a89910911

CentOS6.5 下编译安装php-5.6.3.tar.gz



 

一、安装相关依赖库 
    yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel curl curl-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers pcre pcre-devel 
二、解压php包 
tar -zxvf php-5.6.3.tar.gz 
cd php-5.6.3 
export LD_LIBRARY_PATH=/usr/local/libgd/lib 
三、编译安装 
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc/ --with-mysql=/usr/local/mysql --with-mysql-sock=/usr/local/mysql/mysql.sock  --with-apxs2=/usr/local/apache/bin/apxs --with-gd --with-jpeg-dir --with-png-dir --enable-mbstring --enable-xml --enable-fpm --with-freetype-dir --with-mcrypt --with-mhash --with-libxml-dir --with-zlib-dir 
make 
make install 
四、配置php 
cp php.ini-production /usr/local/php/etc/php.ini #复制php配置文件到安装目录 
===> 
我安装的时候,放到这里不起作用,移动到/usr/local/php/lib 下,正常 

rm -rf /etc/php.ini #删除系统自带配置文件 
ln -s /usr/local/php/etc/php.ini /etc/php.ini #添加软链接到 /etc目录 
vi /etc/php.ini 
找到:disable_functions = 
修改为:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname 
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。 
找到:;date.timezone = 
修改为:date.timezone = PRC #设置时区 
找到:expose_php = On 
修改为:expose_php = Off #禁止显示php版本的信息 
找到:short_open_tag = Off 
修改为:short_open_tag = ON #支持php短标签 
:wq! 保存 


cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #拷贝模板文件为php-fpm配置文件 
ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf #添加软连接到 /etc目录 
vi /usr/local/php/etc/php-fpm.conf #编辑 
user = www #设置php-fpm运行账号为www 
group = www #设置php-fpm运行组为www 
pid = run/php-fpm.pid #取消前面的分号 
:wq! #保存退出 

cp /home/php-5.6.3/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm #拷贝php-fpm到启动目录 
chmod +x /etc/rc.d/init.d/php-fpm #添加执行权限 
chkconfig php-fpm on #设置开机启动 
编辑apache配置文件httpd.conf,以apache支持php 
# vim /etc/httpd/httpd.conf 
添加如下 

AddType application/x-httpd-php .php .phtml 
定位至DirectoryIndex index.html 

修改为: 
DirectoryIndex index.php index.html 
添加index.php为默认主页 
重新启动apache 
五、测试 
在/usr/local/apache/htdocs目录下建一个test.php或test.phtml的文件,内容如下示: 
<</FONT> 

php 
phpinfo(); 


:wq! #保存退出 

======================================================= 

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 --with-pear --with-curl --with-openssl

评论