[Answer]-VirtualHost configuration doesn't allow second website to run

1πŸ‘

βœ…

In order to use your django application inside a virtual host you need to set the WSGIScriptAlias inside the virtualhost settings and also you can’t use the WSGIPythonPath, you need to use WSGIDaemonProcess like in the following settings.

<VirtualHost *:80>
    WSGIScriptAlias / /home/ubuntu/v1/staginnx-info/app/website/website/wsgi.py
    WSGIDaemonProcess example.com python-path=/home/ubuntu/v1/staginnx-info/app/website

    # Admin email, Server Name (domain name) and any aliases
    ServerAdmin info@staginnx.com
    ServerName  staginnx.com
    ServerAlias www.staginnx.com

    <Directory /home/ubuntu/v1/staginnx-info/app/website/website>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    Alias /static/ /home/ubuntu/v1/staginnx-info/app/website/ui/static/

    <Directory /home/ubuntu/v1/staginnx-info/app/website/ui/static>
        Require all granted
    </Directory>

    Alias /favicon.ico /home/ubuntu/v1/staginnx-info/app/website/ui/static/images/favicon.ico

    ErrorLog /var/log/apache2/error.log

</VirtualHost>

Also in case you want to host multiple application on the same host then you need to change a small setting in the wsgi.py file as well.

instead of using

os.environ.setdefault(DJANGO_SETTINGS_MODULE, "app.settings")

you should use

os.environ["DJANGO_SETTINGS_MODULE"] = "app.settings"

I hope this helps you.

For WSGIDaemonProcess setting

πŸ‘€abhishekgarg

Leave a comment