Due to various reasons, I reinstalled the server and rebuilt it, but I cannot load the static file of Django.
<About the Environment>
·GMO Cloud VPS
·CentOS 8
·nginx
·Django 2.2
·python 3.6
·Virtual environment venv
<settings.py>
STATIC_URL='/static/'
STATIC_ROOT='/home/[User]/Django/[file]/[project name]/[app name]/static/'
<nginx.conf>
location/static {
root/home/[User]/Django/[file]/[project name]/[app name]/static;
}
<Tree>
.
├-- Project Name
│ -- --_init__.py
│ -- --__pycache__
│ -- __ --_init__.cpython-36.pyc
│ │ set --settings.cpython-36.pyc
│ │ -- -- urls.cpython-36.pyc
│ w --wsgi.cpython-36.pyc
│ -- -- settings.py
│ -- -- urls.py
│ -- -- wsgi.py
├-- App Name
│ -- --_init__.py
│ -- --__pycache__
│ -- -- admin.py
│ -- -- apps.py
│ -- --media
│ -- --migrations
│ -- -- models.py
│ -- -- static
│ │ c -- css
│ i --images
│ -- --templates
│ -- -- tests.py
│ -- -- urls.py
│ -- -- views.py
└-- └── manage.py
Before the reinstallation, it was loaded without any problems, but after the reconfiguration, it was not loaded at all.
Please let me know if you need any information.
I tried many things and it was solved.
Resolve permission issues
After reviewing the nginx error log, I noticed that there was a "13: Permission denied" and tried to review the permissions, and it was resolved.
Granted execution privileges to all root directories.
sudo chmod+x/home
sudo chmod+x/home/[User]
sudo chmod+x/home/[User]/Django
sudo chmod+x/home/[User]/Django/[file]/[project name]
sudo chmod+x/home/[User]/Django/[file]/[project name]/[app name]
The static file is now loaded successfully.
Once again, I would like to thank everyone for their efforts to solve this problem.
When I think about it, it was a rudimentary mistake.
From now on, we will continue to develop while looking closely at the error log.
Sorry for the trouble.
© 2024 OneMinuteCode. All rights reserved.