CentOS6.5 下编译安装php-5.6.3.tar.gz
一、安装相关依赖库
yum-yinstallgccgcc-c++autoconflibjpeglibjpeg-devellibpnglibpng-develfreetypefreetype-devellibxml2libxml2-develglibcglibc-develglib2glib2-develbzip2bzip2-develcurlcurl-developensslopenssl-developenldapopenldap-develnss_ldapopenldap-clientsopenldap-serverspcrepcre-devel
二、解压php包
tar-zxvfphp-5.6.3.tar.gz
cdphp-5.6.3
exportLD_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
makeinstall
四、配置php
cpphp.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#添加执行权限
chkconfigphp-fpmon#设置开机启动
编辑apache配置文件httpd.conf,以apache支持php
#vim/etc/httpd/httpd.conf
添加如下
AddTypeapplication/x-httpd-php.php.phtml
定位至DirectoryIndexindex.html
修改为:
DirectoryIndexindex.phpindex.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