VPS CentOS7 nginx 环境 想搭建 2 个站点但是只有第一个站点可以打开,第二个一直错误
首先在nginx.conf的底部添加了include /etc/nginx/conf.d/.conf;
然后在conf.d的目录下有2个文件分别创的是default.conf (第一个站点) 和 try.conf(第二个站点)
try.conf内容
server {
listen 80;
server_name www.karpeng.top;
server_name karpeng.top;
set $root_path '/var/www/html/thinkphp/public';
root $root_path;
index index.php index.html index.htm;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite /(.)$ /index.php?_url=/$1;
}
location ~ .php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.php;
include /etc/nginx/fastcgi_params;
fastcgi_split_path_info (.+.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* /(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /.ht {
deny all;
}
}
default.conf 内容
server {
listen 80;
server_name jijincaigang.win;
set $root_path '/var/www/html/laravel/public';
root $root_path;
index index.php index.html index.htm;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite /(.)$ /index.php?_url=/$1;
}
location ~ .php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.php;
include /etc/nginx/fastcgi_params;
fastcgi_split_path_info (.+.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /.ht {
deny all;
}
}
目录没问题,但是只有default中的站点能打开,如果把try中的root 目录改成和default中一样,就能打开,但是打开的是default的站点。
请问大神,我这里是哪里出错了!
2 Comments
看看错误日志咯~
技术QQ交流群:294088839。