以下是在 CentOS 7 上安装 Nginx 1.23.4 的步骤,配置为使用用户 www 和用户组 www,并支持 Stream、SSL 和 Zip 功能:

  1. 更新系统
sudo yum update
  1. 安装依赖
sudo yum install epel-release
sudo yum install gcc gcc-c++ make zlib-devel pcre-devel openssl-devel
  1. 下载 Nginx
wget https://nginx.org/download/nginx-1.23.4.tar.gz
tar -zxvf nginx-1.23.4.tar.gz
cd nginx-1.23.4
  1. 配置 Nginx
./configure --prefix=/usr/local/nginx \
--user=www --group=www \
--with-http_ssl_module \
--with-stream \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-stream_ssl_preread_module \
--with-http_gzip_static_module
  1. 编译并安装 Nginx
make
sudo make install
  1. 配置 Nginx
sudo vi /usr/local/nginx/conf/nginx.conf

在 http 模块下添加以下配置:

gzip on;
gzip_types text/plain application/xml text/css application/javascript;

在 stream 模块下添加以下配置:

stream {
    server {
        listen 1234;
        proxy_pass backend_server:1234;
    }
}

其中,backend_server:1234 是你要代理的后端服务器地址和端口。

  1. 启动 Nginx
sudo /usr/local/nginx/sbin/nginx

至此,你已经成功安装了 Nginx 1.23.4,并支持 Stream、SSL 和 Zip 功能。


原文地址: https://www.cveoy.top/t/topic/nvxg 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录