Rocky Linux 9 源码安装 Nginx
hi,我是温新,一名 PHPer
创建 nginx 用户与组
groupadd nginx
useradd -g nginx nginx -M -s /sbin/nologin
下载与安装
pwd
/usr/local/src
安装 nginx
# 下载
wget https://nginx.org/download/nginx-1.25.3.tar.gz
# 解压
tar -zxvf nginx-1.25.3.tar.gz
cd nginx-1.25.3
# 预编译
./configure \
--prefix=/usr/local/software/nginx-1.25.3 \
--user=nginx \
--group=nginx \
--with-pcre \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
--with-stream_ssl_module
# 安装
make && make install
设置开机启动
vim /usr/lib/systemd/system/nginx.service
配置如下内容,保存并退出
[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/software/nginx-1.25.3/sbin/nginx
ExecReload=/usr/local/software/nginx-1.25.3/sbin/nginx -s reload
ExecStop=/usr/local/software/nginx-1.25.3/sbin/nginx -s quit
[Install]
WantedBy=multi-user.target
设置开机自启
# 设置开机自启
systemctl enable nginx.service
# 启动 nginx
systemctl start nginx.service
# 留意留意如下命令
# 禁止开机自启
systemctl disable nginx.service
# 查看nginx状态
systemctl status nginx.service
请登录后再评论