Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to combine Prestashop (PHP) and DjangoCMS (Python)

I need to use DjangoCMS and prestashop with the same url, for example :

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

my prestashop is installed in /var/www/prestashop and djangoCMS is installed in /var/www/djangoCMS.

Linux Mint 14 64 bits, apache2, mod_python, wsgi...

I've tried this 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 works fine on localhost but I can't access to php.localhost : Oops! Google Chrome could not find php.localhost

like image 505
21S Avatar asked Jun 03 '13 10:06

21S


1 Answers

ServerName php.localhost means that you are telling Apache to answer any requests made to http://php.localhost For that you will need to add php.localhost to point to the server IP address (127.0.0.1 if it's your local dev environment)

This won't work in production envirioments. What I suggest is to use ProxyPass, where you can tell apache to redirect all calls to a specific port. For example:

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

That way you will have prestashop running in port 9090, django in port 80 AND tell Apache to redirect all calls from http://localhost/shop to http://localhost:9090

like image 56
StR Avatar answered Nov 01 '22 06:11

StR