shell脚本多实例怎么部署nginx
发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,这篇文章主要讲解了"shell脚本多实例怎么部署nginx",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"shell脚本多实例怎么部署nginx"吧!1
千家信息网最后更新 2026年11月01日shell脚本多实例怎么部署nginx
这篇文章主要讲解了"shell脚本多实例怎么部署nginx",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"shell脚本多实例怎么部署nginx"吧!
1. 创建一个目录,用来存放脚本和安装包
[root@localhost nginx]# tree.├── install.sh└── packages └── nginx-1.20.1.tar.gz1 directory, 2 files[root@localhost nginx]#
2. 下载好对应的安装包
[root@localhost packages]# wget https://nginx.org/download/nginx-1.20.1.tar.gz[root@localhost packages]# lsnginx-1.20.1.tar.gz[root@localhost packages]#
3. 编写脚本
[root@localhost nginx]# cat install.sh #!/bin/bashlog_dir=/var/loginstall_dir=/usr/localid nginx &>/dev/nullif [ $? -ne 0 ];then useradd -r -M -s /sbin/nologin nginxfiyum -y install pcre-devel pcre gcc gcc-c++ openssl-devel zlib zlib-devel make vim wget openssl openssl-devel gd-develif [ ! -d $log_dir/nginx ];then mkdir -p $log_dir/nginx chown -R nginx.nginx $log_dir/nginxfiif [ ! -d $install_dir/nginx-1.20.1 ];then tar xf packages/nginx-1.20.1.tar.gz -C $install_dirficd $install_dir/nginx-1.20.1if [ ! -d $install_dir/nginx ];then ./configure --prefix=$install_dir/nginx \ --user=nginx \ --group=nginx \ --with-debug \ --with-http_ssl_module \ --with-http_realip_module \ --with-http_image_filter_module \ --with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --http-log-path=/var/log/nginx/access.log \ --error-log-path=/var/log/nginx/error.log make && make installfiecho "export PATH=$install_dir/nginx/sbin:$PATH" > /etc/profile.d/nginx.shcat > /usr/lib/systemd/system/nginx.service <4. 验证效果
[root@localhost nginx]# bash -x install.sh + log_dir=/var/log+ install_dir=/usr/local+ id nginx+ '[' 0 -ne 0 ']'+ yum -y install pcre-devel pcre gcc gcc-c++ openssl-devel zlib zlib-devel make vim wget openssl openssl-devel gd-develUpdating Subscription Management repositories.Unable to read consumer identityThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.上次元数据过期检查:1:03:20 前,执行于 2021年10月24日 星期日 20时57分26秒。软件包 pcre-devel-8.42-4.el8.x86_64 已安装。软件包 pcre-8.42-4.el8.x86_64 已安装。软件包 gcc-8.4.1-1.el8.x86_64 已安装。软件包 gcc-c++-8.4.1-1.el8.x86_64 已安装。软件包 openssl-devel-1:1.1.1g-15.el8_3.x86_64 已安装。软件包 zlib-1.2.11-17.el8.x86_64 已安装。软件包 zlib-devel-1.2.11-17.el8.x86_64 已安装。软件包 make-1:4.2.1-10.el8.x86_64 已安装。软件包 vim-enhanced-2:8.0.1763-15.el8.x86_64 已安装。软件包 wget-1.19.5-10.el8.x86_64 已安装。软件包 openssl-1:1.1.1g-15.el8_3.x86_64 已安装。软件包 gd-devel-2.2.5-7.el8.x86_64 已安装。依赖关系解决。无需任何处理。完毕!+ '[' '!' -d /var/log/nginx ']'+ '[' '!' -d /usr/local/nginx-1.20.1 ']'+ cd /usr/local/nginx-1.20.1+ '[' '!' -d /usr/local/nginx ']'+ echo 'export PATH=/usr/local/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin'+ cat+ systemctl daemon-reload+ systemctl enable --now nginx.service[root@localhost nginx]# [root@localhost nginx]# ss -antlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 0.0.0.0:80 0.0.0.0:* LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 128 [::]:22 [::]:* [root@localhost nginx]#感谢各位的阅读,以上就是"shell脚本多实例怎么部署nginx"的内容了,经过本文的学习后,相信大家对shell脚本多实例怎么部署nginx这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!
软件
软件包
脚本
实例
学习
内容
验证
就是
思路
情况
效果
数据
文章
星期
更多
目录
知识
知识点
篇文章
跟着
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
保险科技 互联网保险
伟宏互联网科技
云之行互联网科技
互联网 科技
富国互联网科技创新基金
互联网和黑科技的看法
福建科技产业互联网发展
杭州壁岐互联网科技有限公司
坤平互联网科技
互联网科技和信息
青海科技产业互联网发展
互联网企业科技类企业如何做账
有人说阿里系是互联网科技企业
广州有谷有贝互联网科技有限公司
2021世界互联网领先科技成果发布
九思连强互联网电子科技有限公司
吉林省码上互联网科技电话
三亚科技创新互联网基地
青岛互联网科技园
互联网科技企业文化
互联网与科技
河南云网互联网络科技有限公司
互联网医疗科技
猪兼强互联网科技
沃里互联网科技
996高科技互联网公司
如何创新互联网科技
科技互联网海报
浙南科技城互联网大厦招聘
互联网高科技绘画