编译安装基于fastcgi模式的多虚拟主机的wordpress和discuz的LAMP架构

一、环境准备
两台主机:
- httpd+php(fastcgi模式)
- mariadb 服务器
软件版本:
- mariadb-10.2.40-linux-x86_64.tar.gz
- apr-1.7.0.tar.bz2
- apr-util-1.6.1.tar.bz2
- httpd-2.4.46.tar.gz
- php-7.4.27.tar.gz
- latest-zh_CN.tar.gz
- Discuz_X3.4_SC_UTF8_20210926.zip
二、进制安装 mariadb
1、准备二进制包
# tar xvf mariadb-10.2.40-linux-x86_64.tar.gz -C /usr/local/
# cd /usr/local
# 把解压后的数据库目录通过软链接到usr/local下统一管理
# ln -sv mariadb-10.2.40-linux-x86_64/ mysql
‘mysql’ -> ‘mariadb-10.2.40-linux-x86_64/’
2、安装依赖包,创建用户
# yum install libaio -y
# useradd -r -s /sbin/nologin -d /data/mysql -u 306 mysql
# mkdir -pv /data/mysql
mkdir: created directory ‘/data’
mkdir: created directory ‘/data/mysql’
3、修改mysql目录权限,以 root 身份安装 MariaDB
# chown -R root.root /usr/local/mysql/*
# ll /usr/local/mysql/*
drwxr-xr-x 2 root root 4096 Jul 27 15:08 /usr/local/mysql/bin
-rw-r--r-- 1 root root 17987 Aug 2 17:40 /usr/local/mysql/COPYING
-rw-r--r-- 1 root root 2093 Aug 2 17:40 /usr/local/mysql/CREDITS
drwxrwxr-x 3 root root 18 Aug 4 06:06 /usr/local/mysql/data
drwxrwxr-x 3 root root 19 Aug 4 06:06 /usr/local/mysql/include
-rw-r--r-- 1 root root 8694 Aug 2 17:40 /usr/local/mysql/INSTALL-BINARY
drwxr-xr-x 5 root root 335 Jul 27 15:08 /usr/local/mysql/lib
drwxrwxr-x 4 root root 30 Aug 4 06:06 /usr/local/mysql/man
drwxrwxr-x 11 root root 4096 Aug 4 06:06 /usr/local/mysql/mysql-test
-rw-r--r-- 1 root root 2440 Aug 2 17:40 /usr/local/mysql/README.md
-rw-r--r-- 1 root root 19477 Aug 2 17:40 /usr/local/mysql/README-wsrep
drwxrwxr-x 2 root root 30 Aug 4 06:06 /usr/local/mysql/scripts
drwxrwxr-x 31 root root 4096 Aug 4 06:06 /usr/local/mysql/share
drwxrwxr-x 4 root root 4096 Aug 4 06:06 /usr/local/mysql/sql-bench
drwxrwxr-x 3 root root 275 Aug 4 06:06 /usr/local/mysql/support-files
-rw-r--r-- 1 root root 86263 Aug 2 17:40 /usr/local/mysql/THIRDPARTY
4、运行可执行脚本,生成数据库文件
# /usr/local/mysql/scripts/mysql_install_db --datadir=/data/mysql --user=mysql
5、修改配置文件
# cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf
# vi /etc/my.cnf
[mysqld]
datadir=/data/mysql #添加这两行
skip_name_resolve=ON
6、将服务设置为开机自启动
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# chkconfig --add mysqld && chkconfig mysqld on && chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
7、添加PATH变量
# echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
# . /etc/profile.d/mysql.sh
8、启动服务
# service mysqld start
Starting mysqld (via systemctl): [ OK ]
9、为wordprss和discuz应用准备数据库和用户帐号
mysql> create database wordpress;
Query OK, 1 row affected (0.00 sec)
mysql> create database discuz;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on wordpress.* to wordpress@'10.0.0.%' identified by "wppass";
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on discuz.* to discuz@'10.0.0.%' identified by 'dispass';
Query OK, 0 rows affected (0.00 sec)
三、编译安装 httpd 2.4
1、安装相关依赖包
yum install gcc pcre-devel openssl-devel expat-devel -y
2、解压源码包
# wget -O /usr/local/src/ https://mirror.bit.edu.cn/apache//apr/apr-1.7.0.tar.bz2
# wget -O /usr/local/src/ https://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
# tar xvf apr-1.7.0.tar.bz2
# tar xvf apr-util-1.6.1.tar.bz2
# tar xvf httpd-2.4.46.tar.gz
# 合并三个目录在一起
# mv apr-1.7.0 httpd-2.4.46/srclib/apr
# mv apr-util-1.6.1 httpd-2.4.46/srclib/apr-util
3、开始编译
# cd httpd-2.4.46/
./configure \
--prefix=/apps/httpd \
--enable-so \
--enable-ssl \
--enable-cgi \
--enable-rewrite \
--with-zlib \
--with-pcre \
--with-included-apr \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=event
# make -j 4 && make install
4、准备PATH变量
# echo 'PATH=/apps/httpd/bin:$PATH' >/etc/profile.d/httpd.sh
# . /etc/profile.d/httpd.sh
5、创建和配置用户和组
# useradd -s /sbin/nologin -r -u 88 apache
# vi /apps/httpd/conf/httpd.conf +172
User apache #改成apache
Group apache #改成apache
6、设置开机启动
# vi /usr/lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
Type=forking
#EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/apps/httpd/bin/apachectl start
#ExecStart=/apps/httpd/bin/httpd $OPTIONS -k start
ExecReload=/apps/httpd/bin/apachectl graceful
#ExecReload=/apps/httpd/bin/httpd $OPTIONS -k graceful
ExecStop=/apps/httpd/bin/apachectl stop
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.targe
7、启动服务
# apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fec4:3eef%eth0. Set the 'ServerName' directive globally to suppress this message
四、编译安装 fastcgi 方式的 php 7.4
1、安装依赖包
yum -y install gcc libxml2-devel bzip2-devel libmcrypt-devel sqlite-devel oniguruma-devel
2、解压源码包开始编译
# tar xf php-7.4.27.tar.gz
# cd php-7.4.27/
# ./configure \
--prefix=/apps/php \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--with-zlib \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d \
--enable-mbstring \
--enable-xml \
--enable-sockets \
--enable-fpm \
--enable-maintainer-zts \
--disable-fileinfo
# make -j 4 && make install
3、添加PATH变量
# echo 'PATH=/apps/php/bin:/apps/httpd/bin:$PATH' > /etc/profile.d/php.sh
# . /etc/profile.d/php.sh
# php --version
PHP 7.4.27 (cli) (built: Dec 24 2021 23:40:16) ( ZTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
五、修改php配置
1、拷贝模板文件
# cp php.ini-production /etc/php.ini
# cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/
# cd /apps/php/etc
# cp php-fpm.conf.default php-fpm.conf
# cd php-fpm.d/
# cp www.conf.default www.conf
# vi /apps/php/etc/php-fpm.d/www.conf
user apache #修改进程所有者
group apache
pm.status_path = /fpm_status #开启状态页面status
ping.path = /ping #开启ping模块
2、启用opcache加速
# mkdir /etc/php.d/
# vi /etc/php.d/opcache.ini
[opcache]
zend_extension=opcache.so
opcache.enable=1
3、启动PHP
# systemctl daemon-reload
# systemctl enable --now php-fpm.service
# ss -ntl #监听端口127.0.0.1:9000打开
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:111 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 [::]:80 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
六、http配置文件修改
[root@httpd-fastcgi ~]# vi /apps/httpd/conf/httpd.conf
#开启反向代理模块
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
#添加index为主页面
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
AddType application/x-httpd-php .php
ProxyRequests Off
# 实现第一个虚拟主机:wordpress
<virtualhost *:80>
servername blog.magedu.org
documentroot /data/wordpress
<directory /data/wordpress>
require all granted
</directory>
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/wordpress/$1
#实现status和ping页面
ProxyPassMatch ^/(fpm_status|ping)$ fcgi://127.0.0.1:9000/$1
CustomLog "logs/access_wordpress_log" common
</virtualhost>
#实现第二个虚拟主机:discuz
<virtualhost *:80>
servername forum.magedu.org
documentroot /data/discuz
<directory /data/discuz/>
require all granted
</directory>
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/discuz/$1
CustomLog "logs/access_discuz_log" common
</virtualhost>
七、部署wordpress
1、安装wordpress
# wget https://cn.wordpress.org/latest-zh_CN.tar.gz
# tar xvf latest-zh_CN.tar.gz
# mv wordpress/ /data
# setfacl -R -m u:apache:rwx /data/wordpress/
2、 web界面访问wordpress
在Windows客户端打开hosts文件,添加域名解析:
C:\Windows\System32\drivers\etc\hosts
10.0.0.27 forum.magedu.org blog.magedu.org
打开浏览器输入网址blog.magedu.org访问





已经可以使用wordpress搭建博客了
八、部署discuz!
1、安装discuz!
# mkdir /data/discuz
# unzip Discuz_X3.4_SC_UTF8_20210926.zip
# mv upload/* /data/discuz
# setfacl -R -m u:apache:rwx /data/discuz/
2、 web界面测试discuz
# cat /data/discuz/info.php
<?php phpinfo() ?>
在浏览器输入地址打开forum.magedu.org/info.php

在浏览器输入地址打开forum.magedu.org/install进入安装向导



编译安装基于fastcgi模式的多虚拟主机的wordpress和discuz的LAMP架构的更多相关文章
- 编译安装基于 fastcgi 模式的多虚拟主机的wordpress和discuz的LAMP架构
目录 实现CentOS 7 编译安装基于 fastcgi 模式的多虚拟主机的wordpress和discuz的LAMP架构 准备环境: 准备软件版本: 主机名修改用以区分 数据库服务器 实现数据库二进 ...
- nginx篇最初级用法之三种虚拟主机基于域名\基于端口\基于IP地址端口的虚拟主机
在nginx中虚拟主机的类型与apache一样也有三种 1.基于域名的虚拟主机 2.基于端口的虚拟主机 3.基于IP地址端口的虚拟主机 在nginx配置文件中每一个server为一个虚拟主机如果需要多 ...
- 源码编译安装LAMP环境及配置基于域名访问的多虚拟主机
实验环境及软件版本: CentOS版本: 6.6(2.6.32.-504.el6.x86_64) apache版本: apache2.2.27 mysql版本: Mysql-5.6.23 php版本 ...
- 源码编译安装LNMP环境及配置基于域名访问的多虚拟主机
实验环境及软件版本: CentOS版本: 6.6(2.6.32.-504.el6.x86_64) nginx版本: nginx-1.6.2 mysql版本: Mysql-5.6.23 php版本: ...
- 编译安装基于nginx与lua的高性能web平台-openresty
1.首先编译安装nginx(不多说) 2.开始安装openresty cd /usr/local/src wget https://openresty.org/download/openresty-1 ...
- centos 6.5 安装 tomcat8 及性能优化_虚拟主机
Tomcat服务器是一个免费的开放源代码的Web应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP程序的首选. Tomcat和Nginx.Apa ...
- nginx笔记 安装nginx 配置 反向代理 多虚拟主机
1,检测linux上是否 通过yum安装了nginxrpm -qi nginx 2.安装nginx之前的依赖包yum install gcc patch libffi-devel python- ...
- Nginx网络架构实战学习笔记(一):Nginx简介、安装、信号控制、nginx虚拟主机配置、日志管理、location 语法、Rewrite语法详解
文章目录 nginx简介 nginx安装 nginx信号控制 nginx虚拟主机配置 日志管理 location 语法 精准匹配的一般匹配 正则匹配 总结 Rewrite语法详解 nginx简介 Ng ...
- centos7 安装 iRedmail 后 给nginx添加虚拟主机
iRedmail安装参考官方文档和 https://ywnz.com/linuxyffq/4563.html 准备工作 更新操作系统 yum update -y 安装必要组件 yum install ...
随机推荐
- Git_使用SSH密钥操作远端仓库
git支持多种传输协议,ssh协议是其中一种. 初次使用git的用户要使用ssh协议大概需要三个步骤: 生成密钥 设置远程仓库(本文以github为例)上的公钥 把git的 remote url 修改 ...
- spring security 动态 修改当前登录用户的 权限
1.前言 spring security 可以获取当前登录的用户信息,同时提供了接口 来修改权限列表信息 , 使用这个方法 ,可以动态的修改当前登录用户权限. 那么问题来了... 如果我是管理员 ,如 ...
- console.log(a)和console.log(window.a)的区别?
console.log(window.l); //undefined console.log(l); //Uncaught ReferenceError: l is not defined js对于未 ...
- Texture+PBR两种工作流程
一.导入Texture 1.Inpspector TextureSize 2的n次幂,底层图形学需要,计算更快:不使用2的倍数,系统也会添加像素补全2n: 有最大尺寸限制8k,cubemap最高4k: ...
- HDU 1009 FatMouse' Trade (贪心)
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1009 题目大意:肥鼠准备了 磅的猫粮,准备和看管仓库的猫交易,仓库里装有他最喜爱的食物 豆.仓库有 个 ...
- 拉普拉斯平滑(Laplacian smoothing)
概念 零概率问题:在计算事件的概率时,如果某个事件在观察样本库(训练集)中没有出现过,会导致该事件的概率结果是 $0$ .这是不合理的,不能因为一个事件没有观察到,就被认为该事件一定不可能发生(即该 ...
- Genymotion安装apk问题,不能部署Genymotion-ARM-Translation_v1.zip
把Genymotion-ARM-Translation_v1.zip拖进去提示 Files successfully copied to: /sdcard/Download 但还是不能安装apk 解决 ...
- C++ 从&到&&
人类发展史,就是不断挖坑.填坑的过程. 语言发展史也是如此! 任何一门设计合理的语言,给你的限制或提供的什么特性,都不是没有代价的. C的指针 指针:pointer 指针的思想起源于汇编.指针思想是编 ...
- Book of the Dead 死者之书Demo工程回顾与学习
1.前言 一转眼离Book of the Dead Environment Demo开放下载已过去多年,当时因为技术力有限,以及对HDRP理解尚浅, 所以这篇文章一直搁浅到了现在.如今工作重心已转向U ...
- 遇到奇怪的问题:web.py 0.40中使用web.input(),出现一堆奇怪的错误
有的请求很正常,有的请求就出现了500错误. 这里使用POST请求,然后在web.input()中出现了很长很长的错误. 猜测是这个机器上安装了python2.7 / python 3.6 / pyt ...