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
# 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 } }
Django REST framework课程视频,RESTFul API前后端分离开发
了解课程