1.编译nginx和php,编译之前先装好php相关的包
cd /usr/local/src/nginx
./configure --prefix=/usr/local/nginx \
--with-http_perl_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-poll_module \
--with-pcre=/home/webroot/pcre-7.6 \
--with-zlib=/home/webroot/zlib-1.2.3
cd /usr/local/src/php
./configure --prefix=/usr/local/php-fcgi \
--with-mysql=/usr/local/mysql \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir=/usr/lcoal/jpeg6 \
--with-png-dir \
--with-zlib \
--with-libxml-dir \
--enable-xml \
--disable-debug \
--disable-rpath \
--enable-discard-path \
--enable-safe-mode \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-curlwrappers \
--enable-mbregex \
--enable-fastcgi \
--enable-force-cgi-redirect \
--enable-mbstring
2.借用lighttpd的spawn-fcgi启动php-cgi进程,监听127.0.0.1的9000端口,
进程数为64(如果服务器内存小于3GB,可以只开启25个进程),用户为nobody:
/usr/local/php-fcgi/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 64 -u nobody -f /usr/local/php-fcgi/bin/php-cgi
3.配置nginx.conf
server {
listen 81;
server_name abc.com;
root /usr/local/htdocs;
index index.html index.htm index.php;
location ~ \.php$ {
root /usr/local/htdocs;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/htdocs/$fastcgi_script_name;
include fastcgi_params;
}
}
阅读(2622) | 评论(0) | 转发(1) |