jax
jax

Reputation: 4197

Two Django apps on apache2 server using wsgi?

I am trying to deploy two Django applications on Apache2 server, running on Ubuntu-16.04. My 000-default.conf file is like given below:

Updated: (Different port) IP which I am using is 172.16.16.68

when I run a single application pep_web, I can connect this application through on browser

172.16.16.68/pep_learn

and for MyApp through the browser like this

172.16.16/MyApp

<VirtualHost *:80>

    <Directory /home/bic/MyApp/MyApp>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess MyApp python-path=/home/bic/MyApp:/usr/lib/python2.7/dist-packages
    WSGIProcessGroup MyApp
    WSGIScriptAlias /MyApp /home/bic/MyApp/MyApp/wsgi.py

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html


</VirtualHost>



<VirtualHost *:8080>


    Alias /static /home/bic/pep_web/protocol/static
    <Directory /home/bic/pep_web/protocol/static>
        Require all granted
    </Directory>


    <Directory /home/bic/pep_web/pep_learn>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess pep_web python-path=/home/bic/pep_web:/usr/lib/python2.7/dist-packages
    WSGIProcessGroup pep_web
    WSGIScriptAlias /pep_learn /home/bic/pep_web/pep_learn/wsgi.py

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html


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


</VirtualHost>

With this setting "MyApp" is working but not the other application "pep_web".
How can I solve this problem?

Upvotes: 2

Views: 170

Answers (1)

itzMEonTV
itzMEonTV

Reputation: 20369

Since both are running in same port 80. You need to add different ServerName in each VirtualHost

For more doc

<VirtualHost *:80>

    <Directory /home/bic/MyApp/MyApp>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess MyApp python-path=/home/bic/MyApp:/usr/lib/python2.7/dist-packages
    WSGIProcessGroup MyApp
    WSGIScriptAlias /MyApp /home/bic/MyApp/MyApp/wsgi.py

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ServerName myapp.com

</VirtualHost>



<VirtualHost *:80>


    Alias /static /home/bic/pep_web/protocol/static
    <Directory /home/bic/pep_web/protocol/static>
        Require all granted
    </Directory>


    <Directory /home/bic/pep_web/pep_learn>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess pep_web python-path=/home/bic/pep_web:/usr/lib/python2.7/dist-packages
    WSGIProcessGroup pep_web
    WSGIScriptAlias /pep_learn /home/bic/pep_web/pep_learn/wsgi.py

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ServerName mypepapp.com


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


</VirtualHost>

Then in /etc/hosts

127.0.0.1       localhost
::1             localhost
#your local domains
127.0.0.1       myapp.com
127.0.0.1       mypepapp.com 

Upvotes: 1

Related Questions