Alex Lucaci Alex Lucaci - 7 months ago 97
Apache Configuration Question

Django wsgi Apache2: 'AH01630: client denied by server configuration'

I've followed this tutorial to deploy my django project :

Why the static files can't be loaded from apache?

I am using Debian9, Python3.5 and Django 1.11

This is my virtual host configuration:

<VirtualHost *:80>

ServerAdmin [email protected]
DocumentRoot /var/www/html

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

Alias /static /home/alex/djangoproject/static
<Directory /home/alex/djangoproject/static>
Require all granted

<Directory /home/alex/djangoproject/cpanel>
Require all granted

WSGIDaemonProcess djangoproject python-home=/home/alex/djangoproject/djangoprojectenv python-path=/home/alex/djangoproject
WSGIProcessGroup djangoproject
WSGIScriptAlias / /home/alex/djangoproject/cpanel/



And the apache error from error.log:

AH01630: client denied by server configuration /home/alex/djangoproject/static

And my config related to static foder

STATIC_URL = '/static/'
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')

Answer Source

Solved this by adding the django project name directory before static so this :

Alias /static /home/alex/djangoproject/static
<Directory /home/alex/djangoproject/static>
    Require all granted

Will become this:

Alias /static /home/alex/djangoproject/"django-project-name(in mycase: cpanel)"/static
<Directory /home/alex/djangoproject/"django-project-name(in mycase: cpanel)"/static>
    Require all granted

Performed ./ collectstatic , restart apache and all running smoothly.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download