Mac OS X 10.9.3にインストール構成nginx-1.7.2
2014-06-27 wcdj
まずは公式のwikiから.http://wiki.nginx.org/GettingStartedを選択して、nginxコンパイルオプションを構成する各意味について説明します../configure--helpは、特定のコンパイルオプションの使用説明を表示し、簡単なインストールスクリプトを書きます.
Nginx modules must be selected during compile, run-time selection of modules is not currently supported.
A full summary of the compile-time options, including optional modules, can be found in the provided configure script by running
指定した構成およびインストールオプションの結果は次のとおりです.
インストール後のディレクトリ構造:
インストールされたnginxバージョン情報とコンパイルオプションを表示します.
その後nginxサービスを実行し、browserでテストします.
テスト後、nginxレコードのリクエストログが表示されます.
次はaccessです.logの内容:127.0.0.1 - - [27/Jun/2014:16:08:09 +0800] "GET/index HTTP/1.1"404 168 "-""Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0"127.0.0.1 - - [27/Jun/2014:16:08:10 +0800] "GET/favicon.ico HTTP/1.1"404 168 "-""Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0"127.0.0.1 - - [27/Jun/2014:16:08:10 +0800] "GET/favicon.ico HTTP/1.1"404 168 "-""Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0"127.0.0.1 - - [27/Jun/2014:16:08:44 +0800] "GET/index.html HTTP/1.1"200 612 "-""Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0"
nginxの起動オプションについて:
http://wiki.nginx.org/NginxCommandLine
その後のオプション操作:(1)nginxのvimプラグインcp-r/Users/gerryyang/Lamp/nginx/nginx-1.7を構成する.2/contrib/vim/* ~/.vim修正後の効果:
次に、インストール後のデフォルトのnginx実行構成を示します.
nginxの起動と停止、いくつかの信号オプションは参照できますhttp://wiki.nginx.org/NginxCommandLine
The master process can handle the following signals:
TERM, INT
Quick shutdown
QUIT
Graceful shutdown
KILL
Halts a stubborn process
HUP
Configuration reload Start the new worker processes with a new configuration Gracefully shutdown the old worker processes
USR1
Reopen the log files
USR2
Upgrade Executable on the fly
WINCH
Gracefully shutdown the worker processes
There's no need to control the worker processes yourself. However, they support some signals, too:
TERM, INT
Quick shutdown
QUIT
Graceful shutdown
USR1
Reopen the log files
リファレンス
[1] https://github.com/nginx/nginx[2] http://nginx.org/download/[3] http://lenky.info/ngx_book[4] http://book.51cto.com/art/201305/395368.htm[5] https://github.com/taobao/nginx-book
まずは公式のwikiから.http://wiki.nginx.org/GettingStartedを選択して、nginxコンパイルオプションを構成する各意味について説明します../configure--helpは、特定のコンパイルオプションの使用説明を表示し、簡単なインストールスクリプトを書きます.
Nginx modules must be selected during compile, run-time selection of modules is not currently supported.
A full summary of the compile-time options, including optional modules, can be found in the provided configure script by running
./configure --help
#!/bin/bash
echo "begin to install nginx-1.7.2"
echo "configure..."
./configure --prefix=/Users/gerryyang/LAMP/nginx/install/nginx-1.7.2 \
--with-debug \
--with-pcre=/Users/gerryyang/LAMP/pcre/pcre-8.35 \
--with-openssl=/Users/gerryyang/LAMP/OpenSSL/openssl-1.0.1g
echo "make and make install..."
make && make install
指定した構成およびインストールオプションの結果は次のとおりです.
Configuration summary
+ using PCRE library: /Users/gerryyang/LAMP/pcre/pcre-8.35
+ using OpenSSL library: /Users/gerryyang/LAMP/OpenSSL/openssl-1.0.1g
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/Users/gerryyang/LAMP/nginx/install/nginx-1.7.2"
nginx binary file: "/Users/gerryyang/LAMP/nginx/install/nginx-1.7.2/sbin/nginx"
nginx configuration prefix: "/Users/gerryyang/LAMP/nginx/install/nginx-1.7.2/conf"
nginx configuration file: "/Users/gerryyang/LAMP/nginx/install/nginx-1.7.2/conf/nginx.conf"
nginx pid file: "/Users/gerryyang/LAMP/nginx/install/nginx-1.7.2/logs/nginx.pid"
nginx error log file: "/Users/gerryyang/LAMP/nginx/install/nginx-1.7.2/logs/error.log"
nginx http access log file: "/Users/gerryyang/LAMP/nginx/install/nginx-1.7.2/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: “scgi_temp"
インストール後のディレクトリ構造:
インストールされたnginxバージョン情報とコンパイルオプションを表示します.
root@mba:sbin#./nginx -v
nginx version: nginx/1.7.2
root@mba:sbin#./nginx -V
nginx version: nginx/1.7.2
built by clang 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
configure arguments: --prefix=/Users/gerryyang/LAMP/nginx/install/nginx-1.7.2 --with-debug --with-pcre=/Users/gerryyang/LAMP/pcre/pcre-8.35 --with-openssl=/Users/gerryyang/LAMP/OpenSSL/openssl-1.0.1g
その後nginxサービスを実行し、browserでテストします.
テスト後、nginxレコードのリクエストログが表示されます.
次はaccessです.logの内容:127.0.0.1 - - [27/Jun/2014:16:08:09 +0800] "GET/index HTTP/1.1"404 168 "-""Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0"127.0.0.1 - - [27/Jun/2014:16:08:10 +0800] "GET/favicon.ico HTTP/1.1"404 168 "-""Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0"127.0.0.1 - - [27/Jun/2014:16:08:10 +0800] "GET/favicon.ico HTTP/1.1"404 168 "-""Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0"127.0.0.1 - - [27/Jun/2014:16:08:44 +0800] "GET/index.html HTTP/1.1"200 612 "-""Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0"
nginxの起動オプションについて:
http://wiki.nginx.org/NginxCommandLine
その後のオプション操作:(1)nginxのvimプラグインcp-r/Users/gerryyang/Lamp/nginx/nginx-1.7を構成する.2/contrib/vim/* ~/.vim修正後の効果:
次に、インストール後のデフォルトのnginx実行構成を示します.
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
nginxの起動と停止、いくつかの信号オプションは参照できますhttp://wiki.nginx.org/NginxCommandLine
root@mba:sbin#./nginx
root@mba:sbin#ps aux|grep nginx
root 703 0.0 0.0 2432784 620 s000 S+ 9:54 0:00.00 grep nginx
nobody 701 0.0 0.0 2452336 892 ?? S 9:54 0:00.00 nginx: worker process
root 700 0.0 0.0 2442908 344 ?? Ss 9:54 0:00.00 nginx: master process ./nginx
root@mba:sbin#./nginx -s stop
root@mba:sbin#ps aux|grep nginx
root 706 0.0 0.0 2442000 636 s000 S+ 9:54 0:00.00 grep nginx
root@mba:sbin#./nginx
root@mba:sbin#ps aux|grep nginx
root 714 0.7 0.0 2442000 632 s000 S+ 9:56 0:00.00 grep nginx
nobody 712 0.0 0.0 2452336 896 ?? S 9:56 0:00.00 nginx: worker process
root 711 0.0 0.0 2443932 348 ?? Ss 9:56 0:00.00 nginx: master process ./nginx
root@mba:sbin#./nginx -s stop
root@mba:sbin#ps aux|grep nginx
root 717 0.0 0.0 2432784 612 s000 S+ 9:56 0:00.00 grep nginx
root@mba:sbin#./nginx
root@mba:sbin#ps aux|grep nginx
root 722 0.0 0.0 2432784 612 s000 S+ 9:56 0:00.00 grep nginx
nobody 720 0.0 0.0 2444144 908 ?? S 9:56 0:00.00 nginx: worker process
root 719 0.0 0.0 2443932 348 ?? Ss 9:56 0:00.00 nginx: master process ./nginx
root@mba:sbin#kill -QUIT $(cat ../logs/nginx.pid)
root@mba:sbin#ps aux|grep nginx
root 725 0.0 0.0 2432784 612 s000 S+ 9:57 0:00.00 grep nginx
root@mba:sbin#
The master process can handle the following signals:
TERM, INT
Quick shutdown
QUIT
Graceful shutdown
KILL
Halts a stubborn process
HUP
Configuration reload Start the new worker processes with a new configuration Gracefully shutdown the old worker processes
USR1
Reopen the log files
USR2
Upgrade Executable on the fly
WINCH
Gracefully shutdown the worker processes
There's no need to control the worker processes yourself. However, they support some signals, too:
TERM, INT
Quick shutdown
QUIT
Graceful shutdown
USR1
Reopen the log files
リファレンス
[1] https://github.com/nginx/nginx[2] http://nginx.org/download/[3] http://lenky.info/ngx_book[4] http://book.51cto.com/art/201305/395368.htm[5] https://github.com/taobao/nginx-book