2017-12-06 6 views
0

나는 NGINX + GUNICORN + DJANGO를 사용하며 내 gunicorn 상태가 활성화되었습니다. django와 nginx를 설정하고 싶습니다. 나는에 'mysite'라는 이름의 새 파일을 생성 nginx 및 django 구성에 문제가 있습니까?

server { 
     listen 8000 default_server; 
     listen [::]:8000 default_server; 
     server_name my_ip; 
     location = /favicon.ico { access_log off; log_not_found off; } 
     location /static/ { 
      root /home/split/mysite; 
     } 
     location/{ 
      include proxy_params; 
      proxy_pass http://unix:/home/split/mysite/mysite.sock; 
     } 
} 

/etc/nginx/sites-available 그것을 저장하고 내가 sudo service nginx restart했다 그 후 /etc/nginx/sites-enabled 에 symbolyc 링크를 만들고이있어 :

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. 

내가 journalctl -xe

-- 
-- Unit nginx.service has finished shutting down. 
Dec 07 01:05:17 ubuntu systemd[1]: Starting A high performance web server and a reverse proxy server... 
-- Subject: Unit nginx.service has begun start-up 
-- Defined-By: systemd 
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel 
-- 
-- Unit nginx.service has begun starting up. 
Dec 07 01:05:17 ubuntu nginx[49646]: nginx: [crit] pread() "/etc/nginx/sites-enabled/sites-available" failed (21: Is a directory) 
Dec 07 01:05:17 ubuntu nginx[49646]: nginx: configuration file /etc/nginx/nginx.conf test failed 
Dec 07 01:05:17 ubuntu systemd[1]: nginx.service: Control process exited, code=exited status=1 
Dec 07 01:05:17 ubuntu sudo[49639]: pam_unix(sudo:session): session closed for user root 
Dec 07 01:05:17 ubuntu systemd[1]: FAILED TO START A HIGH PERFORMANCE WEB SERVER AND A REVERSE PROXY SERVER. 
-- Subject: Unit nginx.service has failed 
-- Defined-By: systemd 
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel 
-- 
-- Unit nginx.service has failed. 
-- 
-- The result is failed. 
Dec 07 01:05:17 ubuntu systemd[1]: nginx.service: Unit entered failed state. 
Dec 07 01:05:17 ubuntu systemd[1]: nginx.service: Failed with result 'exit-code'. 
Dec 07 01:05:42 ubuntu kernel: [UFW BLOCK] IN=eth0 OUT= MAC=02:1e:6d:00:e4:9f:00:01:e8:11:73:69:08:00 SRC=193.124.0.226 DST=194.87.95.46 LEN=48 TOS=0 
Dec 07 01:05:57 ubuntu kernel: [UFW BLOCK] IN=eth0 OUT= MAC=02:1e:6d:00:e4:9f:00:01:e8:11:73:69:08:00 SRC=193.124.0.226 DST=194.87.95.46 LEN=52 TOS=0 
Dec 07 01:06:16 ubuntu kernel: [UFW BLOCK] IN=eth0 OUT= MAC=01:00:5e:00:00:01:00:21:d7:56:a5:80:08:00 SRC=93.95.100.9 DST=224.0.0.1 LEN=32 TOS=0x00 P 
Dec 07 01:06:21 ubuntu sudo[49655]: split : TTY=pts/0 ; PWD=/etc/nginx ; USER=root ; COMMAND=/bin/journalctl -xe 
Dec 07 01:06:21 ubuntu sudo[49655]: pam_unix(sudo:session): session opened for user root by split(uid=0) 
Dec 07 01:06:39 ubuntu kernel: [UFW BLOCK] IN=eth0 OUT= MAC=02:1e:6d:00:e4:9f:00:01:e8:11:73:69:08:00 SRC=193.124.0.226 DST=194.87.95.46 LEN=52 TOS=0 
Dec 07 01:07:16 ubuntu kernel: [UFW BLOCK] IN=eth0 OUT= MAC=01:00:5e:00:00:01:00:21:d7:56:a5:80:08:00 SRC=93.95.100.9 DST=224.0.0.1 LEN=32 TOS=0x00 P 
Dec 07 01:07:17 ubuntu kernel: [UFW BLOCK] IN=eth0 OUT= MAC=02:1e:6d:00:e4:9f:00:01:e8:11:73:69:08:00 SRC=185.207.206.224 DST=194.87.95.46 LEN=40 TOS 
Dec 07 01:07:46 ubuntu kernel: [UFW BLOCK] IN=eth0 OUT= MAC=02:1e:6d:00:e4:9f:00:01:e8:11:73:69:08:00 SRC=212.16.70.23 DST=194.87.95.46 LEN=40 TOS=0x 
Dec 07 01:08:03 ubuntu sudo[49662]: split : TTY=pts/0 ; PWD=/etc/nginx ; USER=root ; COMMAND=/bin/su 
Dec 07 01:08:03 ubuntu sudo[49662]: pam_unix(sudo:session): session opened for user root by split(uid=0) 
Dec 07 01:08:03 ubuntu su[49663]: Successful su for root by root 
Dec 07 01:08:03 ubuntu su[49663]: + /dev/pts/0 root:root 
Dec 07 01:08:03 ubuntu su[49663]: pam_unix(su:session): session opened for user root by split(uid=0) 
에 갔다를
+0

