请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

uwsgi -i uwsgi.ini &执行之后不知如何排查问题

nginx的配置

//按照教程的貌似不行
root@iZwz90hw6w4rniwnlsoxrhZ:/data/MxShop/conf/nginx# sudo /usr/sbin/nginx
sudo: unable to resolve host iZwz90hw6w4rniwnlsoxrhZ
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
//在网上找到另外一种启动方式
root@iZwz90hw6w4rniwnlsoxrhZ:/data/MxShop/conf/nginx# sudo /etc/init.d/nginx start
sudo: unable to resolve host iZwz90hw6w4rniwnlsoxrhZ
[ ok ] Starting nginx (via systemctl): nginx.service.


这是uwsgi -i uwsgi.ini &执行之后的/tmp/mylog.log

https://img1.sycdn.imooc.com//szimg/5a016b4c000154a612361108.jpg

# mysite_uwsgi.ini file
    [uwsgi]
    # Django-related settings
    # the base directory (full path)
    chdir           = /data/MxShop
    # Django's wsgi file
    module          = MxShop.wsgi:application
    # the virtualenv (full path)
    # 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:8000
    # ... with appropriate permissions - may be needed
    # chmod-socket    = 664
    # clear environment on exit
    vacuum          = true
    # virtualenv = /home/bobby/.virtualenvs/mxonline
    logto = /tmp/mylog.log

然后启动之后我还是没法访问我的东西,nginx的欢迎页面还是可以看得到,还有我是没用virtualenv,直接在服务器(ubuntu16.04)跑的。

这是我uc_nginx.conf文件内容
# the upstream component nginx needs to connect to
upstream django {
# server unix:///path/to/your/mysite/mysite.sock; # for a file socket
server 127.0.0.1:8000; # 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 XXX.XX.XX.XX; # 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 /data/MxShop/media;  # 指向django的media目录
}
location /static {
    alias /data/MxShop/static; # 指向django的static目录
}
# Finally, send all non-media requests to the Django server.
location / {
    uwsgi_pass  django;
    include     /data/MxShop/MxShop/wsgi.py; # the uwsgi_params file you installed
}
}


正在回答

1回答

这里有两个问题你需要注意 , 第一幅图中可以看出来 你的80端口已经占用了 你是否配置过apache占用了80端口 或者你是否已经通过其他方式启动了nginx导致现在启动不了nginx, 第二你的nginx的配置文件看起来没有问题 uwsgi启动也是正常的, 你是否通过域名方式访问了? server_name 120.78.95.99; 这句话表明只能通过ip访问才能访问

0 回复 有任何疑惑可以回复我~
  • 提问者 余泽锋 #1
    确实是80端口被占用了,很奇葩的,我谷歌了一下,发现有人说nginx先监听了ipv4的80端口之后又监听了ipv6的80端口,于是就重复占用了。
    sudo vim /etc/nginx/sites-available/default
    改
    listen 80;
    listen [::]:80 default_server;
    为
    listen 80;
    listen [::]:80 ipv6only=on default_server;
    还有点其他问题,不过最后还是可以了,谢谢老师
    回复 有任何疑惑可以回复我~ 2017-11-10 23:41:26
  • 提问者 余泽锋 #2
    非常感谢!
    回复 有任何疑惑可以回复我~ 2017-11-11 07:58:54
  • bobby 回复 提问者 余泽锋 #3
    好的,
    回复 有任何疑惑可以回复我~ 2017-11-13 09:39:52

相似问题

登录后可查看更多问答,登录/注册

问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信