下载 wget http://sysoev.ru/nginx/nginx-0.5.35.tar.gz
解压后安装到/usr/local/nginx
./configure --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_stub_status_module --prefix=/usr/local/nginx
make
make install
创建用户,建立web根目录
useradd -d /dev/null -s /sbin/nologin www
cd /
mkdir web
cd web
mkdir htdocs
cd /
chown -R www:www web
cd /usr/local/nginx
mkdir var
cd ..
chown -R www:www nginx
cd nginx
配置nginx.conf
vi /usr/local/nginx/conf/nginx.conf
内容示例为
user www www;
worker_processes 2;
error_log /usr/local/nginx/logs/error.log;
pid /usr/local/nginx/var/nginx.pid;
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include conf/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" ';
access_log /usr/local/nginx/logs/access.log main;
keepalive_timeout 30;
tcp_nopush on;
tcp_nodelay off;
upstream test {
server 127.0.0.1:81 fail_timeout=60;
server 127.0.0.1:82 fail_timeout=60;
}
limit_zone httplimit $binary_remote_addr 10m;
server
{
listen 80;
client_max_body_size 50M;
server_name www.2tutu.com 192.168.1.33;
index index.php index.htm index.html;
root /web/htdocs;
limit_conn httplimit 8;