Centos配置np
Centos配置np
配置一
1
2
3
4
5
6
7
8
9
10
11
12
13
14
server
{
listen 80;
server_name localhost;
index index.html index.htm index.php;
root /usr/local/nginx/html;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
}
}
配置二
http://blog.jobbole.com/50121/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
server {
listen 80;
server_name foo.com;
root /path;
location / {
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite . /index.php last;
}
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /path$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
}
评价一:index应该放在server环境下。
评价二:if不应该代替try_files:try_files $uri $uri/ /index.php;。
评价三:Nginx有两份fastcgi的配置文件,分别是fastcig_params和fastcgi.conf,它们没有太大的区别,唯一的区别在与后者比前者多一行SCRIPT_FILENAME的定义:fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name。
本文由作者按照
CC BY 4.0
进行授权