php - 在 Apache 中运行 Django 和 PHP 应用程序

标签 php django configuration apache2 apache-config

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

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

这是我的/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 应用程序。

谁能告诉我问题出在哪里,或者给我解决这个问题的方向。

最佳答案

很少有问题,首先是 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>

关于php - 在 Apache 中运行 Django 和 PHP 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37831508/

相关文章:

php - 在链接中输入

php - 在邮件功能 laravel 5 中添加标题

php - 什么时候 PHP 代码真的应该被视为不安全的?

python - Django runserver 在等待查询服务器的外部 Web 服务时挂起

php - 如何在 Joomla 查询中使用 MySQL IN - 语法问题

html - 应用的 CSS 导致 anchor 不可点击

django - 如何更改 django runserver url?

c# - 尽管定义了文件属性,但键值对已添加到 web.config 文件中

xml - log4j - 为什么 logger.debug 不工作?

django - 运行PyCharm测试时,如何解决“django.core.exceptions.ImproperlyConfigured:找不到GDAL库”?