论坛首页 入门技术论坛

nginx spawn-fcgi php

浏览 2732 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2010-04-22   最后修改:2010-06-18

安装spawn-fcgi

# emerge spawn-fcgi
 

安装nginx

# USE="pcre perl ssl zlib -addition -debug fastcgi -flv -imap -pop -random-index -realip -smtp static-gzip status -sub -webdav" emerge nginx
 

启动端口

# /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u uu -f /usr/bin/php-cgi
 

修改配置

# nano -w /etc/nginx/nginx.conf
{{{
 server {
        listen       80;
        server_name  localhost;

        root /var/www/localhost/htdocs;
        #index index.php index.html;
        location ~\.php$ {
                include        fastcgi.conf;
                include         fastcgi_params;
                }
        }

}}}

# nano -w /etc/nginx/fastcgi.conf
{{{

fastcgi_pass   127.0.0.1:9000;

set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
        set $real_script_name $1;
        set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}}}
 

启动

# /etc/init.d/nginx start
 

准备php测试文件

nano /var/www/localhost/htdocs/test.php
{
<?php
phpinfo();
?>
}
 



浏览成果
#visit in browser
http://192.168.0.111/test.php

论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics