一、安装依赖
yum -y install gcc gcc-c++ make libtool zlib zlib-devel openssl openssl-devel pcre pcre-devel
二、下载Nginx
1.官网直接下载.tar.gz
安装包,地址:nginx: download
2.使用wget
命令下载
wget -c https://nginx.org/download/nginx-1.22.1.tar.gz
三、解压
tar -zxvf nginx-1.22.1.tar.gz
cd nginx-1.22.1
四、配置
-
不需要SSL
./configure --prefix=/usr/local/nginx
-
需要SSL
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
五、编译安装
make
make install
六、启动Nginx
# 启动
cd /usr/local/nginx/sbin/
./nginx
# 重启
./nginx -s reload
七、Nginx配置
-
nginx.conf配置
user root; worker_processes 1; error_log /usr/local/nginx/logs/error.log warn; #pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /usr/local/nginx/conf/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer"