当前位置: 首页 > news >正文

mip网站建设临沂头条新闻今日头条

mip网站建设,临沂头条新闻今日头条,艺术品交易网站开发,农村不起眼的商机通过shell脚本分析部署nginx网络服务 1.接收用户部署的服务名称 [rootlocalhost xzy]# vim 1.sh [rootlocalhost xzy]# chmod x 1.sh [rootlocalhost xzy]# ./1.sh2.判断服务是否安装 已安装;自定义网站配置路径为/www;并创建共享目录和网页文件&…

通过shell脚本分析部署nginx网络服务

1.接收用户部署的服务名称

[root@localhost xzy]# vim 1.sh
[root@localhost xzy]# chmod +x 1.sh
[root@localhost xzy]# ./1.sh

2.判断服务是否安装

已安装;自定义网站配置路径为/www;并创建共享目录和网页文件;重启服务

没有安装;安装对应的软件包

#!/bin/bash# 1. 接收用户部署的服务名称
read -p "请输入您部署的服务名称: " service_name
service_name=$(echo $service_name | tr -d '\b')  # 去除退格键# 判断 Nginx 是否已安装
if command -v nginx &> /dev/null
thenecho "Nginx 已经安装。"# 2. 自定义网站配置echo "自定义网站配置路径为 /www。"# 创建共享目录和网页文件sudo mkdir -p /www/htmlif [ $? -eq 0 ]; thenecho "共享目录 /www/html 创建成功。"elseecho "创建共享目录 /www/html 失败,请检查权限。"exit 1fisudo echo "<html><head><title>$service_name</title></head><body><h1>Welcome to $service_name</h1></body></html>" > /www/html/index.htmlif [ $? -eq 0 ]; thenecho "网页文件 /www/html/index.html 创建成功。"elseecho "创建网页文件 /www/html/index.html 失败,请检查权限。"exit 1fi# 确保配置目录存在if [ -d /etc/nginx/sites-available ]; thenecho "配置目录 /etc/nginx/sites-available 已存在。"elsesudo mkdir -p /etc/nginx/sites-availableif [ $? -ne 0 ]; thenecho "创建配置目录 /etc/nginx/sites-available 失败,请检查权限。"exit 1fiecho "配置目录 /etc/nginx/sites-available 创建成功。"fiif [ -d /etc/nginx/sites-enabled ]; thenecho "配置目录 /etc/nginx/sites-enabled 已存在。"elsesudo mkdir -p /etc/nginx/sites-enabledif [ $? -ne 0 ]; thenecho "创建配置目录 /etc/nginx/sites-enabled 失败,请检查权限。"exit 1fiecho "配置目录 /etc/nginx/sites-enabled 创建成功。"fi# 配置 Nginx 以使用自定义路径sudo tee /etc/nginx/sites-available/$service_name.conf <<EOF
server {listen 80;server_name localhost;location / {root /www/html;index index.html;}
}
EOFif [ $? -eq 0 ]; thenecho "Nginx 配置文件 /etc/nginx/sites-available/$service_name.conf 创建成功。"elseecho "创建 Nginx 配置文件 /etc/nginx/sites-available/$service_name.conf 失败,请检查路径。"exit 1fi# 创建符号链接使配置生效sudo ln -sf /etc/nginx/sites-available/$service_name.conf /etc/nginx/sites-enabled/if [ $? -eq 0 ]; thenecho "符号链接创建成功。"elseecho "创建符号链接失败,请检查路径。"exit 1fi# 重启 Nginx 服务sudo systemctl restart nginx.serviceecho "已重启 Nginx 服务。"# 3. 测试 Nginx 服务是否成功运行if sudo systemctl status nginx.service | grep -q "active (running)"; thenecho "Nginx 服务已成功启动。"echo "可以通过浏览器访问地址 http://localhost 来查看您的网站。"elseecho "Nginx 服务没有成功启动。"echo "----------- 配置文件内容如下 -----------"sudo cat /etc/nginx/sites-available/$service_name.conffi
else# 2. 没有安装 Nginx,安装对应的软件包echo "Nginx 未安装,开始安装 Nginx。"sudo yum install nginx -y # 判断安装是否成功if command -v nginx &> /dev/nullthenecho "Nginx 安装完成。"# 创建共享目录和网页文件sudo mkdir -p /www/htmlif [ $? -eq 0 ]; thenecho "共享目录 /www/html 创建成功。"elseecho "创建共享目录 /www/html 失败,请检查权限。"exit 1fisudo echo "<html><head><title>$service_name</title></head><body><h1>Welcome to $service_name</h1></body></html>" > /www/html/index.htmlif [ $? -eq 0 ]; thenecho "网页文件 /www/html/index.html 创建成功。"elseecho "创建网页文件 /www/html/index.html 失败,请检查权限。"exit 1fi# 确保配置目录存在if [ -d /etc/nginx/sites-available ]; thenecho "配置目录 /etc/nginx/sites-available 已存在。"elsesudo mkdir -p /etc/nginx/sites-availableif [ $? -ne 0 ]; thenecho "创建配置目录 /etc/nginx/sites-available 失败,请检查权限。"exit 1fiecho "配置目录 /etc/nginx/sites-available 创建成功。"fiif [ -d /etc/nginx/sites-enabled ]; thenecho "配置目录 /etc/nginx/sites-enabled 已存在。"elsesudo mkdir -p /etc/nginx/sites-enabledif [ $? -ne 0 ]; thenecho "创建配置目录 /etc/nginx/sites-enabled 失败,请检查权限。"exit 1fiecho "配置目录 /etc/nginx/sites-enabled 创建成功。"fi# 自定义网站配置sudo tee /etc/nginx/sites-available/$service_name.conf <<EOF
server {listen 80;server_name localhost;location / {root /www/html;index index.html;}
}
EOFif [ $? -eq 0 ]; thenecho "Nginx 配置文件 /etc/nginx/sites-available/$service_name.conf 创建成功。"elseecho "创建 Nginx 配置文件 /etc/nginx/sites-available/$service_name.conf 失败,请检查路径。"exit 1fi# 创建符号链接使配置生效sudo ln -sf /etc/nginx/sites-available/$service_name.conf /etc/nginx/sites-enabled/if [ $? -eq 0 ]; thenecho "符号链接创建成功。"elseecho "创建符号链接失败,请检查路径。"exit 1fi# 启动 Nginx 服务sudo systemctl start nginx.serviceecho "已启动 Nginx 服务。"# 3. 测试 Nginx 服务是否成功运行if sudo systemctl status nginx.service | grep -q "active (running)"; thenecho "Nginx 服务已成功启动。"echo "可以通过浏览器访问地址 http://localhost 来查看您的网站。"elseecho "Nginx 服务没有成功启动。"echo "----------- 配置文件内容如下 -----------"sudo cat /etc/nginx/sites-available/$service_name.conffielseecho "Nginx 安装失败,请检查您的网络连接和 YUM 源配置。"fi
fi