에 주소를 한 가지 더 변화 소켓 권한을 변경 -lah/etc/nginx/sites-enabled "로 설정하십시오. 파일 허가 문제 나 symlink에 잘못 연결된 것이 있는지 궁금합니다. –

+0

먼저 drwxr-xr-x 2 root root 4.0K Dec 7 01:23. drwxr-xr-x 6 루트 루트 4.0K 12 월 6 일 04:10 .. -rw-r-r-- 1 루트 루트 1.0K Nov 29 00:30 .default.save.swp -rw-r- -r-- 1 루트 루트 1.0K 12 월 5 일 15:49 .default.swp -rw-r - r-- 1 루트 루트 1.0K 12 월 6 일 22:05 .myproject.swp -rw-r -r - 1 루트 루트 1.0K 12 월 7 일 01:23 .mysite.swp -rw-r - r-- 1 루트 루트 1.0K 12 월 7 일 00:47 .suga.swp -rw-r - r-- 1 루트 루트 405 12 월 15 일 15시 49 분 기본값 -rw-r - r-- 1 루트 루트 406 12 월 7 일 01:23 mysite -rw-r - r-- 1 root root 490 12 월 6 일 04:06 suga – question1

+0

초 : drwxr-xr-x 2 루트 루트 4.0K 12 월 7 일 01:23. drwxr-xr-x 6 루트 루트 4.0K 12 월 6 일 04:10 .. -rw-r-r-- 1 루트 루트 1.0K Nov 29 00:28 .blog.swp -rw-r -r - 1 루트 루트 1.0K Nov 29 00:29 .default.swp lrwxrwxrwx 1 루트 루트 34 Dec 5 15:50 기본값 ->/etc/nginx/sites-available/default lrwxrwxrwx 1 루트 루트 33 12 월 7 01 : 23 mysite ->/etc/nginx/sites-available/mysite lrwxrwxrwx 1 루트 루트 12 월 6 일 04:11 suga ->/etc/nginx/sites-available/suga – question1

답변

0

이것은 사용 된 프로젝트의 초안입니다. uwsgi는 나와 함께 잘 작동했습니다. "1! -lah을/etc/nginx를/사이트-가능 /"뿐만 아니라 "LS : 당신이 다음 두 명령의 결과를 게시 할 수 664

# mysite_nginx.conf 

# the upstream component nginx needs to connect to 
upstream django { 
    server unix:///tmp/uwsgi.sock; 
    #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  8080; 
    # the domain name it will serve for 
    server_name 127.0.0.1; # 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/naqib/FINAL_WEB_03/NLLAYVM/media; # your Django project's media files 
    } 

    location /static { 
     alias /home/naqib/FINAL_WEB_03/NLLAYVM/app/static; # your Django project's static files 
    } 

    # Finally, send all non-media requests to the Django server. 
    location/{ 
     uwsgi_pass django; 
     include  /home/naqib/FINAL_WEB_03/NLLAYVM/uwsgi_params; # the uwsgi_params file you installed 
    } 
} 
+0

소켓 권한을 변경하는 방법은 무엇입니까? – question1

+0

이 유닉스 양말은 tmp/uwsgi.sock에서 uwsgi를 실행 한 후에 만들어진 파일입니다. –