标签:script cat stat www html erro tac pathinfo microsoft
这篇文章仅仅是操作,解释说明部分待更新。
1. 修改nginx的配置文件(我的配置文件在/etc/nginx/nginx.conf)
[root@xxx ~]# find / -name nginx.conf
[root@xxx ~]# vim /etc/nginx/nginx.conf
nginx.conf配置文件的大致结构: ... http{ server{ ... #一个server结构可以对应一个域名 } include vhosts/*.conf #增加这一句,以后所有新增的域名都可以放在/etc/nginx/vhosts/下,便于分开管理,注意vhosts目录需要创建 }
2. 在/etc/nginx/vhosts/目录下,新增新域名的配置文件xincanzhe.conf(这边我要绑定一个www.xincanzhe.top的域名),复制nginx.conf中的server部分到xincanzhe.conf
server { listen 80; server_name www.xincanzhe.top; #新增域名名称 #charset koi8-r; access_log /data/wwwlogs/www.xincanzhe.top.log combined; #设置访问该域名产生的日志文件,无需创建设置后会自动生成 location / { root /data/wwwroot/xincanzhe/public/; #域名指向的根目录 index index.html index.php index.htm; #隐藏index.php if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /data/wwwroot/xincanzhe/public/; #域名指向的根目录 fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #使Nginx支持pathinfo路由 fastcgi_split_path_info ^(.+\.php)(.*)$; #增加这一句 fastcgi_param PATH_INFO $fastcgi_path_info; #增加这一句 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache‘s document root # concurs with nginx‘s one # #location ~ /\.ht { # deny all; #} }
3. 如果需要再次新增域名,只需要在/etc/nginx/vhosts/新建一个配置文件即可。
nginx服务器绑定多个域名、支持pathinfo路由、隐藏index.php入口文件
标签:script cat stat www html erro tac pathinfo microsoft
原文地址:https://www.cnblogs.com/xincanzhe/p/9031975.html