脚本一键编译安装nginx
作者:互联网
1、一键安装脚本如下:
#!/bin/bash
# 解决依赖关系
yum install gcc pcre-devel openssl-devel -y
# 下载nginx安装包
curl -O http://nginx.org/download/nginx-1.19.2.tar.gz
# 解压
tar -xf nginx-1.19.2.tar.gz
# 建立一个用户
useradd mynginx
echo "123456" |passwd mynginx --stdin
cd nginx-1.19.2
# 编译前的配置
./configure --prefix=/usr/local/nginx --user=mynginx --group=mynginx --with-threads --with-http_ssl_module --with-http_realip_module --with-stream --with-http_stub_status_module
# 编译和编译安装
make && make install
# 修改环境变量PATH
echo "PATH=$PATH:/usr/local/nginx/sbin" >>/etc/bashrc
# 关闭防火墙和selinux
service firewalld stop
systemctl disable firewalld
setenforce 0
sed -i '/^SELINUX/ s/enforcing/disabled' /etc/sysconfig/selinux
# 开启nginx服务
/usr/local/swy_nginx/sbin/nginx
2、验证是否安装成功
查看nginx进程是否存在
ps -ef |grep nginx |grep -v grep
在浏览器上输入本机的IP地址,有如下效果则说明安装成功
标签:http,编译,--,一键,mynginx,1.19,nginx 来源: https://blog.csdn.net/m0_52904076/article/details/118636845