重新配置Apache以从新的php源和旧的django站点的特定子网站服务网站根 [英] Reconfiguring Apache to serve website root from new php source and specific sub-urls from old django site

查看:157
本文介绍了重新配置Apache以从新的php源和旧的django站点的特定子网站服务网站根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何制作一个django网站(在apache / mod_wsgi / django设置中),该网站被配置为从根目录提供服务,只为特定的子网址而不是根URL?根网址应从新来源(php)提供。所有这一切都有至少的重新配置。

How do I make a django website (in a apache/mod_wsgi/django setup) which is configured to serve from the root url, serve only for specific sub-url but not the root url? The root url shall be served from a new source (php). All this with a minimum of reconfiguration.

目前,精简的虚拟主机配置看起来像这样

Currently the condensed virtualhost config looks like this

<VirtualHost *:80>
    ServerAdmin admin@mysite.com
    ServerName mysite.com

    # mappings to django
    WSGIScriptAlias / /opt/mysite/mysite.wsgi
    <Directory /opt/mysite>
        Order allow,deny
        Allow from all
    </Directory>

    # mappings to wordpress 
    Alias /wp/ /var/www/mysiteWP/
    <Location "/var/www/mysiteWP/">
            Options -Indexes
    </Location>
    Alias /show/ /var/www/mysiteWP/
    Alias /collection/ /var/www/mysiteWP/
</VirtualHost>

正如你可以看到django和php(wordpress)并行运行。 Wordpress只是提供 mysite.com/show / mysite.com/collection / 。 Django正在为其余的服务,包括root url mysite.com 。这个配置是有效的。

As you can see django and php(wordpress) are running side by side. Wordpress just serving mysite.com/show/ and mysite.com/collection/. Django is serving the rest, including the root url mysite.com. This configuration works.

我现在要做的是,我想让wordpress提供一切,除了django应该提供的一些特定的URL。例如。 django应该仅仅服务于 mysite.com/shop / mysite.com/news / 但没有其他的,也排除 mysite.com

What I want to do now, is, I want to make wordpress serve everything except some specific urls which should be served by django. E.g. django should just serve mysite.com/shop/ and mysite.com/news/ but nothing else, also excluding mysite.com.

如何通过重新配置进行此操作?

How would I do this with a minimum of reconfiguration?

感谢您的答案和提示。 p>

Thanks for your answers and hints.

推荐答案

道歉 Graham Dumpleton 。他在这个问答中回答了另一个完全相同的问题: Django (wsgi)和Wordpress共存在Apache虚拟主机

Props to Graham Dumpleton. He answered another question of the exact same kind in this Q&A: Django (wsgi) and Wordpress coexisting in Apache virtualhost.

简而言之,配置Apache后,从根目录提供从php, url到django,但让它认为它的挂载点仍然是根,是 WSGIScriptAliasMatch
对于这个(示例)问题,apache虚拟主机配置的简单添加是这样的:

In short, after configuring Apache so the root url is served from php, the solution to route specific sub urls to django, but making it think its mount point is still the root, is WSGIScriptAliasMatch. To this (example)problem the simple addition to the apache virtual host config was this:

WSGIScriptAliasMatch ^(/(shop|news)) /opt/mysite/mysite.wsgi$1

整个虚拟主机配置为这个例子是:

The whole virtual host config for this example is:

<VirtualHost *:80>
    ServerAdmin admin@mysite.com
    ServerName mysite.com

    # mappings to django
    WSGIScriptAliasMatch ^(/(shop|news)) /opt/mysite/mysite.wsgi$1
    <Directory /opt/mysite>
        Order allow,deny
        Allow from all
    </Directory>

    # mappings to wordpress 
    DocumentRoot /var/www/mysiteWP/
    <Location "/var/www/mysiteWP/">
            Options -Indexes
    </Location>
</VirtualHost>

这篇关于重新配置Apache以从新的php源和旧的django站点的特定子网站服务网站根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