nginx版本:nginx-1.21.1
操作系统:centos7
1、上传nginx
将nginx-1.21.1.tar包上传到普通用户相关目录下(笔者这里是haproxy用户,haproxy用户组,上传到/data/haproxy目录)
2、编译&&安装nginx
tar -zvf nginx-1.21.1.tar
cd nginx-1.21.1
预编译:
./configure --prefix=/data/haproxy/nginx --user=haproxy --group=haproxy --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_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-file-aio --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'
安装
make && make install
3、修改配置文件
vim nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
#隐藏版本号
server_tokens off;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_body_timeout 1m;
client_header_timeout 1m;
send_timeout 30s;
max_ranges 1;
limit_conn_zone $binary_remote_addr zone=conn_zone:1m;
server {
listen 9005;
server_name localhost;
limit_conn conn_zone 5;
limit_rate 10000k;
location / {
mirror /mirror;
mirror_request_body on;
proxy_pass http://127.0.0.1:8762;
}
location = /mirror {
internal;
proxy_pass http://127.0.0.1:8888$request_uri;
proxy_pass_request_body on;
}
}
}
4、程序启动
文件正确性校验
../sbin/nginx -t
ps:这里如果出现successful ok就说明配置文件是OK的
../sbin/nginx
查看nginx启动状态
ps -ef |grep nginx