Install nginx
CentOS Install nginx
我想尝鲜下 http3 点击立即安装
第一步 安装依赖
# gcc安装yum -y install gcc# pcre、pcre-devel安装yum install -y pcre pcre-devel# zlib安装yum install -y zlib zlib-devel# 安装opensslyum install -y openssl openssl-devel
第二步 安装 nginx
# 创建目录mkdir -p /usr/local/softwares/packages && cd /usr/local/softwares/packages# 下载wget https://nginx.org/download/nginx-1.24.0.tar.gz# 解压tar -xf nginx-1.24.0.tar.gz# 进入目录cd nginx-1.24.0# 编译./configure \--prefix=/usr/local/softwares/nginx \--pid-path=/usr/local/softwares/nginx/logs/nginx.pid \--lock-path=/usr/local/softwares/nginx/logs/nginx.lock \--error-log-path=/usr/local/softwares/nginx/logs/error.log \--http-log-path=/usr/local/softwares/nginx/logs/access.log \--with-http_gzip_static_module \--http-client-body-temp-path=/usr/local/softwares/nginx/temp/client \--http-proxy-temp-path=/usr/local/softwares/nginx/temp/proxy \--http-fastcgi-temp-path=/usr/local/softwares/nginx/temp/fastcgi \--http-uwsgi-temp-path=/usr/local/softwares/nginx/temp/uwsgi \--http-scgi-temp-path=/usr/local/softwares/nginx/temp/scgi \--with-http_stub_status_module \--with-http_ssl_module \--with-stream \--with-http_v2_module \# --add-module=/usr/local/softwares/packages/ngx_brotli# 安装make && make install# 配置文件夹mkdir -p /usr/local/softwares/nginx/temp/client# 查看版本号/usr/local/softwares/nginx/sbin/nginx -v# 测试配置文件/usr/local/softwares/nginx/sbin/nginx -t
第三步 配置环境变量
# 修改文件vim /etc/profile
# nginxexport NGINX_HOME=/usr/local/softwares/nginxexport PATH=$PATH:$NGINX_HOME/sbin
# 重载source /etc/profile
第四步 设置开机启动
# 创建文件vim /lib/systemd/system/nginx.service# 配置[Unit]Description=nginxAfter=network.target
[Service]Type=forkingExecStart=/usr/local/softwares/nginx/sbin/nginxExecReload=/usr/local/softwares/nginx/sbin/nginx -s reloadExecStop=/usr/local/softwares/nginx/sbin/nginx -s quitPrivateTmp=true
[Install]WantedBy=multi-user.target
# 设置开机启动systemctl enable nginx.service