在 Apache 中同时运行 Django 和 PHP 应用程序 [英] Run both Django and PHP application in Apache

查看:24
本文介绍了在 Apache 中同时运行 Django 和 PHP 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Apache 中托管 Django 和 PHP(wordpress) 应用

I'm trying to host Django and PHP(wordpress) app in Apache

domain.com,应该指向 Django 应用domain.com/wp,应该指向 wordpress 应用程序

domain.com, should point to Django app domain.com/wp, should point to wordpress app

这是我在/etc/apache2/sites-available 中的 000-default.conf

Here is my 000-default.conf in /etc/apache2/sites-available

<VirtualHost *:80>
    DocumentRoot "/var/www/html/wp"
    ServerName domain.com/wp
    Alias /wp /var/www/html/wp
    <Directory /var/www/html/wp>
        Options Indexes FollowSymLinks
        AllowOverride None
        Order Deny,Allow
        Allow from all
    </Directory>
</VirtualHost>                            

<VirtualHost *:80>
        Alias /static /var/www/html/portal/static
        <Directory /var/www/html/portal/static>
                Require all granted
        </Directory>

        <Directory /home/ubuntu/portal/portal>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

        WSGIDaemonProcess portal python-path=/home/ubuntu/portal:/home/ubuntu/portal/env/lib/python2.7/site-packages
        WSGIProcessGroup portal
        WSGIScriptAlias / /home/ubuntu/portal/portal/wsgi.py
</VirtualHost>

domain.com 将我带到 wordpress 应用程序.

domain.com is taking me to wordpress application.

谁能告诉我问题出在哪里或给我一个方向来解决这个问题.

Can anyone tell me where the issue is or give me a direction to solve this.

推荐答案

几个问题,首先是 ServerName 只是一个服务器名而不是一个 url.第二个问题是您应该组合两个 VirtualHost 条目.

Few issues, first thing is that the ServerName is just a servername and not a url. The second issue is that you should combine the two VirtualHost entries.

<VirtualHost *:80>
    DocumentRoot "/var/www/html"
    ServerName domain.com
    Alias /wp /var/www/html/wp
    <Directory /var/www/html/wp>
        Options Indexes FollowSymLinks
        AllowOverride None
        Order Deny,Allow
        Allow from all
    </Directory>

    Alias /static /var/www/html/portal/static
    <Directory /var/www/html/portal/static>
                Require all granted
    </Directory>

    # this really should be a sub directory of /var/www/html
    # if your server config follows symlinks, just make a symlink  
    <Directory /home/ubuntu/portal/portal>
                <Files wsgi.py>
                        Require all granted
                </Files>
    </Directory>

    WSGIDaemonProcess portal python-path=/home/ubuntu/portal:/home/ubuntu/portal/env/lib/python2.7/site-packages
    WSGIProcessGroup portal
    WSGIScriptAlias / /home/ubuntu/portal/portal/wsgi.py
</VirtualHost>

这篇关于在 Apache 中同时运行 Django 和 PHP 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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