五、使用yum源搭建DZ论坛
使用yum源搭建DZ论坛,虽然无法自定义PHP版本跟Apache版本,但是很方便,出错概率低。
1、关闭防火墙
$ systemctl stop firewalld
$ systemctl disable firewalld
$ setenforce 0
$ vim /etc/selinux/config
SELINUX=disabled
2、配置yum源
$ cd /etc/yum.repos.d/
$ mv CentOS-Base.repo CentOS-Base.repo.bak
$ wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
$ yum clean all
$ yum makecache
#安装epel源
$ wget -O epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
$ yum clean all
$ yum makecache
3、安装Apache
#安装httpd2.4
$ yum install -y httpd
#安装php跟Mariadb
$ yum -y install php php-mysql mariadb mariadb-server mysql-devel
#安装依赖库
$ yum install -y php-gd libjpeg* \
php-imap php-ldap php-odbc php-pear \
php-xml php-xmlrpc php-mbstring \
php-mcrypt php-bcmath php-mhash libmcrypt
#检查httpd模块组中知否存在libphp5.so模块
$ ls /etc/httpd/modules/ | grep libphp
libphp5.so
4、修改相关配置文件
$ vim /etc/httpd/conf/httpd.conf
ServerName localhost:80
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
5、编写测试页
$ vim /var/www/html/index.php
<?php
phpinfo();
?>
$ systemctl restart httpd
6、访问测试页正常

7、配置Mariadb
#加入全局变量
$ vim /etc/profile
export PATH=/usr/bin/:$PATH
$ source /etc/profile
#复制模板配置文件
$ cat /usr/share/mysql/my-medium.cnf > /etc/my.cnf
#创建root账号密码并授权
$ systemctl start mariadb.service
$ /usr/bin/mysql
use mysql;
select user,password,host from user;
delete from user where user=''; #删除空账号,也就是不输入账号名就能登录的用户
update user set password=password('123') where user='root';
grant all on *.* to 'root'@'localhost' identified by '123'; #仅允许本地使用root登录数据库
flush privileges;
quit
$ systemctl restart mariadb.service
注意Mariadb的mysql程序默认存放在/usr/bin/目录下,如果安装有mysql,不要将其搞混了。
8、编写测试页面测试php与mariadb是否正常连接
$ vim /var/www/html/index.php
<?php
$link=mysqli_connect('127.0.0.1','root','123');
if($link)
echo "OK!";
else
echo "Bad!";
?>
访问正常

9、部署DZ论坛
#创建dz论坛使用的数据库,用户,密码
$ mysql -u root -p
create database discuzdb;
grant all on discuzdb.* to 'discuzadmin'@'%' identified by '123456';
flush privileges;
quit
#修改php主配置文件开启短格式支持
$ vim /etc/php.ini
short_open_tag = On
$ systemctl restart httpd
下载DZ论坛安装包:点我下载
解压后将upload目录复制到/var/www/html目录下,重命名为dz
加入可读写执行权限
$ chmod -R 777 /var/www/html/dz
访问http://10.154.0.113/dz/install/




这里有个要注意的点,我用的参考资料1里的安装包建站,最后访问会报500错误,换一个安装包就行了。
参考资料:
使用Yum搭建DZ论坛
DZ建站页面500错误
今天的学习是为了以后的工作更加的轻松!

浙公网安备 33010602011771号