Nginx 1.20.2 编译安装+nginx_upstream_check_module
1、下载nginx
直接下载:wget http://nginx.org/download/nginx-1.20.2.tar.gz
2、下载nginx_upstream_check_module
wget https://github.com/yaoweibin/nginx_upstream_check_module/archive/refs/heads/master.zip
3、下载依赖、安装
#依赖安装
yum -y install patch openssl openssl-devel gcc-c++ gcc zlib pcre
#解压至/usr/local
tar -zxvf nginx-1.20.2.tar.gz -C /usr/local
unzip nginx_upstream_check_module-master.zip -d /usr/local
#编译
cd /usr/local/nginx-1.20.2
patch -p1 < /usr/local/nginx_upstream_check_module-master/check_1.20.1+.patch #打补丁
./configure --prefix=/usr/local/nginx --add-module=../nginx_upstream_check_module-master
make && make install
#增加软连接
ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/
#创建日志目录
mkdir -p /var/log/nginx
#建立conf目录
mkdir -p /etc/nginx/conf.d/
4、修改nginx.conf
vim /usr/local/nginx/conf/nginx.conf
user nginx;
worker_processes 4;
worker_rlimit_nofile 65535;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 32000;
}
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 /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65s;
include /etc/nginx/conf.d/*.conf;
server_tokens off;
server_names_hash_max_size 512;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
gzip on;
gzip_disable msie6;
gzip_min_length 1k;
gzip_comp_level 9;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_proxied any;
gzip_vary on;
gzip_types text/plain text/css text/xml text/javascript text/x-component application/json application/javascript application/xml application/xhtml+xml application/xml+rss application/rss+xml application/atom+xml application/x-font-ttf application/x-web-app-manifest+json font/opentype image/svg+xml image/x-icon;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
client_max_body_size 100m;
}
#启动nginx
cd /usr/local/nginx/sbin
./nginx -c /usr/local/nginx/conf/nginx.conf #不推荐这样启动,选择systemctl管理
#查看版本号
nginx -v