2014-12-06 58 views
0

这里是我的服务器设置域引导到nginx的默认页面,而不是我的根

/etc/nginx/sites-available/example.com

server { 
    listen 80; 
    server_name example.com www.example.com 

    root /root/sites/example.com; 
    index index.html; 
} 
server { 
    listen 80; 
    server_name subdomain.example.com www.subdomain.example.com; 

    location /static { 
     alias /var/www/subdomain.example.com/static; 
    } 
    location/{ 
     proxy_set_header HOST $host; 
     proxy_pass http://127.0.0.1:5000; 
    } 
} 

subdomain.example.com工作正常。但是当我去example.com那么它显示nginx的默认欢迎页面。

注:我删除/etc/nginx/sites-enabled/default

需要帮助解决它。

+0

/root/sites/example.com的内容是什么?您在启用网站时有什么功能? – 2014-12-06 15:49:11

+0

这是一个简单的html网站。 'example.com'包含'index.html'和其他'css'文件。 'sites-enabled'有一个文件'examplme.com',它符号链接到'sites-available/example.com'。 'sites-enabled'中没有其他文件。我删除了'sites-enabled/default',但不是'sites-available.default'。 – 2014-12-06 16:46:17

回答

0

你错过了;在您的服务器名称后。

应该是: server_name example.com www.example.com;

0

使用此为您的nginx设置

include /etc/nginx/sites-enabled/*; 

server { 
listen 80; 
server_name example.com www.example.com; 

root /root/sites/example.com; 
index index.html; 

} 

server { 
    listen 80; 
    server_name subdomain.example.com www.subdomain.example.com; 

    location /static { 
     alias /var/www/subdomain.example.com/static; 
    } 
    location/{ 
     proxy_set_header HOST $host; 
     proxy_pass http://127.0.0.1:5000; 
    } 
} 

另外在nginx.conf文件中注释掉任何默认服务器设置。 你可以在conf文件中包含这个服务器设置(它们将被包括在内)并将include命令放在nginx.conf文件中的任何服务器标签之前。

希望这会有所帮助。

相关问题