4rsenal 4rsenal - 9 months ago 37
Apache Configuration Question

Multiple django projects on apache [UPDATE]

After help, I have come to a proj.conf of this:

<VirtualHost *:80>
WSGIScriptAlias /f_app /home/4rsenal/f_proj/f_proj/wsgi.py

ErrorLog ${APACHE_LOG_DIR}/error.log
CustumLog ${APACHE_LOG_DIR}/access.log combined

Alias /static/ /home/4rsenal/f_proj/static
<Directory /home/4rsenal/f_proj/static>
Require all granted
</Directory>

<Directory /home/4rsenal/f_proj/f_proj>
<Files wsgi.py>
Requier all granted
</Files>
</Directory>
WSGIProcessGroup f_proj
WSGIDaemonProcess f_proj python-home=/home/4rsenal/f_proj/f_projenv python-path=/home/4rsenal/f_proj
</VirtualHost>

<VirtualHost *:80>
WSGIScriptAlias /m_app /home/4rsenal/m_proj/m_proj/wsgi.py

ErrorLog ${APACHE_LOG_DIR}/error.log
CustumLog ${APACHE_LOG_DIR}/access.log combined

Alias /static/ /home/4rsenal/m_proj/static
<Directory /home/4rsenal/m_proj/static>
Require all granted
</Directory>

<Directory /home/4rsenal/m_proj/m_proj>
<Files wsgi.py>
Requier all granted
</Files>
</Directory>
WSGIProcessGroup m_proj
WSGIDaemonProcess m_proj python-home=/home/4rsenal/m_proj/m_projenv python-path=/home/4rsenal/m_proj
</VirtualHost>


With the new alias', if I type in http://[MYIPADDRESS]/f_app/f_app/ I'm good to go with that site, but if I type in http://[MYIPADDRESS]/m_app/m_app/ I get a Not Found error. Why does one alias work but not the other? (I can fix the stupid looking urls later once I get these to both work).

Answer Source

The basis of the problem if your configuration was accurate was that you had two VirtualHost definitions but neither had a ServerName. This meant name based host name matching couldn't be applied and so it would always use the first VirtualHost.

If you had intended them to be both under the same host name, the configuration should all be in the one VirtualHost.

This sort of problem along with others related to running multiple Django applications at the same time are explained in the blog post:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download