下载压缩包php-5.6.14 (2).tar.gz
tar -zxvf php-5.6.14.tar.gz
cd php-5.6.14
yum install gcc
yum install libxml2-dev
yum install openssl
yum install libcurl3-openssl-dev
yum install libjpeg-dev
yum install libpng-dev
yum install libmcrypt-dev
########注意GD的安装 jpeg 下载jpeg安装包编译安装,
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/var/lib/mysql/mysql.sock --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl
--with-mysql=/usr # 路径指的是安装完 server 之后,mysql 的basedir
--with-mysqli=/usr/bin/mysql_config # 如果只安装了 server 和 client,默认情况下是没有用于编译mysql客户端程序的 mysql_config 这个可执行命令的
--with-mysql-sock=/var/lib/mysql/mysql.sock
make && make install
cp php.ini-production /usr/local/php5/etc/php.ini #复制php配置文件到安装目录
rm -rf /etc/php.ini #删除系统自带配置文件
ln -s /usr/local/php5/etc/php.ini /etc/php.ini #添加软链接
cp /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf #拷贝模板文件为php-fpm配置文件
vi /usr/local/php5/etc/php-fpm.conf #编辑
user = www #设置php-fpm运行账号为www
group = www #设置php-fpm运行组为www
pid = run/php-fpm.pid #取消前面的分号
设置 php-fpm开机启动
cp /usr/local/php5/sbin/php-fpm /etc/init.d/php-fpm #拷贝php-fpm到启动目录
chmod +x /etc/init.d/php-fpm #添加执行权限
vi /usr/local/php5/etc/php.ini #编辑配置文件
配置nginx支持php
vi /usr/local/nginx/conf/nginx.conf #编辑配置文件,需做如下修改
user www www; #首行user去掉注释,修改Nginx运行组为www www;必须与/usr/local/php5/etc/php-fpm.conf中的user,group配置相同,否则php运行出错
index index.php index.html index.htm; #添加index.php
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
/etc/init.d/nginx restart #重启nginx
/etc/init.d/php-fpm -c /usr/local/php5/etc/php.ini #加载配置文件 同时已经启动php-fpm
扩展配置。事例:http://blog.sina.com.cn/s/blog_69cc2f0b0100wa8z.html
http://www.cnblogs.com/xiangxiaodong/archive/2013/12/25/3490570.html
错误:Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.
解决地址:http://blog.csdn.net/21aspnet/article/details/7471574
#yum install autoconf
参考资料
http://blog.csdn.net/xc_gxf/article/details/8225002
http://www.centoscn.com/CentosServer/www/2013/0730/818.html
http://www.nowamagic.net/academy/detail/1226244