ngnix 配置问题:为什么每次配置都只能成功一个?

2016-10-20 12:00:58 +08:00
 william23

server { server_name www.aaa.com; root /data/web/aaa/;

    location / {
            index index.php;
            try_files $uri $uri/ $uri/index.php /index.php?$args;
    }

    location ~* \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
    }

}

server { server_name www.bbb.com; root /data/web/bbb/;

    location / {
            index index.php;
            try_files $uri $uri/ $uri/index.php /index.php?$args;
    }

    location ~* \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
    }

} 然后 nginx.conf 载入这两个文件 其他都没动 问下是什么情况?

2556 次点击
所在节点    NGINX
10 条回复
Orzzzz
2016-10-20 12:14:31 +08:00
listen 的端口呐?
william23
2016-10-20 13:17:04 +08:00
@Orzzzz 80 ,写的都是 80 ,就只有一个可以
ryd994
2016-10-20 13:19:27 +08:00
那么, error log 说什么呢?
william23
2016-10-20 13:54:58 +08:00
@ryd994 没有显示 error log
whimsySun
2016-10-20 14:02:00 +08:00
http 都是监听 80 端口, nginx 通过 server_name dispatch
william23
2016-10-20 14:05:45 +08:00
@whimsySun 那你的意思是说只能通过 listen 不同的端口来调度我的目录,而不能只用 80 端口来调度是吗?
我指的是同时可以使用哦
dofy
2016-10-20 14:18:59 +08:00
liyvhg
2016-10-20 15:51:56 +08:00
可以参考楼上的, Server{}字段可以写多个, 多个 Server 可以 Listen 相同端口, Nginx 通过 ServerName 来区分
whimsySun
2016-10-20 19:37:29 +08:00
@william23 我看错了,就是监听一个端口
ryd994
2016-10-20 23:26:24 +08:00
@william23 我说的是 /var/log/nginx/error.log

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/314102

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX