标签归档:Nginx

TP-Link WR720N刷入OpenWrt之五:Nginx+PHP

OpenWrt和Nginx其实是绝配的,他们很合拍。下面的操作,可以让你的OpenWrt基本支持Nginx+PHP。

opkg update
opkg install nginx
opkg install php5
opkg install php5-cgi
opkg install php5-fastcgi
opkg install spawn-fcgi

编辑Nginx配置文件

vi /etc/nginx/nginx.conf

    server {
        listen       88; #设置端口
        server_name  localhost;

        location / {
            root   /home;	#设置主目录
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location ~ .php$ {
            root           /home; #cgi目录
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; #别管什么了,这行就这样
            include        fastcgi_params;
        }
    }

然后呢,把这句加到开机启动。

spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -f php-cgi

然后,没了。