使用Shell脚本一键部署基础LAMP架构
安装顺序:apache→mysql→PHP
实验所需软件包:链接:https://pan.baidu.com/s/1tKAjqn50NnR7F3JmzyHF1w 提取码:1xpr
#!/bin/bash
#一键自动构建LAMP架构(请使用source执行或者使用.命令执行)
#数据库默认密码为123123
#远程挂载
df -hT | grep -o "cifs"
if [ $? -ne 0 ];then
echo "Start mount"
yum install expect -y
read -p "请输入提供硬盘主机IP:" gongip
/usr/bin/expect <> /etc/profile
source /etc/profile
echo $PATH | grep -o "mysql"
if [ $? -eq 0 ];then
echo "添加成功"
else
echo "失败"
exit 1
fi
useradd -s /sbin/nologin mysql
chown -R mysql:mysql /usr/local/mysql/
/usr/local/mysql/scripts/mysql_install_db
--user=mysql
--ldata=/var/lib/mysql
--basedir=/usr/local/mysql
--datadir=/home/mysql
sed -i -e '47d' -e '46d' -e '45abasedir=/usr/local/mysqlndatadir=/home/mysql' /etc/init.d/mysqld
service mysqld start
netstat -ntuap | grep mysqld
if [ $? -eq 0 ];then
echo Mysql数据库启动
else
echo 启动失败
exit 1
fi
#read -p "请输入数据库密码(自定义):" mima
/usr/bin/expect
EOF
service httpd stop
service httpd start
rm -rf /opt/*
umount /mnt
#请使用source+脚本启动
source /etc/profile
echo $PATH | grep -o "mysql"
while [ $? -ne 0 ];do
while [ "a" = "a" ]
do
echo "错误!!"
sleep 2
done
done
echo "LAMP架构完成。脚本执行结束~~~~"