bash 指令碼編程十九 Nginx自動部署

來源:互聯網
上載者:User

自動化部署達到以下幾個目的:

1.編譯

2.安裝

3.產生HTTPS 認證

4.配置

5.設定Ubuntu 服務

首先將Nginx的壓縮包解壓並放在工程目錄下,然後將要準備的的設定檔放在conf目錄下,還有作為service需要的啟動指令檔nginx

目錄結構如下:

# tree -L 2tree -L 2.├── conf│   ├── agol.conf│   └── nginx.conf├── install.sh├── install.sh~├── nginx└── nginx-1.2.3    ├── auto    ├── CHANGES    ├── CHANGES.ru    ├── conf    ├── configure    ├── contrib    ├── html    ├── LICENSE    ├── man    ├── README    └── src8 directories, 10 files

現在看一下install.sh指令碼內容:

#!/bin/bash source ../common/tool.shinstallDpkg "libpcre3"installDpkg "libpcre3-dev"installDpkg "libssl-dev"installDpkg "openssl"cd ./nginx-1.2.3./configure --prefix=/usr/nginx --with-http_ssl_modulemakemake installcd ../cp ./nginx /etc/init.d/update-rc.d nginx defaultscp -r ./conf/* /usr/nginx/conf/#generate ssl certificate-begincd /usr/nginx/confopenssl genrsa -des3 -out server.key -passout pass:freebird 1024openssl req -new -key server.key -out server.csr -passin pass:freebird -batchcp server.key server.key.orgopenssl rsa -in server.key.org -out server.key -passin pass:freebirdopenssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crtcd -#generate ssl certificate-endservice nginx startcd ./nginx-1.2.3make clean

這裡要關注的是產生認證的時候使用批處理方式

openssl genrsa 命令用到 -passout pass:freebird 避免提示輸入口令

openssl req 命令用到 -passin pass:freebird -batch 提供口令,避免輸入一堆其他資訊

openssl rsa 命令也用到 -passin pass:freebird 提供口令

nginx啟動指令碼參考我的另一篇文章:

http://blog.csdn.net/sheismylife/article/details/6744394

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.