批量部署nginx1.18脚本
时间: 2023-10-09 12:06:01 浏览: 94
![](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
安装nginx脚本
以下是一个简单的批量部署 nginx 1.18 的脚本:
```bash
#!/bin/bash
# 定义 nginx 版本和安装目录
NGINX_VERSION=1.18.0
NGINX_INSTALL_DIR=/usr/local/nginx
# 定义需要安装的服务器列表
SERVERS=(
192.168.1.1
192.168.1.2
192.168.1.3
)
# 遍历服务器列表,逐个安装 nginx
for server in "${SERVERS[@]}"
do
echo "Installing nginx on server ${server}..."
ssh ${server} "wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz &&
tar zxvf nginx-${NGINX_VERSION}.tar.gz &&
cd nginx-${NGINX_VERSION} &&
./configure --prefix=${NGINX_INSTALL_DIR} &&
make &&
sudo make install &&
sudo ${NGINX_INSTALL_DIR}/sbin/nginx"
echo "nginx installed on server ${server}."
done
```
使用方法:
1. 将脚本保存为 `deploy_nginx.sh`。
2. 根据实际情况修改脚本中的 nginx 版本和安装目录。
3. 在脚本中定义需要安装 nginx 的服务器列表。
4. 执行 `bash deploy_nginx.sh` 即可开始批量部署 nginx。
注意:执行脚本时需要确保能够通过 SSH 登录到目标服务器,并且 SSH 密钥已经配置好。
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![tar](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![sh](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)