登录  /  注册
nginx+uwsgi部署django,8000端口正常,80端口404
高洛峰
高洛峰 2016-11-14 11:19:52
[Django讨论组]

按照教程用nginx+uwsgi部署django项目,监听8000端口正常,80端口访问时显示404 not found.
django项目目录为/home/wu/Documents/env/myblog
项目文件夹下文档结构

bVD4qj.png

myblog_nginx.conf文件

# 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文件

# 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文件中改为8000端口时没问题

bVD4qj.png

改为80端口后,raload,restart nginx,uwsgi --ini mysite_uwsgi.ini,然后访问

bVD4qj.png

求指点,搞了好久都没解决这个问题,感激不尽!!!

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号