I am working on deploying a Django project with apache2 and MOD_WSGI. When I run the server, I am unable to access the website and I get the error on the site,
Forbidden
You don't have permission to access this resource.
Apache/2.4.29 (Ubuntu) Server at testnexusstudy.com Port 8081
I have set up everything I think I need like the conf file,
<VirtualHost *:8081>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
#Include conf-available/serve-cgi-bin.conf
Alias /static /root/StudBud1/static
<Directory /root/StudBud1/static>
Require all granted
</Directory>
Alias /media /root/StudBud1/media
<Directory /root/StudBud1/media>
Require all granted
</Directory>
<Directory /root/StudBud1/StudBud1>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /root/StudBud1/StudBud1/wsgi.py
WSGIDaemonProcess StudBud1 python-path=/root/StudBud1
WSGIProcessGroup StudBud1
</VirtualHost>
I have given all the permissions I thought were required for apache and here is my ls -la
drwxrwxr-x 12 root www-data 4096 Apr 5 19:36 StudBud1
-rw-rw-r-- 1 root www-data 204800 Apr 5 19:36 db.sqlite3
Hopefully, some of you have experience with this type of error.
2
Answers
I wouldn’t use or give root access to your web server for security reasons.
I would create a user that only has access to the www-data group, make sure apache is also in that group.
Some of these commands come from the Fedora distro, so they may be a little different from Debian.
In /etc/group:
/location/to/vhosts/website.conf (extraneous settings removed for clarity)
Then restart apache
Once that is done, make sure to give your directories to the user and group www-data
as sudo (-R for recursive)
I’m a total beginner.
On a fresh install I had to set the permissions for the /var/www/html directory.
By default they were -rw——-
I typed sudo chmod 775 * and it fuctionned.