一键安装Wordpress博客脚本
#!/bin/bash
#
#********************************************************************
#Author: zhangzexu
#QQ: 1185673631
#Date: 2020-09-08
#FileName: install_Wordpress.sh
#Description: The test script
#Copyright (C): 2020 All rights reserved
#********************************************************************
set -e
Discuz="wordpress-5.4.2-zh_CN.zip" #Wordpress包名称,官方下载
COLOR="echo -e \\033[01;31m"
END='\033[0m'
Wordpress_user="wordpress" #Wordpress数据库连接用户
Wordpress_password="tianze" #Wordpress数据库连接用户密码
Wordpress_database="wordpress" #Wordpress数据库名称
${COLOR}'开始安装Wordpress'$END
sleep 3
yum_install() {
yum list &>/dev/null
echo "Yum源检查完毕开始安装依赖包";sleep 3
yum -y install vim && yum -y install unzip httpd php php-json php-mysqlnd mariadb-server && $COLOR "yum安装完成,开始启动服务..." $END || $COLOR"您的yum源无法连接,请查看"$END
}
start_service(){
systemctl enable --now httpd mariadb
[ $? -ne 0 ] && $COLOR"Htppd启动失败,退出!"$END
$COLOR"Httpd And Mariadb 启动成功"$END
}
mysql_user(){
mysql -e "create database $Wordpress_database"
mysql -e "create user '$Wordpress_user'@'localhost' identified by '$Wordpress_password'"
mysql -e "grant all on $Wordpress_database.* to $Wordpress_user@'localhost'"
mysql -e "flush privileges"
}
install(){
$COLOR"开始下载Wordpress包"$END
sleep 2
wget https://cn.wordpress.org/$Discuz && $COLOR"下载Wordpress包完成,开始安装!!"$END || $COLOR"下载Wordpress包失败!"$END
#if [ ! -f $Discuz ];then
# echo "Wordpress包不存在"
# else
# exit
#fi
unzip ${Discuz}
sleep 5
mv wordpress/* /var/www/html/
chown -R apache.apache /var/www/html/
sleep 3
$COLOR"恭喜您!Wordpress安装完成,请前往浏览器输入http://ip/进行下一步安装。\n数据库名称:$Wordpress_database \n账号:$Wordpress_user 密码:$Wordpress_password"$END
}
yum_install
start_service
mysql_user
install
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步