1208天 Edwiin

还好有你,再见如初。

Centos7环境下快速部署LAMP环境(CentOS7+Apache+MySQL+PHP)脚本分享

发布于 15天前 / 30 次围观 / 0 条评论 / / Edwiin

脚本食用方法:

1、随处新建一个后戳为.sh的文件,然后把下面命令copy进去

2、sh xx.sh 启动脚本

亲测3分钟安装完毕。

clear
echo ""
echo "###############################################################"
echo -e "\e[37m"###"	" "\e[35m"脚本名称: Centos7_LAMP环境一键部署"\e[0m""\e[37m"	"	    	    ###" "\e[35m"
echo -e "\e[37m"###"	" "\e[32m"版本: v1.0"\e[0m""\e[37m"	"                                       ###" "\e[35m"
echo -e "\e[37m"###"	" "\e[33m"作者:  遇见心流"\e[0m""\e[37m"	"				    ###" "\e[35m"
echo -e "\e[37m"###"	" "\e[32m"时间: 2019-06-02"\e[0m""\e[37m"	"				    ###" "\e[35m"
echo -e "\e[37m"###"	" "\e[32m"网站: http://www.Edwiin.cn/"\e[0m""\e[37m"	"                      ###" "\e[0m"
echo "###############################################################"
sleep 3
echo 注意:提前需要确认被安装机器是否正常联网!
sleep 3
echo -e "\e[33m"正在初始化脚本文件……1"\e[0m"
sleep 4
echo -e "\e[33m"正在初始化脚本文件……2"\e[0m"
sleep 4
echo -e "\e[33m"正在初始化脚本文件……3"\e[0m"
sleep 4
echo -e "\e[33m"安装程序准备完成!"\e[0m"
sleep 2
echo -e "\e[33m"关闭防火墙中……"\e[0m"
service firewalld stop
systemctl disable firewalld.service
echo -e "\e[33m"防火墙已关闭!"\e[0m"
sleep 2
echo -e "\e[33m"开始安装Apache……"\e[0m"
yum -y install httpd
systemctl start httpd.service
systemctl enable httpd.service
echo -e "\e[33m"Apache安装完毕!"\e[0m"
sleep 2
echo -e "\e[33m"开始安装PHP……"\e[0m"
yum -y install php
systemctl restart httpd
echo -e "\e[33m"PHP安装完毕!"\e[0m"
sleep 2
echo -e "\e[33m"开始安装MySql……"\e[0m"
yum -y install mariadb mariadb-server
systemctl start mariadb.service
systemctl enable mariadb.service
echo -e "\e[33m"根据提示设置MySQL密码"\e[0m"
mysql_secure_installation
echo -e "\e[33m"MySQL安装完毕!"\e[0m"
sleep 2
echo -e "\e[33m"输入刚刚设置的MySQL密码登陆MySQL"\e[0m"
echo -e "\e[33m"进入MySQL命令行之后手动输入如下2条命令,开启远程连接"\e[0m"
echo -e "\e[32m"GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;"\e[0m"
echo -e "\e[32m"flush privileges;"\e[0m"
echo -e "\e[33m"输入完毕之后,按Ctrl+C退出,脚本自动运行"\e[0m"
mysql -uroot -p
echo -e "\e[33m"开始安装PHP与MySQL关联文件……"\e[0m"
yum -y install php-mysql
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
systemctl restart httpd.service
echo "LAMP环境安装完毕!"
echo ""
echo "###############################################################"
echo -e "\e[37m"###"	" "\e[35m"脚本名称: Centos7_LAMP环境一键部署"\e[0m""\e[37m"	"	    	    ###" "\e[35m"
echo -e "\e[37m"###"	" "\e[32m"版本: v1.0"\e[0m""\e[37m"	"                                       ###" "\e[35m"
echo -e "\e[37m"###"	" "\e[33m"作者:  遇见心流"\e[0m""\e[37m"	"				    ###" "\e[35m"
echo -e "\e[37m"###"	" "\e[32m"时间: 2019-06-02"\e[0m""\e[37m"	"				    ###" "\e[35m"
echo -e "\e[37m"###"	" "\e[32m"网站: http://www.Edwiin.cn/"\e[0m""\e[37m"	"                      ###" "\e[0m"
echo "###############################################################"

//原创脚本 简单易懂 遇见心流