如何组合Prestashop(PHP)和DjangoCMS(Python)

21S*_*21S 7 php python apache django prestashop

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

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>
Run Code Online (Sandbox Code Playgroud)

<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>
Run Code Online (Sandbox Code Playgroud)

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

StR*_*StR 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>
Run Code Online (Sandbox Code Playgroud)

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