【问题标题】:wordpress site in subdomain on nginxnginx 子域中的 wordpress 站点
【发布时间】:2014-10-24 16:53:44
【问题描述】:

我在使用 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;
        }
}

【问题讨论】:

    标签: nginx subdomain


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2011-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-27
      • 2014-12-04
      • 2023-02-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多