2017-04-19 8 views
0

私はちょうどnginxをダウンロードします。それから私は、nginxののディレクトリに移動し、以下のように三つのコマンドを一つずつ実行します。
nginx cモジュールこんにちは世界は動作しません

./configure 
make 
make install 

その後、私はhttp://localhostを訪問することができ、すべてが正常になります。

今、私はcモジュールを追加しようとしています。ここにはhello world exampleがあります。 、その後

worker_processes 1; 
events { 
    worker_connections 1024; 
} 
http { 
    include  mime.types; 
    default_type application/octet-stream; 
    sendfile  on; 
    keepalive_timeout 65; 
    server { 
     listen  80; 
     server_name localhost; 
     location/{ 
      root html; 
      index index.html index.htm; 
     } 
     ############ this is what I add 
     location /test { 
      hello_world; 
     } 
     ############ done 
     error_page 500 502 503 504 /50x.html; 
     location = /50x.html { 
      root html; 
     } 
    } 
} 

私は./configure --add-module=/path/to/nginx-hello-world-modulemakeの操作を行います。私は何をやったか

は、以下のようにGitHubのから例をダウンロードし、nginxの(/pathOfNginx/conf/nginx.conf)の設定ファイルを編集することです。すべてが良いように見えます。
次に、サーバーをリロードします。nginx -s reload

しかし、私は正しい回答を得ることができません。つまり、私がcurl -i http://localhost/testを実行すると、hello world文字列ではなく、404 Not Foundという結果になります。

答えて

0

それは私のために働く!

あなたは./configureを実行して二回目は、あなたが(それはそれを更新し、設定をしませ交換しています)、再びすべてのオプションを与える必要があることを忘れないでください... hello world\0を含むファイルを提供します。

また、make installでこれを実行する必要があります。そうしないと、インストールされているバイナリは更新されません。

# get everything 
wget http://nginx.org/download/nginx-1.12.0.tar.gz 
tar -xvf nginx-1.12.0.tar.gz 
git clone https://github.com/perusio/nginx-hello-world-module 

# configure 
(
    cd nginx-1.12.0 
    ./configure --prefix=../nginx --add-module=../nginx-hello-world-module/ 
) 

# build & install 
make -C ./nginx-1.12.0 -j8 
make -C ./nginx-1.12.0 install 

# update config 
cat <<EOF >./nginx/conf/nginx.conf 
worker_processes 1; 
events { 
    worker_connections 1024; 
} 
http { 
    include  mime.types; 
    default_type application/octet-stream; 
    sendfile  on; 
    keepalive_timeout 65; 
    server { 
     listen  80; 
     server_name localhost; 
     location/{ 
      root html; 
      index index.html index.htm; 
     } 
     ############ this is what I add 
     location /test { 
      hello_world; 
     } 
     ############ done 
     error_page 500 502 503 504 /50x.html; 
     location = /50x.html { 
      root html; 
     } 
    } 
} 
EOF 

# run 
(
    cd nginx 
    ./sbin/nginx 
) 

# test 
curl http://localhost:80/test 
+0

私は理由見つけたと思う:私は 'pathOfNginx/nginxの/ confに/ nginx.conf'再編集するとき、'は/ usr/local/nginxの/ conf'を更新することはできません。私はこの問題のために何をすべきか分かりません。今のところ、私ができることは 'rm -rf/usr/local/nginx'で、nginx全体を再構成してリメイクします。 – Yves

+0

@Yuhuiイベントオーダーについては、私の更新を参照してください。 – Attie

関連する問題