#!/bin/bash
###部署论坛系统discuz
#基础环境:永久关闭防火墙#临时关闭#停用防火墙#开启禁用防火墙
sed -ri '/^SELINUXTYPE=/cSELINUX=disabled' /etc/selinux/config
setenforce 0
systemctl stop firewalld.service
systemctl disable firewalld.service
###安装LAMP
#下载7个相关安装包#开启Apache 和数据库 #设成开机自启
yum -y install httpd mariadb-server mariadb php php-mysql gd php-gd &> /dev/null
systemctl start httpd mariadb
systemctl enable httpd mariadb
####安装Discuz!
##导入discuz网站源码包
#下载源码压缩包#创建项目目录#下载解压文件软件#解压项目文件
#复制项目文件中upload里内容到项目文件#给项目目录授权
if [ ! -f Discuz_X2.5_SC_UTF8.zip ]
then
wget http://download.comsenz.com/DiscuzX/2.5/Discuz_X2.5_SC_UTF8.zip
fi
mkdir -p /luntan/discuz
yum -y install unzip &> /dev/null
if [ ! -d upload ]
then
unzip Discuz_X2.5_SC_UTF8.zip
echo "discuz解压完成"
else echo "discuz已被解压,无需处理"
fi
cp -rf upload/* /luntan/discuz
chown -R apache.apache /luntan/discuz
##Apache配置虚拟主机
#打开配置文件,创建项目配置文件,进行编辑#重启
if [ ! -f /etc/httpd/conf.d/discuz.conf ]
then
cat >> /etc/httpd/conf.d/discuz.conf <<-EOF
<VirtualHost *:80>
ServerName www.discuz.com
DocumentRoot /luntan/discuz
</VirtualHost>
<Directory "/luntan/discuz">
Require all granted
</Directory>
EOF
fi
systemctl restart httpd
##准备数据库
#登录数据库#创建discuz数据库
mysql -e "use discuz;" &> /dev/null
if [ $? -eq 1 ]
then
mysql -e "create database discuz;"
fi
###局域网浏览器访问:ip#虚拟机:浏览器 ip