时间:2021-07-01 10:21:17 帮助过:26人阅读
server {
listen 80;
server_name 此处网站域名;
root /usr/local/www/web/go;
location / {
root /usr/local/www/web/go;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php/$1 last;
break;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ .php$ {
root /usr/local/www/web/go;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#定义变量 $path_info ,用于存放pathinfo信息
set $path_info "";
#定义变量 $real_script_name,用于存放真实地址
set $real_script_name $fastcgi_script_name;
#如果地址与引号内的正则表达式匹配
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
#将文件地址赋值给变量 $real_script_name
set $real_script_name $1;
#将文件地址后的参数赋值给变量 $path_info
set $path_info $2;
}
#配置fastcgi的一些参数
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
#fastcgi_param SCRIPT_FILENAME /usr/local/www/web/go$fastcgi_script_name;
include fastcgi_params;
}
}
}
server {
listen 80;
server_name www.phpno.com;
root /home/www/www_phpno_com/admin_wwwroot;
access_log off;
error_page 404 /404.html;
location /404.html {
root /home/www/www_phpno_com/admin_wwwroot;