Report this

What is the reason for this report?

[Errno 13] Permission denied: '/var/www/mysite2/media/' after deployment.

Posted on September 21, 2020

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.