在localhost(Ubuntu14.1)中使用NGINX服务器托管多个网站

时间:2018-06-22 09:30:37

标签: ubuntu nginx host

要托管多个网站,我更新了/ etc / nginx / default文件,如下所示:

server {
    listen 8080;
    server_name test;
    root /var/www/test;
    client_max_body_size 3096M;
    location ~* \.(jpg|jpeg|png|gif|ico|css|js){
        expires max;
    }
}

此后,我将/ etc / hosts文件编辑为:

IP address  localhost test;

最后一步:

service nginx restart / service nginx reload

使用http://test访问网站,但是它正在重定向到localhost并显示Ubuntu安装页面。

1 个答案:

答案 0 :(得分:1)

测试虚拟主机正在侦听端口8080,因此您应该使用http://test:8080访问它。

相关问题