nginx上子域中的wordpress站点

时间:2011-11-30 01:59:20

标签: nginx subdomain

我在使用nginx和一些wordpress网站设置子域时遇到问题。

我的www.jackalopegames.com域名正在运行,但我想设置dev.jackalopegames.com。

这是我的网站启用文件夹中的配置文件:

server 
{
    listen 80;
    server_name jackalopegames.com www.jackalopegames.com;

    include /etc/nginx/fastcgi_php;

    root /var/sitefolder;

    index index.php;

}

server {
    listen 80;
    server_name dev.jackalopegames.com;

    include /etc/nginx/fastcgi_php;

    root /var/devfolder;

    index index.php;

}

第一个server_name jackalopegames.com有效,但第二个没有。我环顾了一堆,我不知道为什么这不起作用。任何提示将不胜感激!

更新

我已将以下内容添加到我的子域server {...},但没有效果:

location / {
            root   /var/dev;
            index  index.php;
            rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
            if (!-e $request_filename) {
                rewrite ^.+/?(/wp-.*) $1 last;
                rewrite ^.+/?(/.*\.php)$ $1 last;
                rewrite ^(.+)$ /index.php?q=$1 last;
            }
        }

        location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
        {
            root /var/dev;
            rewrite ^/.*(/wp-.*/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
            rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$/wp-includes/ms-files.php?file=$1 last;
            expires 30d;
            break;
        }

        location ~ wp\-.*\.php|wp\-admin|\.php$ {
            include /etc/nginx/fastcgi_params;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/dev$fastcgi_script_name;
        }
}

1 个答案:

答案 0 :(得分:0)

您可能已经或可能没有检查过很多事情。当我第一次这样做时,我自己也有类似的问题。所以,为了帮助解决问题,我写了一篇关于如何做到这一点的演练。您可以在此处找到它:http://blog.phpadvocate.com/2014/10/setting-up-your-wordpress-blog-as-a-subdomain-with-nginx/