1.首先安装依赖包(依赖包有点多,我们采用yum的方式来安装)
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
2.将nginx-1.7.6.tar.gz上传到/usr/local/下
tar -zxvf nginx-1.7.6.tar.gz
3.重命名包名称,讲nginx-1.7.6改为nginx
mv nginx-1.7.6 nginx
3.编译
cd nginx
./configure
make
make install
配置文件 /usr/local/nginx/conf
user root;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 12048;
}
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;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
client_header_buffer_size 4k;
large_client_header_buffers 4 16k;
#client_max_body_size 10m;
#client_body_buffer_size 500k;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
upstream localhost {
server 132.228.119.47:8080;
server 132.228.119.48:8080;
server 132.228.119.45:8080;
}
server {
listen 9001;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_connect_timeout 3;
proxy_send_timeout 30;
proxy_read_timeout 30;
proxy_pass http://localhost;
}
}
}