'Django production with Apache in Ubuntu not show image
I want to config my django project in Ubuntu server which use Apache but it not show image. I edit file settings.py like this.
settings.py
DEBUG = False
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_URL='/media/'
MEDIA_ROOT=os.path.join(BASE_DIR,'static','media')
I show image in html file like this.
index.html
{% load static %}
{% block content %}
<img src="{% static '/media/images/logo.png' %}">
{% endblock %}
I set apache file in path /etc/apache2/sites-available/000-default.conf like this.
<VirtualHost *:80>
ServerName myweb.com
DocumentRoot /home/user/myproject_dir/myproject
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /home/user/myproject_dir/myproject/static
<Directory /home/user/myproject_dir/myproject/static>
Require all granted
</Directory>
<Directory /home/user/myproject_dir/myproject/myproject>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess myproject_dir python-path=/home/user/myproject_dir/myproject python-home=/home/user/myproject_dir/myproject_env
WSGIProcessGroup myproject_dir
WSGIScriptAlias / /home/user/myproject_dir/myproject/myproject/wsgi.py
</VirtualHost>
I upload image to path like this.
/home/user/myproject_dir/myproject/static/media/images/logo.png
I use command collectstatic and restart apache service but it not show image in my website. How to fix it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
