nginx 默认只解析静态 html ,如果要解析 PHP ,首先要安装 PHP ,之后在server段添加如下代码
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
即这个样子:
server {
listen 80;
root your_web_root;
index index.php index.html index.htm;
server_name
XXX.com;
location / {
这里填rewrite lules,如果不需要就留空
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}