各位大神,Nginx的二级域名到底怎么配置才对呀?
大神求教: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_processes1;
events {
worker_connections1024;
}
http {
include mime.types;
default_typeapplication/octet-stream;
sendfile on;
client_max_body_size 32m;
keepalive_timeout65;
server {
listen 80;
server_namelocalhost;
rewrite ^ https://$http_host$request_uri? permanent;
}
server {
listen 443;
server_namexxx.com xxx.com;
... (这里配置SSL,省略了)
root /usr/share/nginx/html;
location / {
indexindex.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9900;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_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_nameabc.xxx.com;
... (这里配置SSL,省略了)
root /usr/share/nginx/abc;
location / {
indexindex.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9900;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
include fastcgi_params;
}
}
回复 1# 的帖子
难道坛子里没人知道吗? 看你发的配置文件不是 https://lnmp.org 安装包安装的看你这配置文件到处是问题,如果是用 https://lnmp.org 安装包安装的,自己乱改了文件,将配置文件恢复到原来的配置文件,按官网上的虚拟主机添加方法进行添加
页:
[1]