美文网首页
nginx1.21.6源码部署

nginx1.21.6源码部署

作者: 乌龟也疯狂 | 来源:发表于2023-03-23 16:31 被阅读0次

nginx1.21.6源码部署

#!/bin/bash
yum install -y gcc gcc-c++ autoconf automake make pcre pcre-devel zlib zlib-devel openssl openssl-devel
tar -zxvf nginx-1.21.6.tar.gz

# 增加用户nginx
useradd -s /sbin/nologin -M nginx
cd nginx-1.21.6/
# --with-debug 非生产环境使用   nginx配置文件需要指定  error_log /var/log/nginx/error.log debug;
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-pcre --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_ssl_module --with-stream
make && make install

cat >> /etc/profile << EOF
# NGINX
export NGINX_HOME=/usr/local/nginx
export PATH=\$PATH:\$NGINX_HOME/sbin
EOF
source /etc/profile

cat > /lib/systemd/system/nginx.service << EOF
[Unit]
Description=nginx
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx reload
ExecStop=/usr/local/nginx/sbin/nginx quit
PrivateTmp=true

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable nginx
systemctl start nginx
systemctl status nginx

# 默认配置文件位置
/usr/local/nginx/conf

相关文章

网友评论

      本文标题:nginx1.21.6源码部署

      本文链接:https://www.haomeiwen.com/subject/egvirdtx.html