I'm trying to set up an Apache2/Django server on Ubuntu 18.04 x64 Digital Ocean droplet. I've went through the tutorials but still get an error. I've searched Stackoverflow and other sources for the solution, but still nothing works. Would someone be able to help?
The project is placed in /root/myproject. I use virtualenv that I named myprojectenv. So the python path is correct with /root/myproject/myprojectenv. I'm using Python 3.6 and the version of /root/myproject/myprojectenv/bin/python is indeed 3.6. I'm using libapache2-mod-wsgi-py3.
I have chown'ed the whole /root/myproject folder to 'www-data' and chmod'ed to 664 the sqlite.db file in accordance with DigitalOcean's tutorial.
The content of my /etc/apache2/sites-available/000-default.conf file is (comments deleted):
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /root/myproject
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static/ /root/myproject/static/
<Directory /root/myproject/static>
Require all granted
</Directory>
<Directory /root/myproject/myproject>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess myproject python-home=/root/myproject/myprojectenv python-path=/root/myproject
WSGIProcessGroup myproject
WSGIScriptAlias / /root/myproject/myproject/wsgi.py process-group=myproject
</VirtualHost>
The content of /root/myproject/myproject/settings.py is:
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = '[SOME STRING]'
DEBUG = True
ALLOWED_HOSTS = ['[IP Address as a string]']
...
The error I get by trying to access the page via browser:
Forbidden You don't have permission to access / on this server. Apache/2.4.29 (Ubuntu) Server at [IP ADDRESS] Port 80
The error log from /var/log/apache2/error.log
[Wed May 16 19:55:47.012027 2018] [wsgi:warn] [pid 3565:tid 140254930643904] (13)Permission denied: mod_wsgi (pid=3565): Unable to stat Python home /root/myproject/myprojectenv. Python interpreter may not be able to be initialized correctly. Verify the supplied path and access permissions for whole of the path.
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
The problem seems to be with apache being unable to run python.
Thanks in advance. Happy to add further information if needed.
Best regards
Saalim