nginx支持php

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

1.编译nginx和php,编译之前先装好php相关的包
./configure --prefix=/usr/local/nginx \
--with-http_perl_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-poll_module \
--with-pcre=./pcre-7.6 \
--with-zlib=./zlib-1.2.3

./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-gd \
--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

php4
./configure --prefix=/usr/local/php-fcgi \
--enable-fastcgi \
--enable-discard-path \
--enable-force-cgi-redirect \
--disable-ipv6 \
--with-curl \
--enable-dio \
--with-zlib-dir \
--with-dom \
--with-gd \
--with-jpeg-dir=/usr/lcoal/jpeg6 \
--with-freetype-dir \
--with-iconv \
--enable-mbstring=cn \
--with-mysql=/usr/local/mysql \
--with-snmp \
--enable-sockets

--with-libdir=/usr/lib64

./configure --prefix=/usr/local/php --enable-fastcgi --enable-discard-path --enable-force-cgi-redirect --disable-ipv6 --with-curl --enable-dio --with-zlib-dir --with-dom --with-gd --with-jpeg-dir=/usr/local/jpeg6 --with-freetype-dir --with-iconv --enable-mbstring=cn --with-mysql=/usr/local/mysql --with-snmp --enable-sockets --enable-magic-quotes --enable-exif --with-apxs2=/usr/local/apache228/bin/apxs

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

对于php4,和上面类似,启动方式有点差别,如下:
/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

3.配置nginx.conf


server {
listen 80;
server_name ;
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_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/htdocs/$fastcgi_script_name;
include fastcgi_params;
}
}

相关文档
最新文档