二、nginxサーバー基礎配置コマンド
デフォルトのnginxサーバプロファイルはインストールディレクトリconfに格納、メインプロファイル名はnginxである.conf.
デフォルトnginx.confは/usr/local/nginxディレクトリの下にあり、前回のコンパイルインストールnginxプライマリプロファイルは/etc/nginxに保存されます.
インストールコンパイル:http://magine356wj.blog.51cto.com/2664956/1677064
次はnginxについてです.confのいくつかの注釈
一、core:
numberを3に変更してpsax|grep nginxを実行すると、メインプロセスmaster processを除いて3つのworker processが生成されていることがわかります.
二、eventsブロック
三、httpモジュール:
四、server,locationモジュール
注意:Httpモジュール、server、locationについては、最初の寸法のみです.仮想ホスト、rewriteなどの機能は、後続のブログに書かれます.
デフォルトnginx.confは/usr/local/nginxディレクトリの下にあり、前回のコンパイルインストールnginxプライマリプロファイルは/etc/nginxに保存されます.
インストールコンパイル:http://magine356wj.blog.51cto.com/2664956/1677064
次はnginxについてです.confのいくつかの注釈
##################### ##############################################
#user nobody; # , nobody, nginx
worker_processes 1; # , CPU nginx
#error_log logs/error.log; # [debug | info| notice| warn | error | crit ]
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid; # pid
################events ###########################################
events {
worker_connections 1024; worker
}
######################http ###########################################
http {# 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.conf , core( ),events ,http 。 http , http , server 。 server server location1. , 。
一、core:
events , Nginx 。 Nginx 。
user
: user user[group]
:nobody nobody
nginx worker , nobody
error_log
: error_log file [ debug | info | notice | warn | error | crit ]
: ${prefix}/logs/error.log
。
pid
: pid file
id 。 kill -HUP cat /var/log/nginx.pid/ Nginx 。
worker_processes
: worker_processes number
: 1
。nginx worker 。
numberを3に変更してpsax|grep nginxを実行すると、メインプロセスmaster processを除いて3つのworker processが生成されていることがわかります.
二、eventsブロック
events Nginx 。
use epoll; # , epoll, 。
worker_connections number; # worker process 。
clients = worker_connections * work_process, worker_connections。
三、httpモジュール:
http ,MIME-Type , , sendfile , , 。
include mime.types;
default_type application/octet-stream;
HTML,XML,GIF Flash , 。 MIME Type。default_type MIME 。
Nginx , , 。
access_log
log_format
:http://nginx.org/en/docs/http/ngx_http_log_module.html
sendfile on | off; sendfile
keepalive_timeout timeout, 65s。
gzip on gzip ,
四、server,locationモジュール
location [ = | ~ | ~* | ^~ ] uri { ... }
= , uri
~ , ,
~*, ,
^~,
:
=;
~;
/
注意:Httpモジュール、server、locationについては、最初の寸法のみです.仮想ホスト、rewriteなどの機能は、後続のブログに書かれます.