Report this

What is the reason for this report?

Failing to run PHP and Django app on same apache server

Posted on January 16, 2017

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.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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

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

DocumentRoot /var/www/html

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

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

  1. additional.conf <VirtualHost IP:80> ServerAdmin admin@domain_name 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 ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined LogLevel debug </VirtualHost>

@w3resource2011

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.