ubuntu16.04 - nginx+uwsgi部署django,8000端口正常,80端口404
問(wèn)題描述
按照教程用nginx+uwsgi部署django項(xiàng)目,監(jiān)聽(tīng)8000端口正常,80端口訪問(wèn)時(shí)顯示404 not found.django項(xiàng)目目錄為/home/wu/Documents/env/myblog項(xiàng)目文件夾下文檔結(jié)構(gòu)
myblog_nginx.conf文件
# mysite_nginx.conf# the upstream component nginx needs to connect toupstream 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 serverserver { # 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文件
# mysite_uwsgi.ini file[uwsgi]# Django-related settings# the base directory (full path)chdir = /home/wu/Documents/env/myblog# Django’s wsgi filemodule = myblog.wsgi# the virtualenv (full path)home = /home/wu/Documents/env# process-related settings# mastermaster = true# maximum number of worker processesprocesses = 10# the socket (use the full path to be safesocket = /home/wu/Documents/env/myblog/mysite.sock# ... with appropriate permissions - may be neededchmod-socket = 666# clear environment on exitvacuum = true
myblog_nginx.conf文件中改為8000端口時(shí)沒(méi)問(wèn)題
改為80端口后,raload,restart nginx,uwsgi --ini mysite_uwsgi.ini,然后訪問(wèn)
端口狀態(tài):
求指點(diǎn),搞了好久都沒(méi)解決這個(gè)問(wèn)題,感激不盡!!!
問(wèn)題解答
回答1:請(qǐng)問(wèn)你的問(wèn)題解決了嗎?
回答2:請(qǐng)問(wèn)兄臺(tái)如何部署,,寫(xiě)個(gè)教程吧。。
回答3:8000 端口顯示的那個(gè)頁(yè)面是 Django 自帶的測(cè)試頁(yè),在 80 端口部署的時(shí)候應(yīng)該不會(huì)出現(xiàn),建議你自己寫(xiě)個(gè)頁(yè)面部署到 80 端口試試
回答4:是不是你其他地方配置了
server { listen 80; xxx}#導(dǎo)致沒(méi)進(jìn)入你的server塊,看下nginx.conf,或者其他虛擬主機(jī)的配置文件。另外你的server { /*這個(gè)去掉吧,或者你可以測(cè)試重復(fù),host配置一個(gè)xxx.com, 這邊也配置為xxx.com,相比于listen 80,會(huì)優(yōu)先進(jìn)入這個(gè)server塊。*/ #server_name .example.com;}回答5:
nginx里面的location配置,include uwsgi_params;后面你沒(méi)有uwsgi_pass 127.0.0.1:8000;
相關(guān)文章:
