网站运营
位置:首页>> 网站运营>> FreeBSD下nginx并支持php配置详解(2)

FreeBSD下nginx并支持php配置详解(2)

 来源:asp之家 发布时间:2010-03-04 16:31:00 

标签:FreeBSD,nginx,fastcgi方式


二、使用spawn-fcgi支持php

▼首先需要安装lighttpd,以取得spawn-cgi

[root@bsd01 ~]#cd /usr/ports/www/lighttpd
[root@bsd01 lighttpd]#make install clean

▼编辑nginx.con文件:

[root@bsd01 ~]#vi /usr/local/etc/nginx/nginx.conf

user nobody;
user www;
location / {
root /usr/local/www/nginx;
index index.html index.htm;
}

location / {
root /data1/www;
index index.html index.htm index.php;
}

#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data1/www$fastcgi_script_name;
include fastcgi_params;
}

#location ~ /\.ht {
# deny all;
#}

location ~ /\.ht {
deny all;
}

▼现在用spawn-fcgi启动php-cgi进程:

[root@bsd01 lighttpd]#spawn-fcgi -a 127.0.0.1 -p 9000 -u www -C 3 -f /usr/local/bin/php-cgi
Kspawn-fcgi.c.206: child spawned successfully: PID: 25354

“-C 3”就是启动3个php-cgi进程吧,但是好像实际会多1,2个。

[root@bsd01 lighttpd]#ps -aux | grep php-cgi
www 25354 24.6 2.5 30956 12924 ?? Ss 3:33AM 0:00.41 /usr/local/bin/php-cgi
www 25355 0.0 2.5 30956 12964 ?? S 3:33AM 0:00.00 /usr/local/bin/php-cgi

www 25356 0.0 2.5 30956 12964 ?? S 3:33AM 0:00.00 /usr/local/bin/php-cgi
www 25357 0.0 2.5 30956 12964 ?? S 3:33AM 0:00.00 /usr/local/bin/php-cgi

▼然后启动nginx即可:

[root@bsd01 ~]#nginx
[root@bsd01 ~]#pgrep nginx
R25436
f25435

现在来访问我们的web页面,说明nginx已经成功配置:



0
投稿

猜你喜欢

手机版 网站运营 asp之家 www.aspxhome.com