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

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

问题描述

我如何做一个Django的网站(在阿帕奇/ 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(字preSS)并排跑一边。字preSS只是服务 mysite.com/show / mysite.com/collection / 。 Django是服务于各地,包括根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.

我想现在要做的,是的,我想使字preSS服务一切,除了应当由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?

谢谢您的回答和提示。

推荐答案

道具格雷厄姆邓普尔顿。他回答完全一样样在这个Q&放大器的另一个问题; A:<一href=\"http://stackoverflow.com/questions/3534678/django-wsgi-and-word$p$pss-coexisting-in-apache-virtualhost\">Django (WSGI)和Word preSS共存于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.

在短,所以根URL是由PHP提供配置Apache后,该解决方案将特定的子网址来Django的,但是使它认为它挂载点仍然是根,是 WSGIScriptAlias​​Match
这个(例子)问题简单的加法到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天全站免登陆