私はちょうど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-module
とmake
の操作を行います。私は何をやったか
は、以下のようにGitHubのから例をダウンロードし、nginxの(/pathOfNginx/conf/nginx.conf
)の設定ファイルを編集することです。すべてが良いように見えます。
次に、サーバーをリロードします。nginx -s reload
しかし、私は正しい回答を得ることができません。つまり、私がcurl -i http://localhost/test
を実行すると、hello world文字列ではなく、404 Not Foundという結果になります。
私は理由見つけたと思う:私は 'pathOfNginx/nginxの/ confに/ nginx.conf'再編集するとき、'は/ usr/local/nginxの/ conf'を更新することはできません。私はこの問題のために何をすべきか分かりません。今のところ、私ができることは 'rm -rf/usr/local/nginx'で、nginx全体を再構成してリメイクします。 – Yves
@Yuhuiイベントオーダーについては、私の更新を参照してください。 – Attie