1 Star 1 Fork 1

尹经阳/脚本文件

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
nginx_vir_server.sh 1.22 KB
一键复制 编辑 原始数据 按行查看 历史
尹经阳 提交于 2022-12-10 18:11 +08:00 . 搭建虚拟主机
#!/bin/bash
# 重置配置文件
\cp /usr/local/nginx/conf/nginx.conf.default\
/usr/local/nginx/conf/nginx.conf
# 添加虚拟主机
sed -ir '34a server {\
listen 80;\
server_name www.yjy.com;\
root html_yjy;\
index index.html;\
}' /usr/local/nginx/conf/nginx.conf
ss -antulp | grep nginx &> /dev/null
if [ `echo $?` -eq 0 ];then
/usr/local/nginx/sbin/nginx -s reload # 重新加载配置文件
else
user=`ss -antulp | grep 80 | awk -F\" 'NR==1{print $2}'`
killall $user &> /dev/null
sleep 1 # 防止进程没被终止完全 启服务报错
/usr/local/nginx/sbin/nginx # 开启nginx服务
fi
rm -rf /usr/local/nginx/html_yjy # 清场 用于重复测试
mkdir /usr/local/nginx/html_yjy # 创建yjy网站目录
echo "来到这里就成功了!!" > \
/usr/local/nginx/html_yjy/index.html # 创建网站测试页
echo -e "\033[32m虚拟主机创建成功!\033[0m"
# ============================================================
# 注意 windows环境需配置hosts文件
# C:\Windows\System32\drivers\etc\hosts
# 右键---属性---安全---编辑---users---完全控制打钩
# 然后用文本打开hosts,在最后添加
# 192.168.88.6(此处是你的虚拟机IP)www.yjy.com
# linux 环境改hosts文件添加内容和Windows一样
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/yinjingyang/script-file.git
git@gitee.com:yinjingyang/script-file.git
yinjingyang
script-file
脚本文件
master

搜索帮助