location ~ \.php { # 这里减掉一个“$”原本是\.php$
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php; # 这一句不知道什么用处
fastcgi_split_path_info ^(.+\.php)(.*)$; # 加了这一句
fastcgi_param PATH_INFO $fastcgi_path_info; # 还有这一句
include fastcgi.conf;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php; # 这一句不知道什么用处
fastcgi_split_path_info ^(.+\.php)(.*)$; # 加了这一句
fastcgi_param PATH_INFO $fastcgi_path_info; # 还有这一句
include fastcgi.conf;
}
yii----------------------------------------------
location ~ \.php { # ......<93>$<94>...\.php$
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php; # ..........
fastcgi_split_path_info ^(.+\.php)(.*)$; # ....
# fastcgi_param PATH_INFO $fastcgi_path_info; # .....
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi.conf;
}
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php; # ..........
fastcgi_split_path_info ^(.+\.php)(.*)$; # ....
# fastcgi_param PATH_INFO $fastcgi_path_info; # .....
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi.conf;
}
---------------------------------------------
nginx 配置
server {
listen 8080;
server_name 192.168.1.168;
root html/e3m;
location / {
root html/e3m;
index index.html index.php;
if ($request_filename !~ (connect|gif|png|jpg|js|css|images|source|robots/.txt|index/.php.*) ) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~* .(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php { # ......<93>$<94>...\.php$
root html/e3m;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php; # ..........
fastcgi_split_path_info ^(.+\.php)(.*)$; # ....
# fastcgi_param PATH_INFO $fastcgi_path_info; # .....
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi.conf;
}
}
listen 8080;
server_name 192.168.1.168;
root html/e3m;
location / {
root html/e3m;
index index.html index.php;
if ($request_filename !~ (connect|gif|png|jpg|js|css|images|source|robots/.txt|index/.php.*) ) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~* .(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php { # ......<93>$<94>...\.php$
root html/e3m;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php; # ..........
fastcgi_split_path_info ^(.+\.php)(.*)$; # ....
# fastcgi_param PATH_INFO $fastcgi_path_info; # .....
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi.conf;
}
}
最后执行
/usr/local/nginx/sbin/nginx -s reload
就完事儿了

本文详细介绍了Nginx服务器的配置方法,包括监听端口、指定服务器名称、设置根目录等基本配置,以及如何通过rewrite规则实现URL重写,如何配置FastCGI参数以支持PHP解析等功能。
5071

被折叠的 条评论
为什么被折叠?



