使用uwsgi启动ini的时候,mysite_uwsgi.ini中的socke是什么作用?

发布于 2022-09-06 10:48:10 字数 2562 浏览 25 评论 0

问题1:mysite_uwsgi.ini中配置的socket指向的mysite.sock文件会在uwsgi --ini mysite_uwsgi.ini时进行创建,但结束后就被remove了,所以怎么对这个sock进行配置?
问题2:mysite_uwsgi.ini这个mysite.sock文件跟mysite_nginx.conf里面upstream django下面的server的sock有什么区别么?都有什么作用?
问题3:我在访问url为:http://mysite-py.local:8000/media/media.png的时候具体访问路径为:/www/Code/python/mysite/mysite/media/media.png,但是访问http://mysite-py.local:8000的时候按理说应该转到Django中配置的/www/Code/python/mysite/mysite.sock中,不过显示Internal Server Error

刚入django坑,请各位大神耐心指教~多多包涵~

运行环境是:python3.6,nginx,uwsgi
下面是我的mysite_nginx.conf

# mysite_nginx.conf

# the upstream component nginx needs to connect to
upstream django {
   server unix://www/Code/python/mysite/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      8000;
    # the domain name it will serve for
    server_name mysite-py.local; # 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 /www/Code/python/mysite/mysite/media;  # your Django project's media files - amend as required
    }

    location /static {
        alias /www/Code/python/mysite/static; # your Django project's static files - amend as required
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /www/Code/python/mysite/config/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           = /www/Code/python/mysite
# Django's wsgi file
module          = mysite.wsgi
# the virtualenv (full path)
#home            = /path/to/virtualenv

# process-related settings
# master
master          = true
# maximum number of worker processes
processes       = 10
# the socket (use the full path to be safe
#socket          = 127.0.0.1:8001
socket = /www/Code/python/mysite/mysite.sock

# ... with appropriate permissions - may be needed
chmod-socket    = 666
# clear environment on exit
vacuum          = true
logto           = /www/Code/python/mysite/uwsgi.log
~                                                    

下面是我的hosts文件:

127.0.0.1    mysite-py.local

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文