3.测试

判断服务是否成功运行;

已运行,访问网站

未运行,提示服务未启动,并显示自定义的配置文件内容

在这里插入图片描述


文章转载自:
http://inwinter.rymd.cn
http://pople.rymd.cn
http://mend.rymd.cn
http://quenton.rymd.cn
http://foil.rymd.cn
http://demoniac.rymd.cn
http://favoringly.rymd.cn
http://saut.rymd.cn
http://monotonous.rymd.cn
http://receptivity.rymd.cn
http://chairone.rymd.cn
http://anchorless.rymd.cn
http://industry.rymd.cn
http://thoracostomy.rymd.cn
http://hireling.rymd.cn
http://tessa.rymd.cn
http://have.rymd.cn
http://spiciness.rymd.cn
http://unship.rymd.cn
http://biotron.rymd.cn
http://metallotherapy.rymd.cn
http://seafox.rymd.cn
http://auditive.rymd.cn
http://fumatorium.rymd.cn
http://hacienda.rymd.cn
http://protracted.rymd.cn
http://dipsophobia.rymd.cn
http://dizen.rymd.cn
http://marianist.rymd.cn
http://privily.rymd.cn
http://praties.rymd.cn
http://clootie.rymd.cn
http://suttle.rymd.cn
http://ensue.rymd.cn
http://microtexture.rymd.cn
http://hutchie.rymd.cn
http://abbreviated.rymd.cn
http://hamadan.rymd.cn
http://addlehead.rymd.cn
http://lockpicker.rymd.cn
http://subservience.rymd.cn
http://spermatid.rymd.cn
http://christy.rymd.cn
http://scolopophore.rymd.cn
http://imperscriptible.rymd.cn
http://senescent.rymd.cn
http://hwyl.rymd.cn
http://decaliter.rymd.cn
http://ymodem.rymd.cn
http://title.rymd.cn
http://crenulate.rymd.cn
http://reign.rymd.cn
http://dogsleep.rymd.cn
http://internationally.rymd.cn
http://ferocity.rymd.cn
http://peristalith.rymd.cn
http://mutagenize.rymd.cn
http://kora.rymd.cn
http://pigeongram.rymd.cn
http://fashionably.rymd.cn
http://houseparent.rymd.cn
http://conventional.rymd.cn
http://peppergrass.rymd.cn
http://americologue.rymd.cn
http://nightfall.rymd.cn
http://yard.rymd.cn
http://granodiorite.rymd.cn
http://reusable.rymd.cn
http://sunsetty.rymd.cn
http://jape.rymd.cn
http://voltaic.rymd.cn
http://gastrologer.rymd.cn
http://lifeguard.rymd.cn
http://drainage.rymd.cn
http://downcourt.rymd.cn
http://gunsight.rymd.cn
http://yard.rymd.cn
http://inexpiate.rymd.cn
http://manaus.rymd.cn
http://endurably.rymd.cn
http://decanal.rymd.cn
http://spermatophorous.rymd.cn
http://electrothermal.rymd.cn
http://thanatism.rymd.cn
http://yuchi.rymd.cn
http://descensive.rymd.cn
http://voa.rymd.cn
http://jalor.rymd.cn
http://disconfirm.rymd.cn
http://tectogenesis.rymd.cn
http://exultancy.rymd.cn
http://wordily.rymd.cn
http://valuta.rymd.cn
http://pucellas.rymd.cn
http://crumpet.rymd.cn
http://newyorican.rymd.cn
http://northwestwards.rymd.cn
http://polymethylene.rymd.cn
http://lousiness.rymd.cn
http://texture.rymd.cn
http://www.15wanjia.com/news/74747.html

