Failing to run PHP and Django app on same apache server

January 16, 2017 399 views
PHP Django Apache Ubuntu

I am trying to run PHP and Django on same Apache server. PHP site is running fine but when I point to Djnago App's url, it shows directory structure only. Any help is greatly appreciated.

2 Answers

@w3resource2011

What's your current configuration look like? (i.e. both VirtualHosts + any additional configuration that you've done)

I have two .conf files in /etc/apache2/sites-available/

  1. basic.conf NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin admin@domainname ServerName domainname

DocumentRoot /var/www/html

<Directory /var/www/html/>
Order deny,allow
Allow from all
</Directory>

ErrorLog ${APACHELOGDIR}/error.log
CustomLog ${APACHELOGDIR}/access.log combined
LogLevel debug
</VirtualHost>

  1. additional.conf
    <VirtualHost IP:80>
    ServerAdmin admin@domainname
    DocumentRoot /var/www/html/qa
    ServerName domain
    name

    aliases to serve static media directly

    Alias /m/ /var/www/html/qa/static/
    Alias /upfiles/ /var/www/html/qa/askbot/upfiles/
    <DirectoryMatch "/var/www/html/qa/askbot/skins/([^/]+)/media">
    Order deny,allow
    Allow from all
    </DirectoryMatch>
    <Directory "/var/www/html/qa/askbot/upfiles">
    Order deny,allow
    Allow from all
    </Directory>
    <Directory "/var/www/html/qa/ask-skins">
    Order deny,allow
    Allow from all
    </Directory>

    <Directory "/var/www/html/qa/static">
    Order deny,allow
    Allow from all

    </Directory>
    #must be a distinct name within your apache configuration
    WSGIDaemonProcess askbot2
    WSGIProcessGroup askbot2

    WSGIScriptAlias / /var/www/html/qa/django.wsgi

    <Directory /var/www/html/qa>
    <Files django.wsgi>
    Order deny,allow
    Allow from all
    </Files>
    </Directory>

    make all admin stuff except media go through secure connection

    <LocationMatch "/admin(?!/media)">
    RewriteEngine on
    RewriteRule /admin(.*)$ http://domain_name/admin$1 [L,R=301]
    </LocationMatch>
    ErrorLog ${APACHELOGDIR}/error.log
    CustomLog ${APACHELOGDIR}/access.log combined
    LogLevel debug
    </VirtualHost>

Have another answer? Share your knowledge.