我有一个 django 项目。Settings.py:STATIC_URL = 'static/'STATIC_ROOT = 'static'MEDIA_URL = '/media/'MEDIA_ROOT = BASE_DIR / 'media'我已经执行了 collectstatic 并且一切正常。现在...
我有一个 django 项目。
设置.py:
STATIC_URL = 'static/'
STATIC_ROOT = 'static'
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'
我已经完成了 collectstatic
,一切运行正常。现在我服务器上的静态文件夹包含所有文件。
Nginx的:
我在使用 nginx 时遇到了问题,因为我改了一个名字, sites_available
然后开始出现错误,所以我重新安装了它,现在从日志来看一切都正常:
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset:>
Active: active (running) since Wed 2024-05-01 14:47:13 UTC; 11min ago
Docs: man:nginx(8)
Process: 6843 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_proce>
Process: 6844 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (c>
Main PID: 6845 (nginx)
Tasks: 2 (limit: 1026)
Memory: 3.1M
CPU: 60ms
CGroup: /system.slice/nginx.service
6845 "nginx: master process /usr/sbin/nginx -g daemon on; master>
6846 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "">
May 01 14:47:13 23210 systemd[1]: nginx.service: Deactivated successfully.
May 01 14:47:13 23210 systemd[1]: Stopped A high performance web server and a r>
May 01 14:47:13 23210 systemd[1]: Starting A high performance web server and a >
May 01 14:47:13 23210 systemd[1]: Started A high performance web server and a r>
~
~
~
~
~
~
ESCOC
server and a reverse proxy server
/nginx.service; enabled; vendor preset: enabled)
2024-05-01 14:47:13 UTC; 11min ago
/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
inx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
ss /usr/sbin/nginx -g daemon on; master_process on;"
ss" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" >
service: Deactivated successfully.
d A high performance web server and a reverse proxy server.
ng A high performance web server and a reverse proxy server...
d A high performance web server and a reverse proxy server.
~
~
~
~
~
~
ESCOD
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset:>
Active: active (running) since Wed 2024-05-01 14:47:13 UTC; 11min ago
Docs: man:nginx(8)
Process: 6843 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_proce>
Process: 6844 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (c>
Main PID: 6845 (nginx)
Tasks: 2 (limit: 1026)
Memory: 3.1M
CPU: 60ms
CGroup: /system.slice/nginx.service
6845 "nginx: master process /usr/sbin/nginx -g daemon on; master>
6846 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "">
May 01 14:47:13 23210 systemd[1]: nginx.service: Deactivated successfully.
May 01 14:47:13 23210 systemd[1]: Stopped A high performance web server and a r>
May 01 14:47:13 23210 systemd[1]: Starting A high performance web server and a >
May 01 14:47:13 23210 systemd[1]: Started A high performance web server and a r>
~
~
~
~
~
~
lines 1-18/18 (END)
[2]+ Stopped systemctl status nginx
^Z
但我不知道为什么会出现错误。
Nginx 配置:
server {
listen 80;
server_name 77.777.77.77;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/ubuntu/portfolio-server;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}