欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

shell腳本多實(shí)例部署nginx的詳細(xì)教程

 更新時(shí)間:2021年10月25日 17:01:41   作者:彭宇棟  
周一今天給大家分享shell腳本多實(shí)例部署nginx的詳細(xì)教程,文章通過(guò)實(shí)例代碼腳本給大家詳細(xì)介紹,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧

1. 創(chuàng)建一個(gè)目錄,用來(lái)存放腳本和安裝包

[root@localhost nginx]# tree
.
├── install.sh
└── packages
    └── nginx-1.20.1.tar.gz

1 directory, 2 files
[root@localhost nginx]# 

2. 下載好對(duì)應(yīng)的安裝包

[root@localhost packages]# wget https://nginx.org/download/nginx-1.20.1.tar.gz
[root@localhost packages]# ls
nginx-1.20.1.tar.gz
[root@localhost packages]# 

3. 編寫腳本

[root@localhost nginx]# cat install.sh 
#!/bin/bash

log_dir=/var/log
install_dir=/usr/local

id nginx &>/dev/null
if [ $? -ne 0 ];then
 useradd -r -M -s /sbin/nologin nginx
fi

yum -y install pcre-devel pcre gcc gcc-c++ openssl-devel zlib zlib-devel make vim wget openssl openssl-devel gd-devel

if [ ! -d $log_dir/nginx ];then
    mkdir -p $log_dir/nginx
    chown -R nginx.nginx $log_dir/nginx
fi


if [ ! -d $install_dir/nginx-1.20.1 ];then
    tar xf packages/nginx-1.20.1.tar.gz -C $install_dir
fi

cd $install_dir/nginx-1.20.1
if [ ! -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 install
fi

echo "export PATH=$install_dir/nginx/sbin:$PATH" > /etc/profile.d/nginx.sh

cat > /usr/lib/systemd/system/nginx.service <<EOF
[Unit]
Description=Nginx server daemon
After=network.target 

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx 
ExecStop=/usr/local/nginx/sbin/nginx -s quit
ExecReload=/bin/kill -HUP \$MAINPID

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable --now nginx.service


[root@localhost nginx]# 

4. 驗(yàn)證效果

[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-devel
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元數(shù)據(jù)過(guò)期檢查:1:03:20 前,執(zhí)行于 2021年10月24日 星期日 20時(shí)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 已安裝。
依賴關(guān)系解決。
無(wú)需任何處理。
完畢!
+ '[' '!' -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 -antl
State            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]# 

到此這篇關(guān)于shell腳本多實(shí)例部署nginx的詳細(xì)教程的文章就介紹到這了,更多相關(guān)shell腳本部署nginx內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Linux Shell腳本實(shí)現(xiàn)檢測(cè)tomcat

    Linux Shell腳本實(shí)現(xiàn)檢測(cè)tomcat

    這篇文章主要介紹了Linux Shell腳本實(shí)現(xiàn)檢測(cè)tomcat的方法,推薦給小伙伴們,需要的朋友可以參考下
    2015-03-03
  • expect實(shí)現(xiàn)單臺(tái)、多臺(tái)服務(wù)器批量scp傳輸文件

    expect實(shí)現(xiàn)單臺(tái)、多臺(tái)服務(wù)器批量scp傳輸文件

    這篇文章主要介紹了expect實(shí)現(xiàn)單臺(tái)、多臺(tái)服務(wù)器批量scp傳輸文件,本文提供了單臺(tái)傳輸腳本、多臺(tái)傳輸腳本及服務(wù)器信息配置文件,需要的朋友可以參考下
    2014-12-12
  • 檢查L(zhǎng)inux系統(tǒng)中文件大小的方法總結(jié)

    檢查L(zhǎng)inux系統(tǒng)中文件大小的方法總結(jié)

    在Linux操作系統(tǒng)中,掌握如何高效檢查文件大小是每位開發(fā)者和系統(tǒng)管理員的必備技能,本文詳細(xì)介紹了四種檢查L(zhǎng)inux文件大小的方法,感興趣的朋友可以參考下
    2024-03-03
  • 詳談linux中sar的使用方法

    詳談linux中sar的使用方法

    下面小編就為大家?guī)?lái)一篇詳談linux中sar的使用方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-03-03
  • git 使用及常用命令

    git 使用及常用命令

    本文是關(guān)于git 的使用和一些git使用小技巧,以及git的常用命令,進(jìn)行的整理,希望能幫助有需要的小伙伴
    2016-07-07
  • 一天一個(gè)shell命令 文本操作系列-linux dd使用教程

    一天一個(gè)shell命令 文本操作系列-linux dd使用教程

    dd 是 Linux/UNIX 下的一個(gè)非常有用的命令,作用是用指定大小的塊拷貝一個(gè)文件,并在拷貝的同時(shí)進(jìn)行指定的轉(zhuǎn)換
    2016-05-05
  • rsync結(jié)合find技巧分享

    rsync結(jié)合find技巧分享

    這條指會(huì)找到/home 及其子目錄下,所有的*.sh文件,并將備分到/backupdir這個(gè)目錄
    2013-01-01
  • Shell腳本一鍵安裝Nginx服務(wù)自定義Nginx版本

    Shell腳本一鍵安裝Nginx服務(wù)自定義Nginx版本

    這篇文章主要為大家介紹了Shell腳本一鍵安裝Nginx服務(wù),用戶可自定義Nginx版本的腳本示例,有需要的朋友可以借鑒參考下,希望能夠參考下
    2022-03-03
  • linux mkdir命令詳解

    linux mkdir命令詳解

    Mkdir 是一個(gè)用來(lái)在 Linux 系統(tǒng)下創(chuàng)建目錄的命令。此命令屬于內(nèi)建命令。接下來(lái)通過(guò)本文給大家分享linux mkdir命令詳解,感興趣的朋友一起看看吧
    2017-09-09
  • Linux logrotate日志切割安裝配置說(shuō)明

    Linux logrotate日志切割安裝配置說(shuō)明

    這篇文章主要為大家介紹了Linux logrotate日志切割的安裝配置說(shuō)明,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-12-12

最新評(píng)論