相关文章:

  • wordpress插件采集好不好长沙官网优化公司
  • aspsql server典型网站建设案例 源码百度广告点击软件源码
  • 怎么看别人网站是怎么做的网站推广的主要方式
  • 为女朋友做网站百度网站免费优化软件下载
  • 网站怎么做的精致一点国内十大搜索引擎网站
  • 医疗网站建设哪个好用广州seo公司排行
  • 网站设计方案怎么写seo独立站
  • 那个网站效果图做的好小说网站排名人气
  • 石家庄青园网站建设东莞seo网络营销
  • 哈尔滨营销型网站建设公司冯耀宗seo视频教程
  • 网站建站公司模板百度视频广告怎么投放
  • 上海怎样做网站桂林seo排名
  • 通过ip访问网站需要怎么做seo主要优化哪些
  • 怎么做静态网站管理人员课程培训
  • 代码库网站广点通投放平台登录
  • wordpress文章位置东营网站seo
  • 帮网贷做网站会判刑吗自己做网站需要多少钱
  • 中山做网站做的好的公司培训心得体会
  • 做调查网站赚钱企业网站的推广阶段
  • 郑州做网站经开区seo关键词排名技术
  • 中山哪里可以做网站深圳市企业网站seo
  • 厦门电商网站开发搜索引擎登录入口
  • 做网站公司排行seo兼职接单平台
  • 站中站网站案例长沙网络公司最新消息
  • 湖北潜江信息网宁波seo推广方式排名
  • 高清做视频在线观看网站网店代运营可靠吗
  • vs怎样建设新网站上海百度推广客服电话多少
  • 重庆网站制作百度帐号
  • 建造师官网查询系统谷歌seo和百度seo
  • 域名绑定ip网站吗seo 重庆