【运维工程师学习六】LAM部署搭建个人Discuz论坛
-
- 1、先卸载Mariadb再安装Mysql
- 2、MySQL官网rpm包下载
- [3、在rpm包路径下安装 YUM Repo 文件](#3、在rpm包路径下安装 YUM Repo 文件)
- 4、更新软件仓库本地数据库信息
- 5、开始部署------php的安装
- 6、搜索yum包
- 7、开始部署------配置apache以支持php
- 8、开始部署------配置apache以支持php
- 9、journalctl排错
- 10、开始部署------创建数据库
- 11、为discuz创建独立账户
- 12、网站安装程序
1、先卸载Mariadb再安装Mysql
powershell
systemctl stop mariadb
yum remove mariadb
2、MySQL官网rpm包下载
https://dev.mysql.com/downloads/repo/yum/
powershell
wget https://dev.mysql.com/get/你要下载的rpm包
powershell
wget https://dev.mysql.com/get/mysql80-community-release-el8-5.noarch.rpm

- 找到下载位置
powershell
ls /etc/yum.repos.d
- 不在上面位置的话就在刚刚下载的路径下
powershell
ls

3、在rpm包路径下安装 YUM Repo 文件
powershell
yum localinstall mysql80-community-release-el8-5.noarch.rpm

4、更新软件仓库本地数据库信息
powershell
yum makecache

powershell
yum list | grep mysql

- 如果你跟我一样之前安装过MairaDB的,请在安装完MySQL后执行(只限MySQL8.0前的版本,8.0开始的版本请看这篇文章:https://blog.csdn.net/weixin_43576565/article/details/131702483)
powershell
mysql_upgrade -u root --p
- 更新数据库(密码为你之前的MariaDB的root密码)。至此DB安装完成。
5、开始部署------php的安装
默认安装的apache不支持php。
系统自带软件仓库中同样有php二进制包,但软件仓库中的关于php的二进制包按功能组件单独编译,即php主程序被编译成一个包,其它组件如gd库、mysql库、xml库等等都被单独编译,如果网站代码中需要用到这些库则都需要安装,一般代码的说明文档会说明需要哪些库支持的。看了Discuz的readme文件,除对数据库有说明,其它的均没有说明,则本次只安装两个。使用如下安装命令:
powershell
yum install -y php php-mysql

- 报错
Error: Unable to find a match: php-mysql
原因新版的名字发生了改变,为避免下次还发生改变,使用下次命令查清名字后再安装
6、搜索yum包
powershell
yum search php-mysql
- 修改名字后开始安装
powershell
yum install -y php php-mysqlnd

7、开始部署------配置apache以支持php
(1)配置使apache能执行php脚本
安装了php及相关组件(库),需要在apache中作相关配置才能使apache能执行php脚本(代码)。配置如下:
编辑httpd.conf(yum安装的apache配置文件路径为/etc/httpd/conf/httpd.conf
)文件
1、查找AddType text/html .shtml
,在其它下方添加AddType application/x-httpd-php .php
2、查找DirectoryIndex index.html
,将其修改为DirectoryIndex index.html index.php
(2)修改配置后重启apache使配置生效。
powershell
systemctl restart httpd

8、开始部署------配置apache以支持php
配置完成apache后,需要检验apache是否正常支持php。检验方法是在网站根目录中添加一个php文件,文件名随意,如phptest.php,文件内容如下:
powershell
<?php
phpinfo();
?>

这是最简单的php代码,因为其只有一个函数phpinfo()。由于这个文件的作用是探测服务器是否支持PHP,因此这个文件又叫探针。但这是最简单的探针文件,网络上有不少功能强大的php探针脚本,可搜索下载来看看。
我这边把phptest.php设置为了默认启动页可以直接通过ip访问,当然通过路径去访问也行

9、journalctl排错
配置过程中如果出现报错启动不了,可以通过journalctl -xe排查错误,具体操作可以参考下例:
powershell
journalctl -xe
- 去到指定文件把311行内容删除

10、开始部署------创建数据库
powershell
create database discuz;
show databases;

11、为discuz创建独立账户
powershell
CREATE USER 'dztest'@'localhost'IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON discuz.* TO 'dztest'@'localhost';

- 上传网站代码至apache指定DocumentRoot目录

这里使用Xftp进行上传,上传成功后,请确保网站根目录下所有文件的所有者为apache运行用户。使用yum安装的apache运行用户名为gee(这里改为你的用户名),因此上传代码文件后,我执行了权限修改命令,确保网站所有文件的所有者均为gee。命令如下:
powershell
chown -R apache:gee /var/www/html

12、网站安装程序
powershell
你的ip/upload/install/index.php
(1)依赖补充
- 通过yum搜索缺少的依赖全称,这里以缺少json依赖为例(具体缺啥就搜啥):
powershell
yum search php-json #search啥看你缺少啥,他会提示的,我这里缺少的是json
yum install php-json
- 数据库创建为前面创建的discuz,当然你用他默认的也行只要你后期维护知道是Discuz的论坛数据库就行
- 到此就安装完毕啦,下面展示Discuz的用户管理中心、主页、管理后台