安装与配置
介绍
Nginx是由俄罗斯软件工程师IgorSysoev开发的一个高性能的HTTP和反向代理服务器,具备IMAP/POP3和SMTP服务器功能。Nginx最大的特点是对高并发的支持和高效的负载均衡,在高并发的需求场景下,是Apache服务器不错的替代品。目前,包括新浪、腾讯等知名网站已经开始使用Nginx作为Web应用服务器。
安装
1 2 3 4 5 6
| $ wget http://nginx.org/download/nginx-1.6.3.tar.gz $ tar -xvf nginx-1.6.3.tar.gz $ cd nginx-1.6.3/ $ ./configure --prefix=/usr/local/nginx $ make $ make install
|
命令
1 2 3 4 5 6 7
| $ sudo /usr/local/nginx/sbin/nginx -h $ sudo /usr/local/nginx/sbin/nginx $ sudo /usr/local/nginx/sbin/nginx -s stop $ sudo /usr/local/nginx/sbin/nginx -s quit $ sudo /usr/local/nginx/sbin/nginx -s reload $ sudo /usr/local/nginx/sbin/nginx -t $ sudo /sudo /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
|
配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
| user root root;
worker_processes 1;
worker_rlimit_nofile 1024;
events { use epoll; worker_connections 1024; }
http { include mime.types; default_type application/octet-stream; charset utf-8; sendfile on; keepalive_timeout 65; gzip on; gzip_disable "msie6"; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_proxied any; gzip_comp_level 4; gzip_types text/plain application/x-javascript text/css application/xml gzip_vary on; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; }
error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ ^/(images|javascript|js|css|flash|media|static)/ { expires 30d; }
}
}
|
参考:
[1] http://wiki.nginx.org/Configuration
[2] http://www.ha97.com/5194.html
[3] http://www.cnblogs.com/zfying/archive/2012/07/07/2580876.html