Django No WSGI daemon process has been configured

Viewed 1618

I have a Django project loaded up with Lightsail. I'm looking to get it to run with Apache. I've followed the tutorial located here, but for some reason, it is throwing the following site error and apache error when trying to connect to the server by just it's IP.

Getting the following error when hitting my site:

500 Internal Server Error

When looking at my Apache Logs

No WSGI daemon process called 'smp_api' has been configured: /home/ubuntu/test/smp_api/wsgi.py,

WSGI.py File

import os

from django.core.wsgi import get_wsgi_application

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

application = get_wsgi_application()

Apache Conf

<VirtualHost *:80>

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

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

Alias /static /home/ubuntu/test/static

<Directory /home/ubuntu/test/static>
Require all granted
</Directory>

<Directory /home/ubuntu/test/smp_api>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

<Directory /test>
Require all granted
</Directory>

WSGIDaemonProcess python-path=/home/ubuntu/test
WSGIProcessGroup smp_api
WSGIScriptAlias / /home/ubuntu/test/smp_api/wsgi.py

</VirtualHost>
1 Answers

Edit your Apache conf with the below command:

sudo nano /etc/apache2/sites-available/000-default.conf

Then set your VirtualHost configuration as shown below:

<VirtualHost *:80>
    . . .

    Alias /static /home/user/myproject/static
    <Directory /home/user/myproject/static>
        Require all granted
    </Directory>

    <Directory /home/user/myproject/myproject>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess myproject python-path=/home/user/myproject python-home=/home/user/myproject/myprojectenv
    WSGIProcessGroup myproject
    WSGIScriptAlias / /home/user/myproject/myproject/wsgi.py

</VirtualHost>

NB:

  1. Replace myproject with the name of the directory of your Django project.
  2. Replace myprojectenv with the name of your virtualenv folder and make sure the virtualenv folder resides inside your Django project's root folder.
  3. Run sudo chmod 664 /home/user/myproject/db.sqlite3 to enable apache to read and write your database file.
  4. Run sudo chown :www-data /home/user/myproject/db.sqlite3 to allow apache group own the database file.
  5. Run sudo chown :www-data /home/user/myproject to enable apache have a full access to write to the project's root directory. 6 Finally, run sudo service apache2 restart to restart apache.
  6. Try to access your Django website with your server IP address or domain name.
Related