VPS侦探论坛

 找回密码
 注册
查看: 13736|回复: 3

nginx 下如何添加多网站 多域名?

[复制链接]
发表于 2010-7-12 22:34:04 | 显示全部楼层 |阅读模式

nginx下添加域名是不是有两种方式
1 直接运行 ./vhost.sh   
2
  1. 修改/usr/local/nginx/conf/nginx.conf 文件

  2. server
  3. {
  4. listen 80;
  5. server_name status.lnmp.org;
  6. location / {
  7. stub_status on;
  8. access_log off;
  9. }
  10. }
  11. 后面添加上下面代码:
  12. server
  13. {
  14. listen 80;
  15. server_name www.abc.com
  16. ;
  17. index index.html index.htm index.php;
  18. root /home/wwwroot/abc;
  19. location ~ .*\.(php|php5)?$
  20. {
  21. fastcgi_pass unix:/tmp/php-cgi.sock;
  22. #fastcgi_pass 127.0.0.1:9000;
  23. fastcgi_index index.php;
  24. include fcgi.conf;
  25. }
  26. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  27. {
  28. expires 30d;
  29. }
  30. location ~ .*\.(js|css)?$
  31. {
  32. expires 12h;
  33. }
  34. access_log off;
  35. }
  36. 再执行kill -HUP `cat /usr/local/nginx/logs/nginx.pid`虚拟机就生效了。
复制代码
我用./vhost.sh  添加 了一个域名 和目录后  显示



不知道这样的目录正确不正确.
然后在***.com 里放了一个网页文件 ,访问 显示 403 Forbidden.

有熟练nginx的朋友麻烦讲解一下, 添加多网站目录,多域名的步骤.

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2010-7-13 09:05:09 | 显示全部楼层

回复 1# 的帖子



server{}段要加在nginx.conf最后一个}的前面,显示403很正常,因为目录下面没有index文件。
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2010-11-18 15:19:33 | 显示全部楼层

多谢了!!正需要这个!
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2011-2-12 09:22:57 | 显示全部楼层



怎么添加多网站多域名啊?
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-19 09:17 , Processed in 0.027287 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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