[root@localhost php]#tar -jxvf php-5.4.13.tar.bz2 -C /usr/local/src
[root@localhost php]#cd /usr/local/src/php-5.4.13/
#切换到解压后的目录执行安装和拷贝初始化配置文件及服务脚本
[root@localhost php-5.4.13]# ./configure --prefix=/usr/local/php \> --enable-fpm \> --enable-sockets \> --with-mysql=/usr/local/mysql \> --with-mysqli=/usr/local/mysql/bin/mysql_config \> --enable-mbstring \> --enable-xml \> --with-png-dir \> --with-jpeg-dir \> --with-zlib \> --with-freetype-dir \> --with-config-file-path=/etc/php \
> --with-config-file-scan-dir=/etc/php5.d[root@localhost php-5.4.13]#make && make install
[root@localhost php-5.4.13]#mkdir /etc/php /etc/php5.d //创建配置文件存放目录
[root@localhost php-5.4.13]#cp php.ini-production /etc/php/php.ini #拷贝配置文件
[root@localhost php-5.4.13]#cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm #拷贝服务脚本
[root@localhost php-5.4.13]# chmod a+x /etc/init.d/php-fpm #改变可执行权限
[root@localhost php-5.4.13]# cd /usr/local/php/etc #切换到安装目录
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf #生成主配置文件
编辑nginx的配置文件
45 index index.php index.html index.htm;
65 location ~ \.php$ { 66 root html; 67 lastcgi_pass 127.0.0.1:9000; 68 fastcgi_index index.php; 69 fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/fastcgi_script_name; 70 include fastcgi_params; 71 } #将65--71行的注释符号去掉,修改fastcgi_param的路径
测试
[root@localhost ~]# cd /usr/local/nginx/html/ #切换到nginx的网站根目录
[root@localhost html]# vim index.php #编辑index.php在里面调用phpinfo
<!DOCTYPE html><html><body><?php phpinfo() ?></body></html>
重新编index.php
1 <!DOCTYPE html><html><body>2 <?php $link=mysql_connect('127.0.0.1','root','jinzhao');
if($link) echo "ok";else echo"fail";?>3 </body></html>