Use nginx+uwsgi to deploy the django project according to the tutorial. Listening to port 8000 is normal. When accessing port 80, 404 not found is displayed.
The django project directory is /home/wu/Documents/env/myblog
Document structure under the project folder
myblog_nginx.conf
File
# mysite_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
server unix:///home/wu/Documents/env/myblog/mysite.sock; # for a file socket
#server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name .example.com; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /home/wu/Documents/env/myblog/media; # your Django project's media files - amend as required
}
location /static {
alias /home/wu/Documents/env/myblog/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
root /home/wu/Documents/env/myblog;
uwsgi_pass django;
include /home/wu/Documents/env/myblog/uwsgi_params; # the uwsgi_params file you installed
}
}
mysite_uwsgi.ini
File
# mysite_uwsgi.ini file
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /home/wu/Documents/env/myblog
# Django's wsgi file
module = myblog.wsgi
# the virtualenv (full path)
home = /home/wu/Documents/env
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 10
# the socket (use the full path to be safe
socket = /home/wu/Documents/env/myblog/mysite.sock
# ... with appropriate permissions - may be needed
chmod-socket = 666
# clear environment on exit
vacuum = true
myblog_nginx.conf
There is no problem when the file is changed to port 8000
After changing to port 80, raload, restart nginx, uwsgi --ini mysite_uwsgi.ini
, and then visit
Port status:
Please give me some advice, I haven’t solved this problem for a long time, I would be very grateful! ! !
Has your problem been solved?
Please tell me how to deploy it, please write a tutorial. .
The page displayed on port 8000 is the test page that comes with Django. It should not appear when deployed on port 80. It is recommended that you write a page yourself and deploy it to port 80 to try it
Did you configure it elsewhere
The location configuration in nginx includes uwsgi_params; you don’t have uwsgi_pass 127.0.0.1:8000;