VPS侦探论坛

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

绑定多个虚拟主机不成功,虚拟主机只能访问默认目录

[复制链接]
发表于 2015-6-19 14:10:23 | 显示全部楼层 |阅读模式

新装了lnmp1.2,各项设置也完成了,可只有1个虚拟主机能绑定到对应的目录,其他的都到默认目录去了,还请知道的给指点下为什么,谢谢.
cat nginx.conf内容如下:

  1. server
  2.     {
  3.         listen 80 default_server;
  4.         #listen [::]:80 default_server ipv6only=on;
  5.         server_name baisogo.com www.baisogo.com;
  6.         index index.html index.htm index.php;
  7.         root  /home/wwwroot/default;//绑定的虚拟主机却访问到了此目录

  8.         #error_page   404   /404.html;
  9.         include enable-php.conf;

  10.         location /nginx_status
  11.         {
  12.             stub_status on;
  13.             access_log   off;
  14.         }

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

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

  23.         location ~ /\.
  24.         {
  25.             deny all;
  26.         }

  27.         access_log  /home/wwwlogs/access.log  access;
  28.     }
  29. include vhost/*.conf;
  30. }
复制代码

vhost目录下已经有两个虚拟主机文件

  1. [root@localhost conf]# cd vhost/
  2. [root@localhost vhost]# ll
  3. total 8
  4. -rw-r--r--. 1 root root 824 Jun 19 13:28 sobaigu.com.conf
  5. -rw-r--r--. 1 root root 821 Jun 19 12:26 wubase.com.conf
复制代码

其中,sobaigu.com可以正常访问,但wubase.com却访问到了默认的default目录,nginx已重启过了

  1. [root@localhost vhost]# cat wubase.com.conf
  2. server
  3.     {
  4.         listen 80;
  5.         #listen [::]:80;
  6.         server_name wubase.com *.wubase.com;
  7.         index index.html index.htm index.php default.html default.htm default.php;
  8.         root  /home/wwwroot/wubase.com;

  9.         include wordpress.conf;
  10.         #error_page   404   /404.html;
  11.         location ~ [^/]\.php(/|$)
  12.         {
  13.             # comment try_files $uri =404; to enable pathinfo
  14.             try_files $uri =404;
  15.             fastcgi_pass  unix:/tmp/php-cgi.sock;
  16.             fastcgi_index index.php;
  17.             include fastcgi.conf;
  18.             #include pathinfo.conf;
  19.         }

  20.         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  21.         {
  22.             expires      30d;
  23.         }

  24.         location ~ .*\.(js|css)?$
  25.         {
  26.             expires      12h;
  27.         }

  28.         access_log off;
  29.     }
复制代码
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2015-6-19 15:17:13 | 显示全部楼层


/usr/local/nginx/sbin/nginx -t 进行测试配置文件
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2015-6-19 15:22:10 | 显示全部楼层

原帖由 licess 于 2015-6-19 15:17 发表
/usr/local/nginx/sbin/nginx -t 进行测试配置文件

谢谢军哥解答.


  1. [root@localhost ~]# /usr/local/nginx/sbin/nginx -t
  2. nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
  3. nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
复制代码
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2015-6-19 16:09:47 | 显示全部楼层



重装了下nginx,好了,神奇的问题,不知道为什么
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-27 23:26 , Processed in 0.033670 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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