django - nginx+uwsgi启动提示unknown directive "location /"(新手)
迷茫
迷茫 2017-04-24 09:09:45
0
1
1193

p.s: 环境是ubuntu16.04,项目的目录是/home/alps/mysite

# uwsgi启动正常
uwsgi -i uwsgi.ini

/home/alps/mysite/uwsgi.ini配置文件如下

[uwsgi]
socket = 127.0.0.1:8001
chdir=/home/alps/mysite/
wsgi-file = mysite/wsgi.py

processes = 2
threads = 4

chmod-socket = 664

/etc/nginx/sites-enabled/mysite.conf的配置文件如下

server{
    location / {
        listen 80;
        uwsgi_pass 127.0.0.1:8001 
        include     /etc/nginx/uwsgi_params;
    }
}

下面是报错信息

$ sudo service nginx configtest
 * Testing nginx configuration    [fail] 

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

$ systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2016-09-29 19:52:25 CST; 11s ago
  Process: 3450 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

Starting A high performance web server and a reverse proxy server...
nginx: [emerg] unknown directive "location /" in /etc/nginx/sites-enabled/mysite.conf:2
nginx: configuration file /etc/nginx/nginx.conf test failed
nginx.service: Control process exited, code=exited status=1
Failed to start A high performance web server and a reverse proxy server.
nginx.service: Unit entered failed state.
nginx.service: Failed with result 'exit-code'.

请问"location /"为什么是unknown directive呢?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

全員に返信(1)
伊谢尔伦

問題がはっきりとわかります

リーリー

あなたの設定は nginx 独自の設定検証にも合格しません。これは、nginx 設定に問題があることを意味します。
その後、設定に含まれていることがわかりました

リーリー

報告されたエラーの原因は nginx 設定/etc/nginx/sites-enabled/mysite.conf であることは間違いありません。転送設定を急いで使用しないでください。起動に問題がありますが、スーパーバイザーとはまったく関係ありません。
このアイデアに従うことをお勧めします

まず、設定を正しく変更します。nginx conf が unix:///tmp/mysite.sock を転送するように設定されていることがわかります。uwsgi 設定では、特定のポートをリッスンするソケットが指定されていません。これを設定すると、uwsgi のソケット パラメータは特定のポートをリッスンします。たとえば

リーリー

次に、nginx の転送 uwsgi_pass unix:///tmp/mysite.sock; を

uwsgi_pass 127.0.0.1:8001
に変更します。

次に、uwsgi -i uwsgi.ini に移動して、転送できるかどうかを確認します

これが成功すると、現在報告しているエラーは解決されるはずです。後ろを見てください

いいねを押す +0
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!