Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

413
Views
Django - Apache2 can't load media files from media folder

I installed an linux server with apache where I want to run my Django app. So I set everything up and when I started the app everything was shown to me except for the pictures. I couldn't find a error inside my site.conf

<VirtualHost *:80>
    ServerName MYHOST

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

    WSGIDaemonProcess mysite processes=2 threads=25 python-path=/var/www/mysite
    WSGIProcessGroup mysite
    WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py

    Alias /robots.txt /var/www/mysite/static/robots.txt
    Alias /favicon.ico /var/www/mysite/static/favicon.ico
    Alias /static/ /var/www/mysite/static/
    Alias /static/ /var/www/mysite/media/

    <Directory /var/www/mysite/mysite>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    <Directory /var/www/mysite/static>
        Require all granted
    </Directory>

    <Directory /var/www/mysite/media>
        Require all granted
    </Directory>
</VirtualHost>

or inside my settings.py

STATIC_URL = '/static/'
STATIC_ROOT = '/var/www/mysite/static'
MEDIA_ROOT = '/var/www/mysite/media'
MEDIA_URL = '/media/'

What I did was setting debug = True and inside linux console I run python3 manage.py collectstatic after reloading apache the website was shown with all its css and js but for every image request I get an error 404.

Inside my templates/base.html I call {% load static %}. I tried to replace it with {% load staticfiles from static %} but that crashed my entire app (err 500) I use Django version 3.x and apache2

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!