大神求教:

LNMP 结构,域名xxx.com下想搞个二级域名abc.xxx.com
xxx.com 原来指向目录/usr/share/nginx/html
现在在想abc.xxx.com指向目录/usr/share/nginx/abc

没设二级域名abc.xxx.com时,访问正常!
设了二级域名abc.xxx.com后,访问xxx.com没问题!
但访问abc.xxx.com时,提示说"File not found"
如果是访问abc.xxx.com/info.html 是正常的,就是不能访问下面的*.php,提示"File not found"
如果把配置文件中的“root /usr/share/nginx/abc” 改为跟nginx.conf的root一样,也能正常访问

各位大老,我哪里姿势不对了吗?求教〜

nginx.conf 文件的配置是这样的:


worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

sendfile on;
client_max_body_size 32m;
keepalive_timeout 65;

server {
listen 80;
server_name localhost;
rewrite ^ https://$http_host$request_uri? permanent;
}

server {
listen 443;
server_name xxx.com xxx.com;

... (这里配置SSL,省略了)

root /usr/share/nginx/html;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9900;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

}

include /etc/nginx/conf.d/*.conf;
}

然后在 /etc/nginx/conf.d/ 目录下生成一个abc.conf 该配置是这样的:


server {
listen 443;
server_name abc.xxx.com;

... (这里配置SSL,省略了)

root /usr/share/nginx/abc;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9900;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}