Run both Django and PHP application in Apache

匆匆过客 提交于 2021-02-18 18:00:34

问题


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

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

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 is taking me to wordpress application.

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


回答1:


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>


来源:https://stackoverflow.com/questions/37831508/run-both-django-and-php-application-in-apache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!