RHEL 9.4 源码编译安装 Nginx
一、安装依赖
dnf install -y zlib-devel pcre-devel openssl-devel
二、下载 Nginx 源码
cd /usr/local/src
wget https://nginx.org/download/nginx-1.26.2.tar.gz
tar xvf nginx-1.26.2.tar.gz
三、编译安装
cd nginx-1.26.2
./configure --with-http_ssl_module --with-http_v2_module --with-http_realip_module
make
make install
四、创建并启动服务
vim /etc/systemd/system/nginx.service
[Unit]
Description=Nginx
After=network.target
[Service]
Type=forking
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl enable nginx
systemctl start nginx
systemctl status nginx
如果是在虚拟机中安装,服务正常启动,但是物理机的浏览器访问不了,大概率是防火墙的问题,关闭防火墙就好了 systemctl stop firewalld