在Apache

时间:2016-06-15 09:31:47

标签: php django configuration apache2 apache-config

我正在尝试在Apache

中托管Django和PHP(wordpress)应用程序

domain.com,应该指向Django app domain.com/wp,应该指向wordpress app

这是我在/ etc / apache2 / sites-available

中的000-default.conf
<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应用程序。

任何人都可以告诉我这个问题的位置,或者给我一个指导来解决这个问题。

1 个答案:

答案 0 :(得分:3)

很少有问题,首先是ServerName只是一个服务器名而不是一个url。第二个问题是您应该合并两个VirtualHost条目。

<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>