./configure
make
make install
其中 sourceforge.net 上的地址,如果不能下载,请点此从本站(path8.net)下载:libmcrypt-2.5.8.tar.bz2.zip [注]本文件是再次zip压缩的,使用时需先unzip 再tar x]
或者你可以到http://mcrypt.sourceforge.net/下载,但要注意,我们需要的是 libmcrypt而不是mcrypt,这里很容易搞错。
开始configure php源码
现在应该对configure很熟悉了吧,用普通用户执行
[feng@fsvps php-5.3.14]$ ./configure --prefix=/usr/local/php53 --with-config-file-path=/usr/local/etc --with-config-file-scan-dir=/usr/local/etc/php.d --mandir=/usr/local/man --enable-fpm --enable-calendar --with-mcrypt --enable-ftp --with-zlib --with-bz2 --with-curl --with-gd --enable-exif --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-mbstring --with-mysql --with-mysqli --with-pdo-mysql --enable-zip --enable-bcmath --with-bz2
这一步要花几分钟时间,不出意外将出现如下消息:
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
按下来,make,这一步更慢,可能要二十分钟,耐心等,或者做点其它事情。
看到如下消息,就是完成了。
Build complete.
Don't forget to run 'make test'。
可以执行一下make test 检测一下,不过一般没有必要,切换到root身份运行make install安装。
[iyunv@fsvps php-5.3.14]# make install
最好记下来这里的消息,它是php的几个重要配置文件的默认路径,下面用得着。
配置并启动php-fpm进程
php-fpm的配置文件位于/usr/local/php53/etc/,这里有个php-fpm.conf.default,用它复制出php-fpm.conf
[iyunv@fsvps php-5.3.14]# ls -l /usr/local/php53/etc/
-rw-r--r-- 1 root root 1172 7月 1 07:20 pear.conf
-rw-r--r-- 1 root root 20891 7月 1 07:20 php-fpm.conf.default
[iyunv@fsvps php-5.3.14]# cp /usr/local/php53/etc/php-fpm.conf{.default,}
修改php-fpm.conf如下几处:
(约第25行) pid = /var/run/php-fpm.pid
(约第32行) error_log = /var/log/php-fpm.log
(约第190行) pm = static
启动php-fpm进程
[iyunv@fsvps php-5.3.14]# /usr/local/php53/sbin/php-fpm
执行后,没有任何输出。如果有错误请查看php-fpm的日志文件 /var/log/php-fpm.log
整合 PHP 与 nginx
直到现在,我们的nginx还是只能处理静态文件,我们接下来要做的是:让nginx把对.php文件的请求,转给php-fpm来处理。
打开nginx配置文件,在server{...}节点里面,有这样一行 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 ,下面的 location ...{...}节点取消注释,改成如下形式(修改部分使用红字加粗):
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/default$fastcgi_script_name;
include fastcgi_params;
}
保存,检查配置nginx -t,无误后重新加载nginx配置 nginx -s reload
写一个php程序文件 /var/www/html/default/phpinfo.php 内容为:
<?php
phpinfo();
?>
用浏览器通过ip地址访问phpinfo.php,看到你亲自编译的nginx+php-fpm在工作了吧。