环 境: rhel4.7(内核 2.6.9-78.EL)
相关软件包: nginx-0.8.8.tar.gz
php-5.2.8.tar.gz
php-5.2.8-fpm-0.5.10.diff.gz
pcre-devel-4.5-4.el4_6.6.rpm (安装nginx的依赖包)
1.php-fpm的安装
# gunzip php-5.2.8.tar.gz | tar xvf - (解压包php-5.2.8,将生成目录php-5.2.8)
# gunzip php-5.2.8-fpm-0.5.10.diff.gz (解压包php-5.2.8-fpm-0.5.10.diff)
# patch -d php-5.2.8 -p1 < php-5.2.8-fpm-0.5.10.diff (给php-5.2.8的源码打上fpm补丁)
# cd php-5.2.8
# ./configure \
--prefix=/usr/local/php \
--enable-fastcgi \
--enable-fpm (配置php-fpm,指定--prefix,若不指定,默认的目录 为/usr/local,编译后显得比较零乱.)
# make all (编译所有)
# make install (编译安装,完成安装)
检查安装
# cd /usr/local/php/bin
# ./php -v (显示如下内容,表示安装正常)
PHP 5.2.8 (cli) (built: Aug 11 2009 22:53:04)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
将php-5.2.8目录下的php.ini-dist 复制到/usr/local/php/lib/php.ini
修改/usr/local/php/etc/php-fpm.conf 配置文件
去掉user,group两行的注释
Unix user of processes
nobody
Unix group of processes
nobody
启动php-fpm
# /usr/local/php/sbin/php-fpm start
2.nginx的安装
# gunzip nginx-0.8.8.tar.gz | tar xvf - (解压缩包nginx-0.8.8,生成目录nginx-0.8.8)
# cd nginx-0.8.8
# ./configure \
--prefix=/usr/local/nginx (指定--prefix.配置前,需要先安装pcre-devel)
# make (编译)
# make install (编译安装)
配置nginx
修改/usr/local/nginx/conf/nginx.conf 配置文件,需做如下修改
user nobody nobody; (首行user去掉注释,并与php-fpm.conf中的user,group配置同)
server {
listen 8080; (修改所使用的端口)
server_name localhost; (修改所使用的服务器名)
# 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行的参数,$fastcgi_script_name 应改为$document_root$fastcgi_script_name,或者使用绝对路径)
完成配置后启动
# /usr/local/nginx/sbin/nginx
编写个phpinfo.php文件保存在/usr/local/nginx/html/目录下,文件内容如下
可通过 访问到php信息页,表明安装成功.
阅读(1422) | 评论(0) | 转发(0) |