VPS侦探论坛

标题: 求助301绑定域名,导致phpmyadmin无法访问,急! [打印本页]

作者: 王小安    时间: 2012-2-1 11:14
标题: 求助301绑定域名,导致phpmyadmin无法访问,急!
系统环境:军哥lnmp 0.8, Cent os 6.0 64位, linode 512 vps,discuz x2最新版问题描述:301定向导致phpmyadmin无法访问
故障详情:我在安装lnmp的时候绑定的是www.wasai.org(军哥教程建议绑定一个二级域名),建立虚拟主机时添加的是wasai.org,现在想把域名www.wasai.org重定向到wasai.org


nginx.conf内容是:
  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name wasai.org;
  5.                 index index.html index.htm index.php;
  6.                 root  /home/wwwroot/wasai.org;
  7.                 include discuzx.conf;
复制代码
wasai.org.conf内容是:
  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name wasai.org;
  5.                 index index.html index.htm index.php default.html default.htm default.php;
  6.                 root  /home/wwwroot/wasai.org;

  7.                 include discuzx.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.   listen 80;
  26.   server_name www.wasai.org;
  27.   rewrite ^/(.*) http://wasai.org/$1 permanent;
  28. }
复制代码
大家可能注意到了,nginx.conf的root设置的是/home/wwwroot/wasai.org,不是默认的/home/wwwroot/,因为我删除了安装lnmp后默认的那个index.html,导致访问www.wasai.org显示的是403错误。

现在解决了301重定向的问题,但因为root目录绑定在了/home/wwwroot/wasai.org,,导致我无法访问http://wasai.org/phpmyadmin

很矛盾呀!

想请教各位大虾,我现在想实现这种效果:
1 让wasai.org重定向到www.wasai.org(因为带www的是主流)

2 用户访问www.wasai.org和wasai.org不出现403错误

3 可正常访问http://www.wasai.org/phpmyadmin




该怎么设置nginx.conf和wasai.org.conf文件呢?

急!在线等!

[ 本帖最后由 王小安 于 2012-2-1 11:27 编辑 ]
作者: licess    时间: 2012-2-1 11:43
nginx.conf 里你改了主目录的位置肯定就无法访问phpmyadmin了。
phpmyadmin 都在 /home/wwwroot/ 下面
作者: 王小安    时间: 2012-2-1 11:59
是的,我是绑定了新目录,因为如果绑定在/wwwroot,访问www.wasai.org就403了呀!
作者: licess    时间: 2012-2-1 12:22
你没看到你一个域名绑定了2次吗
nginx.conf绑了一次,你再添加一次肯定不行啊!!

前面你也已经发过了,我建议安装时帮个二级域名,你前面帮个二级域名后面不久一点问题都没了
把ngin.conf里的域名改掉重启
作者: 王小安    时间: 2012-2-1 13:00
军哥,能把修改后的代码直接贴出来吗?思路有点乱
作者: 王小安    时间: 2012-2-1 13:27
我修改nginx.conf:
server

{

listen       80;

server_name www.wasai.org;

index index.html index.htm index.php;

root  /home/wwwroot/;

include discuzx.conf;


和wasai.org.conf:

  1. server
  2.         {
  3.                 listen       80;
  4.                 server_name www.wasai.org;
  5.                 index index.html index.htm index.php default.html default.htm default.php;
  6.                 root  /home/wwwroot/wasai.org;

  7.                 include discuzx.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.   listen 80;
  26.   server_name wasai.org;
  27.   rewrite ^/(.*) http://www.wasai.org/$1 permanent;
  28. }
复制代码



wasai.org是可以跳转到www.wasai.org,但首页是403错误了,绑定root目录没有index.html,因为我网站的内容全在/wasai.org文件夹里的,这就是矛盾的地方。
作者: zy2060537    时间: 2012-2-1 14:08
把phpmyadmin这个目录放到你域名目录里面,然后重启lnmp应该可以吧
我VPS里面就这样放的
作者: 王小安    时间: 2012-2-1 14:35
如果把phpmyadmin放到一个虚拟主机里,以后添加主机怎么办,那几个是所有主机共用的呀!
作者: cnmt    时间: 2012-2-1 17:24
标题: 能不能将默认站点关闭。或设到别的目录。新建的网站可不可以放到其它目录。
能不能将默认站点关闭。或设到别的目录。
新建的网站可不可以放到其它目录。如/home2/wwwroot/
作者: licess    时间: 2012-2-1 21:40
修改nginx.conf 里的域名换成一个二级域名就行了,phpmyadmin 用 http://二级域名/phpmyadmin/ 访问




欢迎光临 VPS侦探论坛 (https://bbs.lnmp.com/) Powered by Discuz! X3.4