nginx1.21.6源码部署

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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容