方永、南天紫云

道亦有道

OpenWrt架设nginx php网站
作者 vinoca 發布於 2012年05月31日

php就不说了,之前的一篇日志都做介绍了,关键是nginx。

以下是参考

opkg update
opkg install shadow-groupadd shadow-useradd spawn-fcgi nginx
groupadd www
useradd -g www www
chown -R www:www /www/wwwroot
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 2 -f /usr/bin/php-cgi
/etc/init.d/nginx start

nginx.conf:

user www www;
worker_processes 1;
pid /var/run/nginx.pid;
 
events {
use epoll;
worker_connections 1024;
}
 
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
 
server {
listen 80;
server_name localhost;
index index.php;
root /www/html;
 
location ~* ^.+\.php(\/.*)*$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
 
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}

Typecho运行良好。