[Answered ]-Can't load statics, Django rest_framework on Apache, Windows

1👍

So, i had to add extra alias in virtualhost settings, and athe moment it’s kinda works:

<VirtualHost 127.0.0.1:8081>
    ##ServerAdmin webmaster@dummy-host.example.com
    WSGIScriptAlias / "D:/genesi5/Coding/www/django/wsgi_handler.wsgi"
    DocumentRoot "D:/genesi5/Coding/www/django"
    ServerName DjangoApp
    ServerAlias DjangoApp
    ErrorLog "logs/myapp/error.log"
    CustomLog "logs/myapp/access.log" common
    Alias /static "C:/Users/Genesi5/AppData/Local/Programs/Python/Python36-32/Lib/site-packages/rest_framework/static"
    <Directory "C:/Users/Genesi5/AppData/Local/Programs/Python/Python36-32/Lib/site-packages/rest_framework/static">
        Require all Granted
    </Directory>
    <Directory "D:/genesi5/Coding/www/django">
        AllowOverride All
        Require all Granted
    </Directory>
</VirtualHost>

1👍

You have to declare lots of things in Apache2.conf in order to use mod_wsgi

WSGIScriptAlias / /path_to_wsgi.py
WSGIPythonPath /path_to_your_project
Alias /static/ /path_to_your_static_directory

<Directory /path_to_your_static_directory>
        Require all granted
</Directory>

<Directory /path_to_your_project_directory>
        <Files wsgi.py>
                #Options Indexes FollowSymLinks
                #Require all granted
                #SetEnvIfNoCase Host .+ VALID_HOST
                Order deny,allow
                Allow from all
                #Allow from env=VALID_HOST
        </Files>
</Directory>

<Directory />
       Options FollowSymLinks
       AllowOverride None
       Require all denied
</Directory>

<Directory /usr/share>
       AllowOverride None
       Require all granted
</Directory>

<Directory /var/www/>
       Options Indexes FollowSymLinks
       AllowOverride None
       Require all granted
</Directory>

<Directory /srv/>
       Options Indexes FollowSymLinks
       AllowOverride None
       Require all granted
</Directory>

It’s an example with Linux, but it’s the same thing with Windows 😉

👤Essex

Leave a comment