找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 68|回复: 7

求助一下nginx的域名绑定

[复制链接]

30

主题

18

回帖

150

积分

注册会员

积分
150
发表于 2012-8-24 15:50:32 | 显示全部楼层 |阅读模式
本帖最后由 jellday 于 2012-8-24 15:51 编辑

想问一下,我要加很多域名,能不能在vhost目录下建一个文件,然后加很多个server 段(就是server{...})?

就是例如 mydomain.conf[ol]
  • server
  •         {
  •                 listen       80;
  •                 server_name abc.mydomain.com;
  •                 index index.html index.htm index.php default.html default.htm default.php;
  •                 root  /home/wwwroot/mydomain.com/abc;
  •                 include none.conf;
  •                 location ~ .*\.(php|php5)?$
  •                         {
  •                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  •                                 fastcgi_index index.php;
  •                                 include fcgi.conf;
  •                         }
  •                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  •                         {
  •                                 expires      30d;
  •                         }
  •                 location ~ .*\.(js|css)?$
  •                         {
  •                                 expires      12h;
  •                         }
  •                 access_log off;
  •         }
  • server
  •         {
  •                 listen       80;
  •                 server_name aaa.mydomain.com;
  •                 index index.html index.htm index.php default.html default.htm default.php;
  •                 root  /home/wwwroot/mydomain.com/aaa;
  •                 include none.conf;
  •                 location ~ .*\.(php|php5)?$
  •                         {
  •                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  •                                 fastcgi_index index.php;
  •                                 include fcgi.conf;
  •                         }
  •                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  •                         {
  •                                 expires      30d;
  •                         }
  •                 location ~ .*\.(js|css)?$
  •                         {
  •                                 expires      12h;
  •                         }
  •                 access_log off;
  •         }
  • server
  •         {
  •                 listen       80;
  •                 server_name bbb.mydomain.com;
  •                 index index.html index.htm index.php default.html default.htm default.php;
  •                 root  /home/wwwroot/mydomain.com/bbb;
  •                 include none.conf;
  •                 location ~ .*\.(php|php5)?$
  •                         {
  •                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  •                                 fastcgi_index index.php;
  •                                 include fcgi.conf;
  •                         }
  •                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  •                         {
  •                                 expires      30d;
  •                         }
  •                 location ~ .*\.(js|css)?$
  •                         {
  •                                 expires      12h;
  •                         }
  •                 access_log off;
  •         }
  • [/ol]复制代码有三个server段,行吗?
    还是说必须每个域名一个conf文件呢?
  • 回复

    使用道具 举报

    76

    主题

    780

    回帖

    1862

    积分

    金牌会员

    积分
    1862
    发表于 2012-8-24 15:50:59 | 显示全部楼层
    都额可以
    回复

    使用道具 举报

    1215

    主题

    1万

    回帖

    2万

    积分

    论坛元老

    积分
    28601
    发表于 2012-8-24 15:53:15 | 显示全部楼层
    回复

    使用道具 举报

    549

    主题

    1万

    回帖

    2万

    积分

    论坛元老

    积分
    23801
    发表于 2012-8-24 15:54:39 | 显示全部楼层
    可以呀
    回复

    使用道具 举报

    276

    主题

    2541

    回帖

    5964

    积分

    论坛元老

    积分
    5964
    发表于 2012-8-24 15:56:19 | 显示全部楼层
    可以的。
    回复

    使用道具 举报

    84

    主题

    2424

    回帖

    5158

    积分

    论坛元老

    积分
    5158
    发表于 2012-8-24 15:56:59 | 显示全部楼层
    多谢各位!
    回复

    使用道具 举报

    30

    主题

    18

    回帖

    150

    积分

    注册会员

    积分
    150
     楼主| 发表于 2012-8-24 15:57:56 | 显示全部楼层
    域名不多,分开好。 多的的话自然合并
    回复

    使用道具 举报

    395

    主题

    1968

    回帖

    5253

    积分

    论坛元老

    积分
    5253
    发表于 2012-8-24 16:04:52 | 显示全部楼层

    单手摘月 发表于 2012-8-24 15:53



    可以,本来就是全部在nginx.conf里面的,lnmp一键包什么的把他们分开而已

    思密达
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|Discuz! X

    GMT+8, 2025-4-20 22:30 , Processed in 0.022559 second(s), 5 queries , Gzip On, Redis On.

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表