-
Notifications
You must be signed in to change notification settings - Fork 0
/
Deploy_discuz.sh
70 lines (64 loc) · 2.25 KB
/
Deploy_discuz.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Author:afei
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
Check_Services(){
for service in nginx.service mysqld.service php-fpm.service
do
if [ -f /usr/lib/systemd/system/${service} ]; then
if [ "${service}" == nginx.service ];then
echo "=================================="
echo "nginx检测完毕,nginx服务正常。"
elif [ "${service}" == mysqld.service ];then
echo "=================================="
echo "mysql数据库检测完毕,mysqld服务正常。"
echo "=================================="
elif php -v || ${service} == php-fpm.service; then
echo "=================================="
echo "PHP环境检测完毕,PHP服务正常。"
echo "=================================="
else
echo"LAMP环境异常,请检查httpd、mysql、php服务!"
exit
fi
systemctl start mysqld && systemctl start nginx && systemctl start php-fpm
fi
done
}
Deploy_discuz(){
cd /usr/share/nginx/html
git clone https://gitee.com/ComsenzDiscuz/DiscuzX.git
chmod -Rf 777 DiscuzX/upload/*
# discuz数据库配置
mysql -e "create database discuz charset=utf8;" -uroot -p123
mysql -e "grant all on discuz.* to 'root'@'localhost' identified by 'cl';" -uroot -p123
mysql -e "flush privileges;" -uroot -p123
echo "============================================================"
echo "数据库配置成功,可以开始安装discuz了。"
}
Install_discuz(){
Check_Services
Deploy_discuz
if ! rpm -qa php-xml; then
yum install -y php-xml --enablerepo remi-php70
php -m |grep ^xml$
systemctl restart php-fpm && systemctl restart nginx
else
php -m |grep ^xml$
fi
ip_add=$(ip addr | grep -E -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -E -v "^127\.|^255\.|^0\." | head -n 1)
echo "============================================================"
echo "浏览器打开:http://${ip_add}/DiscuzX/upload,按照页面提示即可安装。"
echo " "
}
echo "=================================="
echo "基于LNMP架构部署discuz"
echo "=================================="
echo " "
read -p "是否安装部署discuz(y|n):" X
if [ $X == y -o $X == Y ]; then
Install_discuz
else
echo "=================================="
echo "正在退出部署discuz..."
fi