【发布时间】:2022-02-22 02:55:36
【问题描述】:
我想自动安装 nginx Web 服务,如果 nginx 已经存在,它将安装在其他位置,例如:/usr/local/nginx。
#!/bin/bash
echo "Beginning installation of nginx web server"
if ! which nginx > /dev/null 2>&1; then
echo "Nginx is not installed"
else
echo "Installing nginx"
yum install nginx -y
#check if nginx services are up
service nginx start
fi
我是 shell 脚本的新手并尝试了上述方法,但是我无法在 else 块中执行命令。 非常感谢您的帮助。
【问题讨论】: