当前位置:文档之家› nginx支持php

nginx支持php

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 https://www.doczj.com/doc/1418309019.html,;
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;
}
}

相关主题
文本预览
相关文档 最新文档