完善脚本
This commit is contained in:
35
lemp.sh
35
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 <<EOF
|
||||
|
||||
y
|
||||
${MariaDB_ROOT_PWD}
|
||||
${MariaDB_ROOT_PWD}
|
||||
y
|
||||
y
|
||||
y
|
||||
y
|
||||
EOF
|
||||
|
||||
|
||||
Reference in New Issue
Block a user