实战案例:编译安装基于 FastCGI 模式LAMP架构多虚拟主机WEB应用(WordPress 和Discuz)

君不见长松卧壑困风霜,时来屹立扶明堂。这篇文章主要讲述实战案例:编译安装基于 FastCGI 模式LAMP架构多虚拟主机WEB应用(WordPress 和Discuz)相关的知识,希望能为你提供帮助。
编译安装基于 FastCGI 模式LAMP架构多虚拟主机WEB应用(WordPress 和Discuz)1.目标实践目标:FastCGI模式(php-FPM基于TCP9000和UDS两种模式)LAMP架构的实现。
用独立的mysql服务器存放博客和论坛的数据,并在另一台CentOS 7.9环境下编译安装基于FastCGI模式的PHP,并部署Apache多虚拟主机的WordPress和Discuz的网站。
2.架构图及环境准备

# 两台服务器
1Apache(httpd)+PHP (FastCGI模式):
Httpd-PHP
CentOS 7.9
IP: 192.168.250.47/24
10.3.28-MariaDB

2Mariadb 服务器:
MariaDB
CentOS 8.4
IP: 192.168.250.48/24
10.3.28-MariaDB

# 软件包及版本:https://mariadb.com/downloads/
mariadb-10.4.22-linux-x86_64.tar.gz二进制格式
mariadb-10.4.24-linux-x86_64.tar.gz

# mariadb-10.7.3-linux-systemd-x86_64.tar.gz没搞清楚中间systemd 是什么意思
https://dlm.mariadb.com/browse/mariadb_server/192/1288/bintar-linux-systemd-x86_64/

httpd-2.4.52.tar.bz2
apr-1.7.0.tar.bz2
apr-util-1.6.1.tar.bz2
php-7.4.28.tar.xz

wordpress-5.9.1-zh_CN.zip
Discuz_X3.4_SC_UTF8_20220131.zip

https://mariadb.com/downloads/
https://mariadb.org/
https://www.php.net/downloads
https://httpd.apache.org/download.cgi
https://cn.wordpress.org/download/
https://www.dismall.com/thread-73-1-1.html

3.Maria数据库服务器【实战案例:编译安装基于 FastCGI 模式LAMP架构多虚拟主机WEB应用(WordPress 和Discuz)】基本任务:在独立的数据库服务器(IP192.168.250.48)上用最新稳定版本mariadb-10.7.3-linux-systemd-x86_64.tar.gz,二进制安装10.7.3数据库,并创建 discuz和 wordpress两个数据库,做好授权给论坛和博客通过TCP端口连接调用。
3.1.主机环境及安装包准备
官网下载地址:https://mariadb.org/download/
# 修改主机名退出再登录 确保前缀变成新主机名
[root@CentOS84 ]#hostnamectl set-hostname MarriaDB-IP48

# 时钟同步
[root@MarriaDB-IP48 ]#systemctl enable --nowchronyd.service
[root@MarriaDB-IP48 ]#

# 查看主机监听的端口,确保没有软件安装冲突
[root@MarriaDB-IP48 ]#cd /data/
[root@MarriaDB-IP48 ]#wget https://tw1.mirror.blendbyte.net/mariadb/mariadb-10.7.3/bintar-linux-systemd-x86_64/mariadb-10.7.3-linux-systemd-x86_64.tar.gz

3.2.MariaDB的安装和配置
# 查询是否有mysql账号,没有就创建
[root@MarriaDB-IP48 ]#getent passwd mysql

# 创建数据库账号 mysql组 mysql非主机登录
[root@MarriaDB-IP48 ]#useradd -r -s /sbin/nologin mysql

# 解压最新的mariadb安装包
[root@MarriaDB-IP48 ]#tar xvf mariadb-10.7.3-linux-systemd-x86_64.tar.gz -C /usr/local > /dev/nul

[root@MarriaDB-IP48 ]#ll /usr/local
drwxrwxr-x11 summer summer 245 Feb 12 07:47 mariadb-10.7.3-linux-systemd-x86_64
[root@MarriaDB-IP48 ]#

# 进入目录并创建软链接
[root@MarriaDB-IP48 ]#cd /usr/local
[root@MarriaDB-IP48 ]#ln -sv mariadb-10.7.3-linux-systemd-x86_64 mysql
mysql -> mariadb-10.7.3-linux-systemd-x86_64

# 查看mysql目录下的文件权属,并修改
[root@MarriaDB-IP48 ]#cd mysql
[root@MarriaDB-IP48 ]#ll
total 164
drwxr-xr-x2 summer summer4096 Jan 19 01:31 bin
-rw-r--r--1 summer summer 17987 Feb 11 04:33 COPYING
-rw-r--r--1 summer summer2093 Feb 11 04:33 CREDITS
drwxrwxr-x3 summer summer19 Feb 11 05:11 include
-rw-r--r--1 summer summer8782 Feb 11 04:33 INSTALL-BINARY
drwxr-xr-x5 summer summer293 Jan 19 01:31 lib
drwxrwxr-x5 summer summer42 Feb 11 05:12 man
drwxrwxr-x9 summer summer4096 Feb 11 05:12 mysql-test
-rw-r--r--1 summer summer2697 Feb 11 04:33 README.md
-rw-r--r--1 summer summer 19520 Feb 11 04:33 README-wsrep
drwxrwxr-x2 summer summer56 Feb 11 05:12 scripts
drwxrwxr-x 31 summer summer4096 Feb 11 05:12 share
drwxrwxr-x4 summer summer4096 Feb 11 05:12 sql-bench
drwxrwxr-x4 summer summer180 Feb 11 05:12 support-files
-rw-r--r--1 summer summer 86263 Feb 11 04:33 THIRDPARTY

