9

我需要使用具有相同 url 的 DjangoCMS 和 prestashop,例如:

localhost/shop = prestashop<br> localhost/everythingElse = DjangoCMS<br>

我的 prestashop 安装在/var/www/prestashopdjangoCMS 安装在/var/www/djangoCMS.

Linux Mint 14 64 位、apache2、mod_python、wsgi...

我试过这个 conf :

<VirtualHost *:80>
DocumentRoot "/var/www/djangoCMS"
ServerName localhost
WSGIScriptAlias / "/var/www/djangoCMS/djangoCMS/apache/django.wsgi"
<Directory "/var/www/djangoCMS/djangoCMS/apache">
    Options +ExecCGI
    Order allow,deny
    Allow from all
</Directory>

<VirtualHost *:80>
DocumentRoot "/var/www/prestashop"
ServerName php.localhost
<Directory "/var/www/prestashop">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order Deny,Allow
    Allow from all
</Directory>

Django 在 localhost 上运行良好,但我无法访问 php.localhost:糟糕!谷歌浏览器找不到 php.localhost

4

1 回答 1

1

ServerName php.localhost 表示您告诉 Apache 回答对http://php.localhost发出的任何请求为此,您需要添加 php.localhost 以指向服务器 IP 地址(如果是本地开发环境,则为 127.0.0.1 )

这在生产环境中不起作用。我建议使用 ProxyPass,您可以在其中告诉 apache 将所有调用重定向到特定端口。例如:

<VirtualHost *:9090>
    ServerName localhost
    DocumentRoot /var/www/prestashop
    <Directory "/var/www/prestashop">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/var/www/djangoCMS"
    ServerName localhost
    WSGIScriptAlias / "/var/www/djangoCMS/djangoCMS/apache/django.wsgi"
    <Directory "/var/www/djangoCMS/djangoCMS/apache">
        Options +ExecCGI
        Order allow,deny
        Allow from all
    </Directory>

    ProxyPass /shop http://localhost:9090
    ProxyPassReverse /shop http://localhost:9090
</virtualHost>

这样,您将在端口 9090 中运行 prestashop,在端口 80 中运行 django 并告诉 Apache 将所有调用从 http://localhost/shop 重定向到 http://localhost:9090

于 2018-03-09T21:01:17.013 回答