System initialization script can be unified, automatic configuration, reduce manpower.
Here is a brief talk about Yum installation and source code compilation and installation, please correct me. I have been insisting on Yum installation for the following reasons
First, easy to install, do not need to spend more energy to consider the problem of dependency
Second, the configuration is unified, convenient later maintenance, automation and so on
Third, convenient upgrade
Four, okay, I'm a vegetable chicken, I admit it. 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0039.gif "alt=" J_0039.gif "style=" Padding:0px;margin : 0px;vertical-align:top;border:none; "/>
#!/bin/sh# determine user identity username= ' whoami ';if [ $username != "root" ]then echo "Insufficient current user rights, will exit script"; exit 2;fi# verify user Network echo "detect network ...";/bin/ping www.baidu.com -c 2 >> /dev/nullif [ $? != 0 ]then echo "Network does not communicate properly, please check the network configuration"; exit 3;fiecho "Network normal"; sleep 1; #安装yum remi php Source if rpm -qa|grep remi-release >> /dev/ null;then echo "remi resource is installed"; elseyum_changes= "a"; version= ' cat /etc/issue|head -n 1|awk {' print $3 '}|tr '. " "\ n" |head -n 1 ' if [ $version == 5 ]then rpm -uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm http:// rpms.famillecollet.com/enterprise/remi-release-5.rpm 2>&1 >> /tmp/sys_log.txt elif [ $version == 6 ]then rpm -uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/ Epel-release-6-8.noarch.rpm http://rpms.famillecollet.com/enterprise/remi-release-6.rpm 2>&1 >> /tmp/sys_log.txtfiif [ $? != 0 ]then echo "Failed to install yum source, please check the log under TMP";else echo "yum source has been installed, please configure the Remi Source configuration file, choose PHP Version"; Fifi# asks the user whether to close selinuxselinux_st= ' sestatus | awk {' print $3 '} ' if [ $selinux _st != "Disabled" ]then se_changes= "a"; until [ $se _changes == "yes" ] && [ $se _changes == "no"  ] do read -p "The current SELinux status is open, Whether to close (enter Yes to close, enter no not to close): "Se_changes done if [ $se _changes == "yes"  ] then sed -i ' s/^selinux= Enforcing$/selinux=disables/' /etc/selinux/config 2>&1 >> /tmp/sys_log.txt if [$? != 0] then echo " To close the SELinux error, please check the log under TMP "; fi elif [ $se _changes == "No" ] then echo "You have chosen not to turn off SELinux"; fielse echo " The selinux was detected to be closed "; fi
Let's say the script's business logic:
Determine user identity [non-root exit script]
Detect if the server network is healthy [error exit script]
Installing the Remi Yum Source
Turn off SELinux
Close Iptables
Change the SSH port
Changing Linux network kernel parameters
#其中关闭iptables, change the SSH port, change the Linux network kernel parameters, temporarily do not write logic code, the weekend will be updated on
This article is from the "Linux operation and Maintenance" blog, reproduced please contact the author!
Centos System Initialization Management script