[root@MarriaDB-IP48 ]#chown -R root.root ./*
#上面的命令等同于 chown -R root:root /usr/local/mysql/

# 权属修改的确认
[root@MarriaDB-IP48 ]#ll
total 164
drwxr-xr-x2 root root4096 Jan 19 01:31 bin
-rw-r--r--1 root root 17987 Feb 11 04:33 COPYING
-rw-r--r--1 root root2093 Feb 11 04:33 CREDITS
drwxrwxr-x3 root root19 Feb 11 05:11 include
-rw-r--r--1 root root8782 Feb 11 04:33 INSTALL-BINARY
drwxr-xr-x5 root root293 Jan 19 01:31 lib
drwxrwxr-x5 root root42 Feb 11 05:12 man
drwxrwxr-x9 root root4096 Feb 11 05:12 mysql-test
-rw-r--r--1 root root2697 Feb 11 04:33 README.md
-rw-r--r--1 root root 19520 Feb 11 04:33 README-wsrep
drwxrwxr-x2 root root56 Feb 11 05:12 scripts
drwxrwxr-x 31 root root4096 Feb 11 05:12 share
drwxrwxr-x4 root root4096 Feb 11 05:12 sql-bench
drwxrwxr-x4 root root180 Feb 11 05:12 support-files
-rw-r--r--1 root root 86263 Feb 11 04:33 THIRDPARTY

# 创建数据库存放数据的目录,并授权mysql.mysql
[root@MarriaDB-IP48 ]#mkdir /data/mysql -p
[root@MarriaDB-IP48 ]#chown -R mysql.mysql /data/mysql

# 创建数据库配置文件目录,并编写配置文件说明:本例的my.cnf属于极小化配置,需要根据生产需要做细化配置
[root@MarriaDB-IP48 ]#mkdir /etc/mysql

[root@MarriaDB-IP48 ]#vim /etc/mysql/my.cnf
[root@MarriaDB-IP48 ]#cat /etc/mysql/my.cnf
[mysqld]
server-id=1
log-bin
datadir=/data/mysql
socket=/data/mysql/mysql.sock
skip_name_resolve = on

log-error=/data/mysql/mysql.log
pid-file=/data/mysql/mysql.pid

[client]
port=3306
socket=/data/mysql/mysql.sock
[root@MarriaDB-IP48 ]#

## 进入数据库程序文件目录,安装依赖包,初始化安装数据库
[root@MarriaDB-IP48 ]#cd /usr/local/mysql
# 安装依赖包
[root@MarriaDB-IP48 ]#yum -y install libaio
# 初始化安装数据库
[root@MarriaDB-IP48 ]#./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
Installing MariaDB/MySQL system tables in /data/mysql ...
OK
...............

# 准备数据库的服务文件
[root@MarriaDB-IP48 ]#cp support-files/systemd/mariadb.service /usr/lib/systemd/system
[root@MarriaDB-IP48 ]#ll
drwxrwxr-x4 root root180 Feb 11 05:12 support-files

# 个性化数据库,定义专用的日志等目录,并授权
[root@MarriaDB-IP48 ]#mkdir /var/log/mariadb
[root@MarriaDB-IP48 ]#mkdir /var/run/mariadb

[root@MarriaDB-IP48 ]#chown mysql:mysql /var/log/mariadb
[root@MarriaDB-IP48 ]#chown mysql:mysql /var/run/mariadb

# 设置PATH变量并使之立刻生效
[root@MarriaDB-IP48 ]#echo PATH=/usr/local/mysql/bin:$PATH > /etc/profile.d/mysql.sh
[root@MarriaDB-IP48 ]#. /etc/profile.d/mysql.sh

# 启动服务,并设定为开机自动启动
[root@MarriaDB-IP48 ]#systemctl enable --now mariadb
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

3.3.验证数据库
# 查看监听
[root@MarriaDB-IP48 ]#ss -tln
StateRecv-QSend-QLocal Address:PortPeer Address:PortProcess

LISTEN0800.0.0.0:33060.0.0.0:*
LISTEN080[::]:3306[::]:*

# 进入数据库
[root@MarriaDB-IP48 ]#mysql
Welcome to the MariaDB monitor.Commands end with ; or \\g.
Your MariaDB connection id is 4
Server version: 10.7.3-MariaDB-log MariaDB Server#此行看到数据库版本信息

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type help; or \\h for help. Type \\c to clear the current input statement.

# 查看库
MariaDB [(none)]> show databases;
+--------------------+
| Database|
+--------------------+
| information_schema |
| mysql|
| performance_schema |
| sys|
| test|
+----

    推荐阅读