一、Nginx配置文件详解
配置文件介绍
主要有两部分:分别是
main:主体部分
http{}:虚拟主机配置部分 配置指令主要以分号结尾;配置语法:directive value1 [value2 ....]
支持使用的变量
模块内置的变量
自定义变量:set var_name value 主配置段的指令类别:
用于调试和定位问题:
(1)daemon [on|off]: 是否以守护进程的方式启动nginx;
(2)master_press [on|off]: 是否以master/worker模型来运行nginx;
(3)error_log /path/to/error_loglevel: 指明错误日志文件级别,处于调试目的,可以使用debug级别,但次级别只有在编译nginx时使用了--with-debug选项才有效 ; 正常运行必备的配置:
(1)user USERNAME [GROUPNAME]:指定运行worker的用户和用户组;例如 user nginx nginx
(2)pid /path/to/nginx.pid : 指定pid文件
(3)worker_rlimit_nofile # : 指定一个worker进程能够打开的最大文件句柄数
(4)worker_rlimit_sigpending # : 指定每个用户能够发往worker信号的数量 优化性能相关的配置:
(1)worker_processes # :worker进程的个数,通常是cpu核心数减1
(2)worker_cpu_affinity cpuumask :绑定worker进程至指定的CPU上
(3)timer-resolution t :时间解析度,在x86服务器上可以不用配置
(4)worker_priority NICE :调整nice值(-20,19);nice值越大,越优先分配cpu 事件相关的配置;
(1)accept_mutex [on|off] :内部调动用户请求至各worker时的负载均衡锁;启用时表示能够让多个worker轮流的、序列化的响应请求
(2)lock_file /path/to/lock_file :指定锁文件
(3)accept_mutex_delay #ms: 取得负载均衡锁的时间
(4)use [epoll|poll|select|rgsig]:定义使用的事件模型,建议让nginx自动选择
(5)worker_connections #:每个worker进程所能够响应的最大并发请求数
nginx.conf
worker_connections 64;
} http {
include /usr/local/nginx/conf/mime.types;
default_type application/octet-stream; #charset gb2312; server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k; keepalive_timeout 60; fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 128k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
client_body_temp_path /usr/local/nginx/client_body_temp;
proxy_temp_path /usr/local/nginx/proxy_temp;
fastcgi_temp_path /usr/local/nginx/fastcgi_temp; gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on; client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
#设定虚拟主机
include /usr/local/nginx/conf/vhost/aa.test.com;
}
一、Nginx的主配置文件详解(nginx.conf)
 一、Nginx的主配置文件详解(nginx.conf)
 user nobody nobody;   #运行用户与组
 worker_processes 6;   #启动进程,通常设置与CPU数相同
 worder_cpu_affinity 4;  #明确指定使用哪些CPU 如使用1、3核心: 1000 0010
 worker_rlimit_nofile 51200; #设置最大系统连接数
 worker_priority 1;   #指定调用CPU优先级;取值范围(-20~20)
 #error_log logs/error.log; 
 #error_log logs/error.log notice; #错误日志及日志级别;日志级别有:(debug|info|notice|warn|error|crit|alert|emerg)
 #error_log logs/error.log info;
 #pid logs/nginx.pid;   #PID文件路径
 lock_file logs/nginx.lock;  #锁文件路径
 events {    #事件模块
 use epoll;   #指定事件驱动模型;(kqueue|rtsig|epoll|select|poll|eventport)
 worker_connections 51200; #定义连接数限制;当超过1024时,须使用"ulimit -n"来解除系统连接限制
 }
 http {      #设置HTTP服务器模块
 include mime.types; #设置MIME类型
 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;   #指定Nginx是否调用sedfile函数
 #autoindex on;  #开启索引功能,适合下载服务器,默认关闭
 #tcp_nopush on;  #防止网络阻塞
 #tcp_nodelay on;  #防止网络阻塞
 #keepalive_timeout 0;
 keepalive_timeout 65;    #连接超时时间,单位秒
 server_names_hash_bucket_size 128; #服务器名字Hash表大小
 large_client_header_buffers 4 32k; #设定请求缓存大小
 client_header_buffer_size 2k; #客户端请求头部缓冲区大小
 client_body_buffer_size 512k; #客户端请求主休缓冲区大小
 client_header_timeout 60;  #客户端请求头部超时时间
 client_max_body_size 8M;  #设置通过Nginx上传的文件大小
 proxy_connect_timeout 20; #代理连接超时时间
 proxy_send_timeout 60;  #代理发送超时时间
 proxy_read_timeout 20;  #代理接收超时时间
 proxy_buffer_size 16k;  #代理服务器保存用户头信息的缓冲区大小
 proxy_buffers  4 64k;  #存放后台服务器缓冲区数量与大小
 proxy_busy_buffers_size 128k;  #高负荷下缓冲大小
 proxy_temp_file_write_size 128k; #设置缓存文件夹大小
 proxy_temp_path /usr/cache_one; #设置缓存文件夹位置
 ######指定缓冲区的路径、存储方式及大小
 proxy_cache_path /usr/proxy_cache_path levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;
 gzip on;     #开启Gzip压缩功能
 gzip_min_length 1k;  #最小压缩文件大小
 gzip_buffers 4 16k;  #压缩缓存区
 gzip_http_version 1.1;  #压缩版本
 gzip_proxied off;   #在代理中是否启用压缩功能
 gzip_comp_level 5;   #压缩级别;默认为1,取值范围(1-9)
 ######压缩文件类型
 gzip_types text/plain application/x-javascript text/css application/xml application/javascript;
 gzip_vary on;
 upstream allen { #定义负载均衡配置,必须定义在"server"之外
 ip_hash;  #基于客户端IP地址完成请求的分发,可以实现同一个客户端的请求发送到同一台服务器;有三种调度算法:轮询(round-robin)、ip哈希(ip_hash)和最少连接(least_conn)
 server 172.16.14.2 weight=1;#定义一个后端服务器;weight:权重 max_fails:最大失败连接次数,失败连接超时时间由fail_timeout设置 fail_timeout:等待请求目标服务器发送响应时长 backup:所有服务器都故障时才启用此服务器 down:手动记录此服务器不在做任何处理请求
 server 172.16.14.3 weight=1;
 }  
 server {      #定义一个虚拟主机,可以定义多个
 listen 80;    #监听端口
 server_name www.allen.com; #定义主机名称
 #charset koi8-r;   #设置字符集
 #access_log logs/host.access.log main;
 location / {    #可以定义多个,也可以嵌套
 root /web;    #设置网站文件存放目录
 index index.php index.html index.htm; #设置默认访问主页
 }
 location /status { 
   stub_status on;  #开启Nginx状态监测
 access_log off;  #关闭日志访问
 }
 location ~ .php$ {     #定义以".php"结尾的文件
 root  /web;      #定义php服务器网站存放目录
 fastcgi_pass 172.16.14.2:9000;  #定义fastcgi服务器地址及端口
 fastcgi_index index.php; #定义默认访问主页
 fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
   include fastcgi_params;  #定义fastcgi访问文件
 }
 #location ~ .*.(gif|jep|jpeg|png|bmp|swf|js|css|js|)$ {
 # proxy_cache cache_one;   #设置缓存区
 # proxy_cache_valid 200 304 12h; #设置缓存时间
 # proxy_cache_valid 301 302 1m;
 # proxy_cache_valid any 1m;
 # proxy_set_header Host $host; #设置发送到代理服务器请求头部添加额外信息
 # proxy_set_header X-Real-IP $remote_addr;
 # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 # proxy_pass http://allen;
 #}
 #location / {
 # if ($request_method == “PUT”) { #如果客户请求动作为"PUT"就转到定义的地址
 # proxy_pass http://www.allen.com:8080;
 # }
 # if ($request_uri ~ ".(jpg|gif|jpeg|png)$") { #如果客户端请求"uri"有已经定义的文件结尾的文件就转到定义好的地址然后跳出
 # proxy_pass http://imageservers;
 # break;
 # }
 #if ($http_user_agent ~ MSIE) { #如果客户端请求使用的浏览器是IE,不管请求地址是什么都转到"/msie/"下面并跳出
 #rewrite ^(.*)$ /msie/$1 break;
 注释:
 ·last - 完成重写指令,之后搜索相应的URI或location。
 ·break - 完成重写指令。
 ·redirect - 返回302临时重定向,如果替换字段用http://开头则被使用。
 ·permanent - 返回301永久重定向
 #}
 #}
 #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;  #定义以".php"结尾的全部转到指定的地址
 #}
 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
 #
 # 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 {    #定义一个HTTPS服务器
 # listen 443;
 # server_name localhost;
 # ssl   on;
 # ssl_certificate cert.pem;  #私钥文件
 # ssl_certificate_key cert.key;  #颁发的证书
 # ssl_session_timeout 5m;   #会话超时时间
 # ssl_protocols SSLv2 SSLv3 TLSv1; #SSL协议版本
 # ssl_ciphers HIGH:!aNULL:!MD5;
 # ssl_prefer_server_ciphers on;
 # location / {
 # root html;
 # index index.html index.htm;
 # }
 #}
 }
 if语句
 语法:if (condition) { ... }
 默认值:none
 使用字段:server, location
 判断一个条件,如果条件成立,则后面的大括号内的语句将执行,相关配置从上级继承。
 可以在判断语句中指定下列值:
 ·一个变量的名称;不成立的值为:空字符传""或者一些用“0”开始的字符串。
 ·一个使用=或者!=运算符的比较语句。
 ·使用符号~*和~模式匹配的正则表达式:
 URL重写模块(Rewrite)
 ·~为区分大小写的匹配。
 ·~*不区分大小写的匹配(allen匹配Allen)。
 ·!~和!~*意为“不匹配的”。
 ·使用-f和!-f检查一个文件是否存在。
 ·使用-d和!-d检查一个目录是否存在。
 ·使用-e和!-e检查一个文件,目录或者软链接是否存在。
 ·使用-x和!-x检查一个文件是否为可执行文件。
 正则表达式的一部分可以用圆括号,方便之后按照顺序用$1-$9来引用。
 示例配置:
 if ($http_cookie ~* "id=([^;] +)(?:;|$)" ) {
 set $id $1;
 }
 if ($request_method = POST ) {
 return 405;
 }
 if (!-f $request_filename) {
 break;
 proxy_pass http://127.0.0.1;
 }
 if ($slow) {
 limit_rate 10k;
 }
 if ($invalid_referer) {
 return 403;
 }
 if ($args ^~ post=140){
 rewrite ^ http://example.com/ permanent;
 }
Nginx.conf
Nginx负载均衡配置
下面使用一个案例来介绍Nginx如何配置负载均衡:
1、编译安装Nginx
######安装Nginx依赖环境
[root@nginx ~]# yum -y groupinstall "Development tools" "Server Platform Development"
[root@nginx ~]# yum -y install pcre-devel
=====================================================
######添加Nginx运行用户
[root@nginx ~]# useradd -r nginx
[root@nginx ~]# tar xf nginx-1.4.2.tar.gz
[root@nginx ~]# cd nginx-1.4.2
######编译安装Nginx
[root@nginx nginx-1.4.2]# ./configure
> --prefix=/usr #Nginx安装目录
> --sbin-path=/usr/sbin/nginx #nginx执行程序安装路径
> --conf-path=/etc/nginx/nginx.conf #Nginx主配置文件存放路径
> --error-log-path=/var/log/nginx/error.log #日志文件存放路径
> --http-log-path=/var/log/nginx/access.log
> --pid-path=/var/run/nginx/nginx.pid #PID文件存放路径
> --lock-path=/var/lock/nginx.lock #锁文件存放路径
> --user=nginx #指定运行Nginx用户
> --group=nginx #指定运行Nginx组
> --with-http_ssl_module #开启SSL加密模块
> --with-http_flv_module #支持flv流媒体模块
> --with-http_stub_status_module #开启状态检测模块
> --with-http_gzip_static_module #开启gzip静态压缩模块
> --http-client-body-temp-path=/var/tmp/nginx/client/ #客户端请求的缓存目录
> --http-proxy-temp-path=/var/tmp/nginx/proxy/ #代理缓存目录
> --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ #fcgi缓存目录
> --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi #uwsgi缓存目录
> --http-scgi-temp-path=/var/tmp/nginx/scgi #scgi缓存目录
> --with-pcre #启动正则表达式
[root@nginx nginx-1.4.2]# make && make install
2、为Nginx提供Sysv服务脚本
#!/bin/sh
# nginx - this script starts and stops the nginx daemon
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING"= "no" ] && exit 0
nginx="/usr/sbin/nginx"
prog=$(basename$nginx)
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
[ -f /etc/sysconfig/nginx] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`nginx -V 2>&1 |grep "configure arguments:"| sed 's/[^*]*--user=([^ ]*).*/1/g' -`
options=`$nginx -V 2>&1 |grep 'configure arguments:'`
foropt in $options; do
if[ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d"=" -f 2`
if [ ! -d "$value"]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] ||exit 5
[ -f $NGINX_CONF_FILE ] ||exit 6
make_dirs
echo-n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq0 ] && touch $lockfile
return$retval
}
stop() {
echo-n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq0 ] && rm -f $lockfile
return$retval
}
restart() {
configtest ||return $?
stop
sleep1
start
}
reload() {
configtest ||return $?
echo-n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null2>&1
}
case "$1" in
start)
rh_status_q && exit0
$1
;;
stop)
rh_status_q || exit0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
为Nginx提供Sysv服务脚本
3、将Nginx加入到系统服务并启动
[root@nginx ~]# chmod +x /etc/rc.d/init.d/nginx
[root@nginx ~]# chkconfig --add nginx
[root@nginx ~]# service nginx start
正在启动 nginx: [确定]
4、查看Nginx进程并访问测试
[root@nginx ~]# ps aux|grep nginx
root 2557 0.0 0.2 44444 816 ? Ss 15:20 0:00 nginx: master process/usr/sbin/nginx -c/etc/nginx/nginx.conf
nginx 2558 0.7 0.5 44852 1508 ? S 15:20 0:00 nginx: worker process

5、在WEB1服务器上安装Httpd并启动 1
2
[root@web1 ~]# yum -y install httpd
[root@web1 ~]# service httpd start
6、为WEB1服务器提供一个测试页面并做访问测试 1
[root@web1 ~]# echo 'web1 172.16.14.2' > /var/www/html/index.html

7、在WEB2服务器上面安装Httpd并启动 [root@web2 ~]# yum -y install httpd
[root@web2 ~]# service httpd start
8、为WEB2服务器提供一个测试页面并做访问测试 [root@web2 ~]# echo 'web1 172.16.14.3' > /var/www/html/index.html

修改主配置文件 #user nobody;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
worker_rlimit_nofile 51200;
#pid logs/nginx.pid;
events {
use epoll;
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;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 300m;
client_body_buffer_size 512k;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
proxy_connect_timeout 20;
proxy_send_timeout 60;
proxy_read_timeout 20;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_vary on;
upstream allen {
server 172.16.14.2;
server 172.16.14.3;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://allen;
index index.html index.htm;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
2、测试Nginx主配置文件语法,并重新加载
| 
 1 
2 
3 
4 
 | 
[root@nginx ~]# nginx -tnginx: the configurationfile /etc/nginx/nginx.conf syntax is oknginx: configurationfile /etc/nginx/nginx.conftest is successful[root@nginx ~]# service nginx reload | 
3、访问Nginx主机验证是否实现负载均衡,有时可能需要多刷新几下


 Nginx实现后端健康状态检测
 1、修改Nginx主配置文件如下
     upstream allen {
         server 172.16.14.2      backup;
         server 172.16.14.3      max_fails=3 fail_timeout=2s;
     }
 注释:
 backup:作为备份服务器,当所有服务器都停止了服务,此时backup备份机会启用
 max_fails:请求超时后,最大检测后端服务器次数
 fail_timeout:超时时间;默认为10s
 2、重新加载配置文件
 1
 [root@nginx ~]# service nginx reload
 3、测试是否访问的页面为WEB2服务器的

4、停止WEB2服务器的Httpd服务,验证是否请求的为WEB1服务器内容
| 
 1 
2 
 | 
[root@web2 ~]# service httpd stopStopping httpd:                                            [  OK  ] | 

5、把WEB2服务器Httpd服务启动,此时请求到的内容为WEB2服务器;这里就不在测试了
给Nginx添加第三方模块实现过载保护
给Nginx添加第三方模块实现过载保护 1、下载扩展补丁包,解压并打补丁 点此下载 [root@nginx ~]# unzip nginx-http-sysguard-master.zip
[root@nginx ~]# cd nginx-1.4.2
[root@nginx nginx-1.4.2]# patch -p1 < ../nginx-http-sysguard-master/nginx_sysguard_1.3.9.patch
2、重新编译安装Nginx [root@nginx nginx-1.4.2]# ./configure
> --prefix=/usr
> --sbin-path=/usr/sbin/nginx
> --conf-path=/etc/nginx/nginx.conf
> --error-log-path=/var/log/nginx/error.log
> --http-log-path=/var/log/nginx/access.log
> --pid-path=/var/run/nginx/nginx.pid
> --lock-path=/var/lock/nginx.lock
> --user=nginx
> --group=nginx
> --with-http_ssl_module
> --with-http_flv_module
> --with-http_stub_status_module
> --with-http_gzip_static_module
> --http-client-body-temp-path=/var/tmp/nginx/client/
> --http-proxy-temp-path=/var/tmp/nginx/proxy/
> --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
> --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi
> --http-scgi-temp-path=/var/tmp/nginx/scgi
> --with-pcre
> --add-module=/root/nginx-http-sysguard-master/
[root@nginx nginx-1.4.2]# make && make install
3、修改Nginx配置文件添加过载保护;这里说明下为了测试方便,把CPU负载调的比较低 [root@nginx nginx-1.4.2]# cd /etc/nginx/
[root@nginx nginx]# vim nginx.conf
######在"server"模块中添加如下内容
sysguard on; #开启过载保护功能
sysguard_load load=0.3 action=/loadlimit; #cpu负载超过0.3就保护,"action"过载保护动作
#sysguard_mem swapratio=20% action=/swaplimit; #交换分区过载保
#sysguard_mem free=100M action=/freelimit; #内存过载保护
location/loadlimit {
return 503; #系统过载返回503
}
注释:由于新添加了功能需要重启Nginx服务
[root@nginx nginx]# service nginx restart
4、安装"htop"工具,监测负载 1
2
[root@nginx ~]# yum -y install htop
[root@nginx ~]# htop

5、在另一台主机使用apache自带的压力测试工具ab做压测;在压测前先访问一下是否正常如:

| 
 1 
2 
 | 
######做压力测试[root@web1 ~]# ab -n 50000 -c 1000 http://172.16.14.1/index.html | 
6、查看Nginx服务器的负载状况

7、测试访问Nginx服务器是否能正常访问
一、Nginx配置文件详解的更多相关文章
- nginx之旅(第一篇):nginx下载安装、nginx启动与关闭、nginx配置文件详解、nginx默认网站
		
一.nginx下载安装 版本nginx 1.15.5 系统环境centos7.5(本机ip192.168.199.228) 关闭selinux 和防火墙firewall 1.下载 wget http: ...
 - Nginx系列(10)- Nginx配置文件详解
		
nginx文件结构 ... #全局块 events { #events块 ... } http #http块 { ... #http全局块 server #server块 { ... #server全 ...
 - Nginx配置文件详解
		
Nginx是一款面向性能设计的HTTP服务器,相较于Apache.lighttpd具有占有内存少,稳定性高等优势. ######Nginx配置文件nginx.conf中文详解##### #定义Ngin ...
 - Nginx教程(五) Nginx配置文件详解
		
一. Nginx配置文件nginx.conf中文详解 #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_processe ...
 - Nginx教程(五) Nginx配置文件详解 (转)
		
一. Nginx配置文件nginx.conf中文详解 #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_processe ...
 - Nginx:Nginx配置文件详解
		
Nginx是一款面向性能设计的HTTP服务器,相较于Apache.lighttpd具有占有内存少,稳定性高等优势. 如下是Nginx的配置详解: ######Nginx配置文件nginx.conf中文 ...
 - Nginx配置文件详解与优化建议
		
1.概述 今天来详解一下Nginx的配置文件,以及给出一些配置建议,希望能对大家有所帮助. 2.nginx.conf 1)配置文件位置 nginx 安装目录的 conf 文件夹下,例如:/usr/lo ...
 - nginx配置文件详解(三)
		
nginx配置文件详细解析 nginx安装目录: /usr/local/nginx 配置文件: /usr/local/nginx/conf 目录下的 nginx.conf文件 nginx优化方法1 ...
 - nginx实现动静分离--附nginx配置文件详解
		
转自http://www.cnblogs.com/1214804270hacker/p/9299462.html 一.认识访问静态资源与访问动态资源的区别 静态资源:指存储在硬盘内的数据,固定的数据, ...
 
随机推荐
- UVA 12230 - Crossing Rivers(概率)
			
UVA 12230 - Crossing Rivers 题目链接 题意:给定几条河,每条河上有来回开的船,某一天出门,船位置随机,如今要求从A到B,所须要的期望时间 思路:每条河的期望,最坏就是船刚开 ...
 - js静态方法和实例方法
			
js静态方法 function foo(){} // 声明类 foo.method = function(){} // 方法体 使用:foo.method() js实例方法 function foo( ...
 - tomcat使用所遇到的问题
			
1.在使用eclipse添加server的时候添加不了tomcat服务器: 如图左图所示,添加按钮已成灰色,无法操作. 解决办法:找到workspace的工作空间->.metadata-> ...
 - 使用BeautifulSoup解析XML文档
			
有200多个XML文档,每个文档类似如下: <?xml version="1.0"?> <VehicleInfo> <FileHeader> & ...
 - poj 2965
			
http://poj.org/problem?id=2965 本题要结合poj 1753 来看最好...又有了一点搜索的经验..加油... #include <iostream> #inc ...
 - A + B Problem II 大数加法
			
题目描述: Input The first line of the input contains an integer T(1<=T<=20) which means the number ...
 - 第一章:介绍Django
			
django简单来说就是一个Web开发框架.Web框架为应用程序提供了一套程序框架,这样你可以专注于编写清晰.易维护的代码,而无需从头做起. models.py文件主要用一个Python类来描述数据表 ...
 - AutoCAD 2014简体中文版官方正式版x86 x64下载,带注册机,永久免费使用
			
注册机使用说明:会有部分杀毒软件报病毒,请无视.操作步骤:1.安装Autodesk AutoCAD 20142.使用以下序列号666-69696969安装.3.产品密码为001F14.安装完成后,启动 ...
 - 引用 IP电话的原理结构及其关键技术
			
引用 茫然 的 两种将字符串转换成浮点数的方法 方法一: char szString[] = "-2876.99812376443"; double db1; db1 = atof ...
 - nginx日志每日定时写入Hdfs
			
#!/bin/bash hadoop_home=/opt/hadoop-2.4.0 tw_nginx_log_file=/home/chiline.com.all/access_com_tw.log ...