Hi,
I have hosted my website according to your website guidance. And my website is working after hosting but when I try to access my media directory, I get this [Errno 13] Permission denied: /var/www/mysite2/media/
I have Built my website using Django framework python with apache server and mysql database. Actually I have hosted two websites on a single droplet. And my first website working properly, and this is my second website which causes this type of error.
So please help me.
This is my site.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request’s Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
#DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
Alias /static /var/www/mysite/staticfiles
<Directory /var/www/mysite/staticfiles>
Require all granted
</Directory>
<Directory /var/www/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess djangohost2 python-path=/var/www/mysite python-home=/var/www/mysite/djangohost2
WSGIProcessGroup djangohost2
WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
vim: syntax=apache ts=4 sw=4 sts=4 sr noet
And this permissions on /var/www/
drwxr-xr-x 13 root root 4096 Sep 19 13:05 mysite2
drwxr-xr-x 8 root root 4096 Sep 14 10:20 mysite1
drwxr-xr-x 2 root root 4096 Sep 14 08:58 html
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Hi there @akshaykoshti401,
I would recommend starting with checking your Nginx error log:
- sudo tail -100 /var/log/nginx/error.log
It is possible that the Nginx user does not have read permissions for the /var/www/mysite/staticfiles
folder and the files inside.
I could suggest changing the ownership of that folder and the files inside it to the Nginx user.
You can do that with the following command:
- chown -R www-data: /var/www/mysite/staticfiles
Note that you might have to change the www-data
with your actual Nginx user in case that you changed it.
Regards, Bobby
If it doesn’t work for ‘www-data’ user, try changing permission to ‘django’ user instead.
sudo chown -R your_username:your_group /var/www/mysite2/media/
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.