我正在尝试在一个域(少数子域)上使用一台服务器托管几个独立网站。问题是,当我输入任何子域时,它会从根文件夹显示index.html。域记录如下:
domain.xxx (record A pointing to my vps server)
a.domain.xxx (record A pointing to my vps server)
b.domain.xxx (record A pointing to my vps server)
所以每个子/域指向完全相同的地址,但我在我的vps上安装了nginx。我创建了以下目录:
/usr/share/nginx - page root for phpmyadmin(common db)
/usr/share/nginx/a - first page
/usr/share/nginx/b - second page
... c/d/e/f/g - maybe in future
重要的是,每个文件夹都有自己的index.html(带有“文件夹”,“b文件夹”,“根文件夹”),我在默认配置中设置(sites-available / enabled):
#a
server {
listen 80;
server_name www.a.domain.xxx a.domain.xxx;
root /usr/share/nginx/a;
index index.html index.htm index.php;
error_page 404 /404.html;
location ~ \.php$ {
if (!-f $document_root/$fastcgi_script_name){
return 404;
}
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
#b
server {
listen 80;
server_name www.b.domain.xxx b.domain.xxx;
root /usr/share/nginx/b;
index index.html index.htm index.php;
error_page 404 /404.html;
location ~ \.php$ {
if (!-f $document_root/$fastcgi_script_name){
return 404;
}
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
#phpmyadmin
server {
listen 80;
server_name localhost;
root /usr/share/nginx;
index index.html index.htm index.php;
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
无论我会尝试我总是从根文件夹获取index.html。有趣的是,当我键入sub / domain / folder时,它会显示正确的index.html
a.domain.xxx/a displays "a folder"
b.domain.xxx/a displays "a folder"
domain.xxx/a displays "a folder"
可能有一些配置我可以尝试ip而不是那些子域因为可能存在一些DNS问题仅在几小时前就已经设置了记录。
第二个问题是那些网站是用角度2构建的,所以另外你可以给我一些未来的建议(atm我只使用index.html和静态文本)