0

我试图让我的 wordpress 网站和我的评论板网站在同一个域名下工作。

前任:

www.mysite.com (this is where i host my wordpress site)
www.mysite.com/reviewboard (this is where I want to host my reviewboard site)

根据我的 httpd-vhosts.conf 文件,我可以让其中一个工作。但是,我不能让两者都工作(这是我需要你帮助的地方!)。

这就是我托管我的 wordpress 网站的方式:

<VirtualHost *:80>
    ServerAdmin myemail@gmail.com
    DocumentRoot "/opt/local/apache2/htdocs/mysite"
    ServerName www.mysite.com
    ErrorLog "/opt/local/apache2/logs/mysite.com-error_log"
    CustomLog "/opt/local/apache2/logs/mysite.com-access_log" common
</VirtualHost>

这就是我托管我的评论板网站的方式(然后破坏了我的 wordpress 网站):

<VirtualHost *:80>
    ServerName www.mysite.com
    DocumentRoot "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs"

    # Error handlers
    ErrorDocument 500 /errordocs/500.html

    WSGIPassAuthorization On
    WSGIScriptAlias "/reviewboard" "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/reviewboard.wsgi/reviewboard"

    <Directory "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs">
        AllowOverride All
        Options -Indexes +FollowSymLinks
        Allow from all
    </Directory>

    # Alias static media requests to filesystem
    Alias /reviewboard/media "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/media"
    Alias /reviewboard/static "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static"
    Alias /reviewboard/errordocs "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/errordocs"
    Alias /reviewboard/favicon.ico "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>

所以,现在我希望能够弄清楚如何以某种方式将这些组合起来,这样我就可以在上面指定的路径上托管评论板,而不会破坏我的 wordpress 网站。我尝试使用此处提到的 Alias 命令:http://stackoverflow.com/questions/1553165/multiple-django-sites-with-apache-mod-wsgi 和这里 https://code.google.com/p/modwsgi /wiki/配置指南

但是我无法让它工作。这是我的在制品。如果您可以非常具体地说明我需要做些什么来改变它,那么它会很好,因为我是这种东西的新手。谢谢!

<VirtualHost *:80>
    ServerName www.mysite.com
    DocumentRoot "/opt/local/apache2/htdocs/mysite"


    # Error handlers
    #hmm not sure where to put this since my document root is different??????
    #ErrorDocument 500 /errordocs/500.html

    WSGIPassAuthorization On
    Alias /reviewboard/ /opt/local/apache2/htdocs/mysite/reviewboard/htdocs/

    <Directory "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs">
        Options ExecCGI
        SetHandler wsgi-script  
        AllowOverride All
        Options -Indexes +FollowSymLinks
        Allow from all
    </Directory>

    # Alias static media requests to filesystem
    # Since I added the alias command above these are complaining about 
    #overlapping an earlier alias when I restart my apache server????
    Alias /reviewboard/media "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/media"
    Alias /reviewboard/static "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static"
    Alias /reviewboard/errordocs "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/errordocs"
    Alias /reviewboard/favicon.ico "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>
4

2 回答 2

0

如果您对两者使用相同的域,则不能对两者使用不同的 VirtualHost 部分。因此,首先,您必须将两种配置合并到一个 VirtualHost 部分。我将从 WordPress 配置开始,然后为 ReviewBoard 添加一些内容:

<VirtualHost *:80>

    ServerAdmin myemail@gmail.com
    DocumentRoot "/opt/local/apache2/htdocs/mysite"
    ServerName www.mysite.com
    ErrorLog "/opt/local/apache2/logs/mysite.com-error_log"
    CustomLog "/opt/local/apache2/logs/mysite.com-access_log" common

    WSGIPassAuthorization On
    WSGIScriptAlias /reviewboard /opt/local/apache2/htdocs/mysite/reviewboard/rb.wsgi
    <Directory /opt/local/apache2/htdocs/mysite/reviewboard>
        Order deny,allow
        Allow from all
    </Directory>

    Alias /reviewboard/media "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/media"
    Alias /reviewboard/static "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static"
    Alias /reviewboard/errordocs "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/errordocs"
    Alias /reviewboard/favicon.ico "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static/rb/images/favicon.png"

</VirtualHost>

你需要创建一个 WSGI 脚本(但你应该已经有了)。您可能希望将其放置在与我在此处的配置中不同的路径中,这样您的权限会更安全。

于 2013-03-11T09:39:39.420 回答
0

结合使用 djc 写的内容和我的一些修改,这是工作版本,这样:

www.mysite.com (wordpress site loads correctly)(mod_php)
www.mysite.com/reviewboard (reviewboard site loads correctly)(mod_wsgi)

重要的是确保每次重新启动 apache 服务器时都清除浏览器缓存,因为我一直陷入显示错误数据的陷阱,因为我忘了这样做。

重要2确保“/reviewboard”跟随“reviewboard.wsgi”成为“reviewboard.wsgi/reviewboard”,否则它将无法工作并给出404错误!

这是工作版本:

<VirtualHost *:80>
    ServerAdmin myemail@gmail.com
    ServerName www.mysite.com
    DocumentRoot "/opt/local/apache2/htdocs/mysite"
    ErrorLog "/opt/local/apache2/logs/mysite-error_log"
    CustomLog "/opt/local/apache2/logs/mysite-access_log" common

    WSGIPassAuthorization On
    WSGIScriptAlias /reviewboard /opt/local/apache2/htdocs/mysite/reviewboard/htdocs/reviewboard.wsgi/reviewboard
    <Directory /opt/local/apache2/htdocs/mysite/reviewboard>
        Allow from all
        Options -Indexes +FollowSymLinks
        AllowOverride All
    </Directory>

    # Alias static media requests to filesystem
    Alias /reviewboard/media "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/media"
    Alias /reviewboard/static "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static"
    Alias /reviewboard/errordocs "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/errordocs"
    Alias /reviewboard/favicon.ico "/opt/local/apache2/htdocs/mysite/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>
于 2013-03-12T04:52:53.610 回答