全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 2326|回复: 8

[已解决] 求助一下nginx的域名绑定

[复制链接]
发表于 2012-8-24 15:50:32 | 显示全部楼层 |阅读模式
本帖最后由 jellday 于 2012-8-24 15:51 编辑

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

就是例如 mydomain.conf

  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name abc.mydomain.com;
  5.                 index index.html index.htm index.php default.html default.htm default.php;
  6.                 root  /home/wwwroot/mydomain.com/abc;

  7.                 include none.conf;
  8.                 location ~ .*\.(php|php5)?$
  9.                         {
  10.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  11.                                 fastcgi_index index.php;
  12.                                 include fcgi.conf;
  13.                         }

  14.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  15.                         {
  16.                                 expires      30d;
  17.                         }

  18.                 location ~ .*\.(js|css)?$
  19.                         {
  20.                                 expires      12h;
  21.                         }

  22.                 access_log off;
  23.         }
  24. server
  25.         {
  26.                 listen       80;
  27.                 server_name aaa.mydomain.com;
  28.                 index index.html index.htm index.php default.html default.htm default.php;
  29.                 root  /home/wwwroot/mydomain.com/aaa;

  30.                 include none.conf;
  31.                 location ~ .*\.(php|php5)?$
  32.                         {
  33.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  34.                                 fastcgi_index index.php;
  35.                                 include fcgi.conf;
  36.                         }

  37.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  38.                         {
  39.                                 expires      30d;
  40.                         }

  41.                 location ~ .*\.(js|css)?$
  42.                         {
  43.                                 expires      12h;
  44.                         }

  45.                 access_log off;
  46.         }
  47. server
  48.         {
  49.                 listen       80;
  50.                 server_name bbb.mydomain.com;
  51.                 index index.html index.htm index.php default.html default.htm default.php;
  52.                 root  /home/wwwroot/mydomain.com/bbb;

  53.                 include none.conf;
  54.                 location ~ .*\.(php|php5)?$
  55.                         {
  56.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  57.                                 fastcgi_index index.php;
  58.                                 include fcgi.conf;
  59.                         }

  60.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  61.                         {
  62.                                 expires      30d;
  63.                         }

  64.                 location ~ .*\.(js|css)?$
  65.                         {
  66.                                 expires      12h;
  67.                         }

  68.                 access_log off;
  69.         }

复制代码
有三个server段,行吗?
还是说必须每个域名一个conf文件呢?
发表于 2012-8-24 15:50:59 | 显示全部楼层
都额可以
发表于 2012-8-24 15:53:15 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2012-8-24 15:54:39 | 显示全部楼层
发表于 2012-8-24 15:56:19 | 显示全部楼层
可以呀
发表于 2012-8-24 15:56:59 | 显示全部楼层
可以的。
 楼主| 发表于 2012-8-24 15:57:56 | 显示全部楼层
多谢各位!
发表于 2012-8-24 16:04:52 | 显示全部楼层
域名不多,分开好。 多的的话自然合并
发表于 2012-8-24 16:07:22 | 显示全部楼层
单手摘月 发表于 2012-8-24 15:53
可以,本来就是全部在nginx.conf里面的,lnmp一键包什么的把他们分开而已

思密达
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-29 21:33 , Processed in 0.066274 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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