From 3f7e9fbd8b9d1d7bb9cc30d7072aac6d0e2be398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B2=B3=E6=9D=BE?= Date: Mon, 24 Oct 2016 16:03:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lemp.sh | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/lemp.sh b/lemp.sh index 9e8b3b9..94ed9d7 100755 --- a/lemp.sh +++ b/lemp.sh @@ -22,6 +22,13 @@ else kill -9 $$ fi +while :; do echo + echo 'Please type MariaDB root password:' + read -p "Please type MariaDB root password:(Default lemp.sh press Enter) " MariaDB_ROOT_PWD + [ -z "$MariaDB_ROOT_PWD" ] && MariaDB_ROOT_PWD="lemp.sh" + [ -n "`echo $MariaDB_ROOT_PWD | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; } + done + # Close SELINUX setenforce 0 sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config @@ -146,13 +153,27 @@ echo "Configuring MariaDB..." sudo cp ./conf/my.cnf /etc/my.cnf sudo cp ./conf/server.cnf /etc/my.cnf.d/server.cnf +echo "Configuring Firewall..." +if [ "$CentOS_RHEL_version" == 7 ];then + sudo systemctl stop firewalld + sudo systemctl mask firewalld + sudo yum install iptables iptables-services -y +fi + +sudo /sbin/iptables -I INPUT -p tcp --dport 443 -j ACCEPT +sudo /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT +sudo /sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT +sudo /sbin/service iptables save + # Restarting Services echo "Restarting Services..." if [ "$CentOS_RHEL_version" == 6 ];then + sudo service iptables restart sudo service mysql restart sudo service php-fpm restart sudo service nginx restart else + sudo systemctl start iptables sudo systemctl restart mariadb.service sudo systemctl restart nginx.service sudo systemctl restart php-fpm.service @@ -160,12 +181,13 @@ fi # Set Up Autostart echo "Setting Autostart..." - if [ "$CentOS_RHEL_version" == 6 ];then + sudo chkconfig --levels 235 iptables on sudo chkconfig --levels 235 mysql on sudo chkconfig --levels 235 nginx on sudo chkconfig --levels 235 php-fpm on else + sudo systemctl enable iptables.service sudo systemctl enable mariadb.service sudo systemctl enable nginx.service sudo systemctl enable php-fpm.service @@ -173,5 +195,14 @@ fi # Done echo "Configuring MariaDB..." -sudo mysql_secure_installation +sudo mysql_secure_installation <