Shell script to write Nginx deployment script

Source: Internet
Author: User

The following is a script for the installation and modification of nginx.conf scripts written by the shell script, which is relatively simple:

#!/bin/bash

function Yum_install () {
Yum Install Epel-release-y
Yum Install Nginx-y
}

Yum_install

Pw=/etc/nginx/nginx.conf
Read-p "Please enter group name:" zu
Read-p "Please enter the first IP address:" Ip1
Read-p "Please enter a second IP address:" IP2
Read-p "Please enter a third IP address:" IP3

msg= "Upstream $zu {server $ip 1;server $ip 2;server $ip 3}"
Sed-ri "/^http/a $msg" $PW #增加upstream

Processor= ' Cat/proc/cpuinfo | grep "Processor" | Wc-l ' #获取cpu核数
Sed-i "S/^w.*;$/worker_processes ${processor};/g"/etc/nginx/nginx.conf #将nginx conf value in worker_processes modified to the number of cores in the CPU

Service Nginx Start

Shell script to write Nginx deployment script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.