王小安 发表于 2012-2-1 11:14:57

求助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内容是:server
      {
                listen       80;
                server_name wasai.org;
                index index.html index.htm index.php;
                root/home/wwwroot/wasai.org;
                include discuzx.conf;wasai.org.conf内容是:server
      {
                listen       80;
                server_name wasai.org;
                index index.html index.htm index.php default.html default.htm default.php;
                root/home/wwwroot/wasai.org;

                include discuzx.conf;
                location ~ .*\.(php|php5)?$
                        {
                              fastcgi_passunix:/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 www.wasai.org;
rewrite ^/(.*) http://wasai.org/$1 permanent;
}大家可能注意到了,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:39

nginx.conf 里你改了主目录的位置肯定就无法访问phpmyadmin了。
phpmyadmin 都在 /home/wwwroot/ 下面

王小安 发表于 2012-2-1 11:59:02

是的,我是绑定了新目录,因为如果绑定在/wwwroot,访问www.wasai.org就403了呀!

licess 发表于 2012-2-1 12:22:51

你没看到你一个域名绑定了2次吗
nginx.conf绑了一次,你再添加一次肯定不行啊!!

前面你也已经发过了,我建议安装时帮个二级域名,你前面帮个二级域名后面不久一点问题都没了
把ngin.conf里的域名改掉重启

王小安 发表于 2012-2-1 13:00:50

军哥,能把修改后的代码直接贴出来吗?思路有点乱

王小安 发表于 2012-2-1 13:27:33

我修改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:

server
        {
                listen       80;
                server_name www.wasai.org;
                index index.html index.htm index.php default.html default.htm default.php;
                root/home/wwwroot/wasai.org;

                include discuzx.conf;
                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_passunix:/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 wasai.org;
rewrite ^/(.*) http://www.wasai.org/$1 permanent;
}


wasai.org是可以跳转到www.wasai.org,但首页是403错误了,绑定root目录没有index.html,因为我网站的内容全在/wasai.org文件夹里的,这就是矛盾的地方。

zy2060537 发表于 2012-2-1 14:08:31

把phpmyadmin这个目录放到你域名目录里面,然后重启lnmp应该可以吧
我VPS里面就这样放的

王小安 发表于 2012-2-1 14:35:25

如果把phpmyadmin放到一个虚拟主机里,以后添加主机怎么办,那几个是所有主机共用的呀!

cnmt 发表于 2012-2-1 17:24:26

能不能将默认站点关闭。或设到别的目录。新建的网站可不可以放到其它目录。

能不能将默认站点关闭。或设到别的目录。
新建的网站可不可以放到其它目录。如/home2/wwwroot/

licess 发表于 2012-2-1 21:40:28

修改nginx.conf 里的域名换成一个二级域名就行了,phpmyadmin 用 http://二级域名/phpmyadmin/ 访问
页: [1]
查看完整版本: 求助301绑定域名,导致phpmyadmin无法访问,急!