第十四周作业



1.简述CGI与FASTCGI区别

CGI:收到请求,会fork一个新的进程进行处理;在处理数据方面,读取参数,处理数据,然后就结束生命期
FASTCGI:收到请求,用TCP方式跟远程机器上的进程或本地进程建立连接;在处理数据方面,要开启tcp端口,进入循环,等待数据的到来,处理数据。


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

2.1 环境准备:

 两台主机:
  一台主机:httpd+php(fastcgi模式) 一台主机:mariadb 服务器
 软件版本:
  mariadb-10.2.27-linux-x86_64.tar.gz 通用二进制格式
  (下载地址:https://mariadb.org/download)
  apr-1.7.0.tar.bz2、apr-util-1.6.1.tar.bz2、httpd-2.4.43.tar.gz
  (下载地址:https://apr.apache.org/download.cgi、https://httpd.apache.org/download.cgi#apache24)
  php-7.4.27.tar.gz
  (下载地址:https://www.php.net/downloads)
  latest.tar.gz
  (下载地址:https://wordpress.org/download/)
  Discuz_X3.4_SC_UTF8【20191201】.zip
  (下载地址:https://gitee.com/3dming/DiscuzL/attach_files)

2.2 操作步骤:

二进制安装 mariadb

tar xvf mariadb-10.4.22-linux-x86_64.tar.gz -C /usr/local/
cd /usr/local/
ln -s mariadb-10.4.22-linux-x86_64 mysql
cd mysql/
chown -R root.root ./*
mkdir -p /data/mysql 
chown -R mysql.mysql /data/mysql 
mkdir /etc/mysql
cp support-files/wsrep.cnf /etc/mysql/my.cnf 
vim /etc/mysql/my.cnf

[mysqld]
datadir =/data/mysql
skip_name_resolve = ON

[root@mariadb mysql]# vim /etc/profile.d/lamp.sh 
[root@mariadb mysql]# . /etc/profile.d/lamp.sh
[root@mariadb mysql]# yum install libaio -y
[root@mariadb mysql]# cd /usr/local/mysql
[root@mariadb mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
[root@mariadb mysql]# cp support-files/mysql.server  /etc/rc.d/init.d/mysqld
[root@mariadb mysql]# chkconfig --add mysqld 
[root@mariadb mysql]# service mysqld start
Starting mysqld (via systemctl):                           [  OK  ]

[root@mariadb ~]# mysql -uroot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.4.22-MariaDB 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)]> create database wordpress;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> create database discuz;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> grant all on wordpress.* to wordpress@'10.0.0.%' identified by "123456"
    -> ;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> grant all on discuz.* to discuz@'10.0.0.%' identified by '123456';
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]>

2.3 编译安装 httpd 2.4
[root@fastcgi ~]# yum install gcc pcre-devel openssl-devel expat-devel -y
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirrors.bfsu.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
base                                                                                                                                      | 3.6 kB  00:00:00     
extras                                                                                                                                    | 2.9 kB  00:00:00     
updates                                                                                                                                   | 2.9 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package expat-devel.x86_64 0:2.1.0-12.el7 will be installed
---> Package gcc.x86_64 0:4.8.5-44.el7 will be installed
--> Processing Dependency: cpp = 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: libmpfr.so.4()(64bit) for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-4.8.5-44.el7.x86_64
---> Package openssl-devel.x86_64 1:1.0.2k-22.el7_9 will be installed
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-22.el7_9 for package: 1:openssl-devel-1.0.2k-22.el7_9.x86_64
--> Processing Dependency: zlib-devel(x86-64) for package: 1:openssl-devel-1.0.2k-22.el7_9.x86_64
--> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-22.el7_9.x86_64
---> Package pcre-devel.x86_64 0:8.32-17.el7 will be installed
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-44.el7 will be installed
---> Package glibc-devel.x86_64 0:2.17-325.el7_9 will be installed
--> Processing Dependency: glibc-headers = 2.17-325.el7_9 for package: glibc-devel-2.17-325.el7_9.x86_64
--> Processing Dependency: glibc = 2.17-325.el7_9 for package: glibc-devel-2.17-325.el7_9.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-325.el7_9.x86_64
---> Package krb5-devel.x86_64 0:1.15.1-51.el7_9 will be installed
--> Processing Dependency: libkadm5(x86-64) = 1.15.1-51.el7_9 for package: krb5-devel-1.15.1-51.el7_9.x86_64
--> Processing Dependency: krb5-libs(x86-64) = 1.15.1-51.el7_9 for package: krb5-devel-1.15.1-51.el7_9.x86_64
--> Processing Dependency: libverto-devel for package: krb5-devel-1.15.1-51.el7_9.x86_64
--> Processing Dependency: libselinux-devel for package: krb5-devel-1.15.1-51.el7_9.x86_64
--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.15.1-51.el7_9.x86_64
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.15.1-51.el7_9.x86_64
---> Package libmpc.x86_64 0:1.0.1-3.el7 will be installed
---> Package mpfr.x86_64 0:3.1.1-4.el7 will be installed
---> Package openssl-libs.x86_64 1:1.0.2k-19.el7 will be updated
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-19.el7 for package: 1:openssl-1.0.2k-19.el7.x86_64
---> Package openssl-libs.x86_64 1:1.0.2k-22.el7_9 will be an update
---> Package zlib-devel.x86_64 0:1.2.7-19.el7_9 will be installed
--> Processing Dependency: zlib = 1.2.7-19.el7_9 for package: zlib-devel-1.2.7-19.el7_9.x86_64
--> Running transaction check
---> Package glibc.x86_64 0:2.17-317.el7 will be updated
--> Processing Dependency: glibc = 2.17-317.el7 for package: glibc-common-2.17-317.el7.x86_64
---> Package glibc.x86_64 0:2.17-325.el7_9 will be an update
---> Package glibc-headers.x86_64 0:2.17-325.el7_9 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.17-325.el7_9.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.17-325.el7_9.x86_64
---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed
---> Package krb5-libs.x86_64 0:1.15.1-50.el7 will be updated
---> Package krb5-libs.x86_64 0:1.15.1-51.el7_9 will be an update
---> Package libcom_err-devel.x86_64 0:1.42.9-19.el7 will be installed
---> Package libkadm5.x86_64 0:1.15.1-51.el7_9 will be installed
---> Package libselinux-devel.x86_64 0:2.5-15.el7 will be installed
--> Processing Dependency: libsepol-devel(x86-64) >= 2.5-10 for package: libselinux-devel-2.5-15.el7.x86_64
--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.5-15.el7.x86_64
---> Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed
---> Package openssl.x86_64 1:1.0.2k-19.el7 will be updated
---> Package openssl.x86_64 1:1.0.2k-22.el7_9 will be an update
---> Package zlib.x86_64 0:1.2.7-18.el7 will be updated
---> Package zlib.x86_64 0:1.2.7-19.el7_9 will be an update
--> Running transaction check
---> Package glibc-common.x86_64 0:2.17-317.el7 will be updated
---> Package glibc-common.x86_64 0:2.17-325.el7_9 will be an update
---> Package kernel-headers.x86_64 0:3.10.0-1160.49.1.el7 will be installed
---> Package libsepol-devel.x86_64 0:2.5-10.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================
 Package                                     Arch                           Version                                        Repository                       Size
=================================================================================================================================================================
Installing:
 expat-devel                                 x86_64                         2.1.0-12.el7                                   base                             57 k
 gcc                                         x86_64                         4.8.5-44.el7                                   base                             16 M
 openssl-devel                               x86_64                         1:1.0.2k-22.el7_9                              updates                         1.5 M
 pcre-devel                                  x86_64                         8.32-17.el7                                    base                            480 k
Installing for dependencies:
 cpp                                         x86_64                         4.8.5-44.el7                                   base                            5.9 M
 glibc-devel                                 x86_64                         2.17-325.el7_9                                 updates                         1.1 M
 glibc-headers                               x86_64                         2.17-325.el7_9                                 updates                         691 k
 kernel-headers                              x86_64                         3.10.0-1160.49.1.el7                           updates                         9.0 M
 keyutils-libs-devel                         x86_64                         1.5.8-3.el7                                    base                             37 k
 krb5-devel                                  x86_64                         1.15.1-51.el7_9                                updates                         273 k
 libcom_err-devel                            x86_64                         1.42.9-19.el7                                  base                             32 k
 libkadm5                                    x86_64                         1.15.1-51.el7_9                                updates                         179 k
 libmpc                                      x86_64                         1.0.1-3.el7                                    base                             51 k
 libselinux-devel                            x86_64                         2.5-15.el7                                     base                            187 k
 libsepol-devel                              x86_64                         2.5-10.el7                                     base                             77 k
 libverto-devel                              x86_64                         0.2.5-4.el7                                    base                             12 k
 mpfr                                        x86_64                         3.1.1-4.el7                                    base                            203 k
 zlib-devel                                  x86_64                         1.2.7-19.el7_9                                 updates                          50 k
Updating for dependencies:
 glibc                                       x86_64                         2.17-325.el7_9                                 updates                         3.6 M
 glibc-common                                x86_64                         2.17-325.el7_9                                 updates                          12 M
 krb5-libs                                   x86_64                         1.15.1-51.el7_9                                updates                         809 k
 openssl                                     x86_64                         1:1.0.2k-22.el7_9                              updates                         494 k
 openssl-libs                                x86_64                         1:1.0.2k-22.el7_9                              updates                         1.2 M
 zlib                                        x86_64                         1.2.7-19.el7_9                                 updates                          90 k

Transaction Summary
=================================================================================================================================================================
Install  4 Packages (+14 Dependent packages)
Upgrade             (  6 Dependent packages)

Total download size: 54 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/24): expat-devel-2.1.0-12.el7.x86_64.rpm                                                                                               |  57 kB  00:00:00     
(2/24): cpp-4.8.5-44.el7.x86_64.rpm                                                                                                       | 5.9 MB  00:00:00     
(3/24): glibc-2.17-325.el7_9.x86_64.rpm                                                                                                   | 3.6 MB  00:00:00     
(4/24): glibc-headers-2.17-325.el7_9.x86_64.rpm                                                                                           | 691 kB  00:00:00     
(5/24): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm                                                                                        |  37 kB  00:00:00     
(6/24): glibc-devel-2.17-325.el7_9.x86_64.rpm                                                                                             | 1.1 MB  00:00:00     
(7/24): krb5-devel-1.15.1-51.el7_9.x86_64.rpm                                                                                             | 273 kB  00:00:00     
(8/24): krb5-libs-1.15.1-51.el7_9.x86_64.rpm                                                                                              | 809 kB  00:00:00     
(9/24): libkadm5-1.15.1-51.el7_9.x86_64.rpm                                                                                               | 179 kB  00:00:00     
(10/24): libmpc-1.0.1-3.el7.x86_64.rpm                                                                                                    |  51 kB  00:00:00     
(11/24): libselinux-devel-2.5-15.el7.x86_64.rpm                                                                                           | 187 kB  00:00:00     
(12/24): libsepol-devel-2.5-10.el7.x86_64.rpm                                                                                             |  77 kB  00:00:00     
(13/24): libverto-devel-0.2.5-4.el7.x86_64.rpm                                                                                            |  12 kB  00:00:00     
(14/24): mpfr-3.1.1-4.el7.x86_64.rpm                                                                                                      | 203 kB  00:00:00     
(15/24): openssl-1.0.2k-22.el7_9.x86_64.rpm                                                                                               | 494 kB  00:00:00     
(16/24): gcc-4.8.5-44.el7.x86_64.rpm                                                                                                      |  16 MB  00:00:01     
(17/24): openssl-devel-1.0.2k-22.el7_9.x86_64.rpm                                                                                         | 1.5 MB  00:00:00     
(18/24): libcom_err-devel-1.42.9-19.el7.x86_64.rpm                                                                                        |  32 kB  00:00:00     
(19/24): openssl-libs-1.0.2k-22.el7_9.x86_64.rpm                                                                                          | 1.2 MB  00:00:00     
(20/24): zlib-devel-1.2.7-19.el7_9.x86_64.rpm                                                                                             |  50 kB  00:00:00     
(21/24): pcre-devel-8.32-17.el7.x86_64.rpm                                                                                                | 480 kB  00:00:00     
(22/24): zlib-1.2.7-19.el7_9.x86_64.rpm                                                                                                   |  90 kB  00:00:00     
(23/24): glibc-common-2.17-325.el7_9.x86_64.rpm                                                                                           |  12 MB  00:00:01     
(24/24): kernel-headers-3.10.0-1160.49.1.el7.x86_64.rpm                                                                                   | 9.0 MB  00:00:00     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                             38 MB/s |  54 MB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : glibc-2.17-325.el7_9.x86_64                                                                                                                  1/30 
  Updating   : glibc-common-2.17-325.el7_9.x86_64                                                                                                           2/30 
  Updating   : zlib-1.2.7-19.el7_9.x86_64                                                                                                                   3/30 
  Updating   : 1:openssl-libs-1.0.2k-22.el7_9.x86_64                                                                                                        4/30 
  Updating   : krb5-libs-1.15.1-51.el7_9.x86_64                                                                                                             5/30 
  Installing : mpfr-3.1.1-4.el7.x86_64                                                                                                                      6/30 
  Installing : libmpc-1.0.1-3.el7.x86_64                                                                                                                    7/30 
  Installing : cpp-4.8.5-44.el7.x86_64                                                                                                                      8/30 
  Installing : libkadm5-1.15.1-51.el7_9.x86_64                                                                                                              9/30 
  Installing : zlib-devel-1.2.7-19.el7_9.x86_64                                                                                                            10/30 
  Installing : libcom_err-devel-1.42.9-19.el7.x86_64                                                                                                       11/30 
  Installing : kernel-headers-3.10.0-1160.49.1.el7.x86_64                                                                                                  12/30 
  Installing : glibc-headers-2.17-325.el7_9.x86_64                                                                                                         13/30 
  Installing : glibc-devel-2.17-325.el7_9.x86_64                                                                                                           14/30 
  Installing : libverto-devel-0.2.5-4.el7.x86_64                                                                                                           15/30 
  Installing : libsepol-devel-2.5-10.el7.x86_64                                                                                                            16/30 
  Installing : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                                                                      17/30 
  Installing : pcre-devel-8.32-17.el7.x86_64                                                                                                               18/30 
  Installing : libselinux-devel-2.5-15.el7.x86_64                                                                                                          19/30 
  Installing : krb5-devel-1.15.1-51.el7_9.x86_64                                                                                                           20/30 
  Installing : 1:openssl-devel-1.0.2k-22.el7_9.x86_64                                                                                                      21/30 
  Installing : gcc-4.8.5-44.el7.x86_64                                                                                                                     22/30 
  Updating   : 1:openssl-1.0.2k-22.el7_9.x86_64                                                                                                            23/30 
  Installing : expat-devel-2.1.0-12.el7.x86_64                                                                                                             24/30 
  Cleanup    : 1:openssl-1.0.2k-19.el7.x86_64                                                                                                              25/30 
  Cleanup    : 1:openssl-libs-1.0.2k-19.el7.x86_64                                                                                                         26/30 
  Cleanup    : krb5-libs-1.15.1-50.el7.x86_64                                                                                                              27/30 
  Cleanup    : zlib-1.2.7-18.el7.x86_64                                                                                                                    28/30 
  Cleanup    : glibc-common-2.17-317.el7.x86_64                                                                                                            29/30 
  Cleanup    : glibc-2.17-317.el7.x86_64                                                                                                                   30/30 
  Verifying  : libselinux-devel-2.5-15.el7.x86_64                                                                                                           1/30 
  Verifying  : krb5-libs-1.15.1-51.el7_9.x86_64                                                                                                             2/30 
  Verifying  : mpfr-3.1.1-4.el7.x86_64                                                                                                                      3/30 
  Verifying  : pcre-devel-8.32-17.el7.x86_64                                                                                                                4/30 
  Verifying  : zlib-1.2.7-19.el7_9.x86_64                                                                                                                   5/30 
  Verifying  : keyutils-libs-devel-1.5.8-3.el7.x86_64                                                                                                       6/30 
  Verifying  : libsepol-devel-2.5-10.el7.x86_64                                                                                                             7/30 
  Verifying  : libkadm5-1.15.1-51.el7_9.x86_64                                                                                                              8/30 
  Verifying  : libverto-devel-0.2.5-4.el7.x86_64                                                                                                            9/30 
  Verifying  : glibc-devel-2.17-325.el7_9.x86_64                                                                                                           10/30 
  Verifying  : cpp-4.8.5-44.el7.x86_64                                                                                                                     11/30 
  Verifying  : glibc-headers-2.17-325.el7_9.x86_64                                                                                                         12/30 
  Verifying  : glibc-common-2.17-325.el7_9.x86_64                                                                                                          13/30 
  Verifying  : 1:openssl-1.0.2k-22.el7_9.x86_64                                                                                                            14/30 
  Verifying  : gcc-4.8.5-44.el7.x86_64                                                                                                                     15/30 
  Verifying  : krb5-devel-1.15.1-51.el7_9.x86_64                                                                                                           16/30 
  Verifying  : libmpc-1.0.1-3.el7.x86_64                                                                                                                   17/30 
  Verifying  : 1:openssl-devel-1.0.2k-22.el7_9.x86_64                                                                                                      18/30 
  Verifying  : glibc-2.17-325.el7_9.x86_64                                                                                                                 19/30 
  Verifying  : 1:openssl-libs-1.0.2k-22.el7_9.x86_64                                                                                                       20/30 
  Verifying  : expat-devel-2.1.0-12.el7.x86_64                                                                                                             21/30 
  Verifying  : zlib-devel-1.2.7-19.el7_9.x86_64                                                                                                            22/30 
  Verifying  : kernel-headers-3.10.0-1160.49.1.el7.x86_64                                                                                                  23/30 
  Verifying  : libcom_err-devel-1.42.9-19.el7.x86_64                                                                                                       24/30 
  Verifying  : glibc-2.17-317.el7.x86_64                                                                                                                   25/30 
  Verifying  : glibc-common-2.17-317.el7.x86_64                                                                                                            26/30 
  Verifying  : zlib-1.2.7-18.el7.x86_64                                                                                                                    27/30 
  Verifying  : 1:openssl-1.0.2k-19.el7.x86_64                                                                                                              28/30 
  Verifying  : 1:openssl-libs-1.0.2k-19.el7.x86_64                                                                                                         29/30 
  Verifying  : krb5-libs-1.15.1-50.el7.x86_64                                                                                                              30/30 

Installed:
  expat-devel.x86_64 0:2.1.0-12.el7        gcc.x86_64 0:4.8.5-44.el7        openssl-devel.x86_64 1:1.0.2k-22.el7_9        pcre-devel.x86_64 0:8.32-17.el7       

Dependency Installed:
  cpp.x86_64 0:4.8.5-44.el7                                glibc-devel.x86_64 0:2.17-325.el7_9                  glibc-headers.x86_64 0:2.17-325.el7_9            
  kernel-headers.x86_64 0:3.10.0-1160.49.1.el7             keyutils-libs-devel.x86_64 0:1.5.8-3.el7             krb5-devel.x86_64 0:1.15.1-51.el7_9              
  libcom_err-devel.x86_64 0:1.42.9-19.el7                  libkadm5.x86_64 0:1.15.1-51.el7_9                    libmpc.x86_64 0:1.0.1-3.el7                      
  libselinux-devel.x86_64 0:2.5-15.el7                     libsepol-devel.x86_64 0:2.5-10.el7                   libverto-devel.x86_64 0:0.2.5-4.el7              
  mpfr.x86_64 0:3.1.1-4.el7                                zlib-devel.x86_64 0:1.2.7-19.el7_9                  

Dependency Updated:
  glibc.x86_64 0:2.17-325.el7_9             glibc-common.x86_64 0:2.17-325.el7_9     krb5-libs.x86_64 0:1.15.1-51.el7_9     openssl.x86_64 1:1.0.2k-22.el7_9    
  openssl-libs.x86_64 1:1.0.2k-22.el7_9     zlib.x86_64 0:1.2.7-19.el7_9            

Complete!

[root@fastcgi data]# ll
total 54048
-rw-r--r--. 1 root root   872238 Jul  6  2020 apr-1.7.0.tar.bz2
-rw-r--r--. 1 root root   428595 Jul  6  2020 apr-util-1.6.1.tar.bz2
-rw-r--r--. 1 root root 12360394 Dec 22 23:19 Discuz_X3.4_SC_UTF8_20211124.zip
-rw-r--r--. 1 root root  9719976 Dec 20 17:36 httpd-2.4.52.tar.gz
-rw-r--r--. 1 root root 15085301 Nov 11 01:24 latest.tar.gz
-rw-r--r--. 1 root root 16870320 Dec 22 23:12 php-7.4.27.tar.gz
[root@fastcgi data]# tar xf apr-1.7.0.tar.bz2 
[root@fastcgi data]# tar xf apr-util-1.6.1.tar.bz2 
[root@fastcgi data]# tar xf httpd-2.4.52.tar.gz
[root@fastcgi data]# mv apr-1.7.0 httpd-2.4.52/srclib/apr
[root@fastcgi data]# mv apr-util-1.6.1 httpd-2.4.52/srclib/apr-util
[root@fastcgi data]# cd httpd-2.4.52
[root@fastcgi httpd-2.4.52]#./configure \
--prefix=/apps/httpd24 \
--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

[root@fastcgi httpd-2.4.52]# make && make install

[root@fastcgi httpd-2.4.52]# echo 'PATH=/apps/httpd24/bin:$PATH' > /etc/profile.d/lamp.sh
[root@fastcgi httpd-2.4.52]# cat /etc/profile.d/lamp.sh 
PATH=/apps/httpd24/bin:$PATH
[root@fastcgi httpd-2.4.52]# . /etc/profile.d/lamp.sh

[root@fastcgi httpd-2.4.52]# useradd -s /sbin/nologin -r -u 88 apache
[root@fastcgi httpd-2.4.52]# sed -ri 's/^(User ).*/\1apache/' /apps/httpd24/conf/httpd.conf
[root@fastcgi httpd-2.4.52]# cat /apps/httpd24/conf/httpd.conf |grep '^User'
User apache
[root@fastcgi httpd-2.4.52]# sed -ri 's/^(Group ).*/\1apache/' /apps/httpd24/conf/httpd.conf
[root@fastcgi httpd-2.4.52]# cat /apps/httpd24/conf/httpd.conf |grep '^Group'
Group apache

[root@fastcgi httpd-2.4.52]# apachectl start

[root@fastcgi ~]# cat /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 
ExecStart=/apps/httpd24/bin/apachectl start
ExecReload=/apps/httpd24/bin/apachectl graceful
ExecStop=/apps/httpd24/bin/apachectl stop
KillSignal=SIGCONT
PrivateTmp=true 

[Install]
WantedBy=multi-user.target

[root@fastcgi ~]# systemctl daemon-reload
2.4 编译安装 fastcgi 方式的 php 7.4
[root@fastcgi ~]# yum -y install gcc libxml2-devel bzip2-devel libmcrypt-devel sqlite-devel oniguruma-devel
[root@fastcgi data]# tar  xf php-7.4.27.tar.gz
[root@fastcgi data]# cd php-7.4.27
[root@fastcgi php-7.4.27]# ./configure \
> --prefix=/apps/php74 \
> --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

[root@fastcgi php-7.4.27]# make && make install
[root@fastcgi ~]#cd[root@fastcgi ~]#echo 'PATH=/apps/php74/bin:/apps/httpd24/bin:$PATH' >> /etc/profile.d/lamp.sh
[root@fastcgi ~]#. /etc/profile.d/lamp.sh
[root@fastcgi ~]#php --version
PHP 7.4.27 (cli) (built: Jan  4 2022 23:11:05) ( ZTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

#准备php配置文件和启动文件
[root@fastcgi php-7.4.27]# cp php.ini-production /etc/php.ini
[root@fastcgi php-7.4.27]# cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/
[root@fastcgi php-7.4.27]# cd /apps/php74/etc
[root@fastcgi etc]# cp php-fpm.conf.default php-fpm.conf
[root@fastcgi etc]# cd php-fpm.d/
[root@fastcgi php-fpm.d]# cp www.conf.default www.conf

#修改进程所有者
[root@fastcgi php-fpm.d]# sed -ri 's/^(user = ).*/\1apache/'  /apps/php74/etc/php-fpm.d/www.conf
[root@fastcgi php-fpm.d]# sed -ri 's/^(group = ).*/\1apache/'  /apps/php74/etc/php-fpm.d/www.conf
[root@fastcgi php-fpm.d]# grep '^user'  /apps/php74/etc/php-fpm.d/www.conf
user = apache
[root@fastcgi php-fpm.d]# grep '^group'  /apps/php74/etc/php-fpm.d/www.conf
group = apache

#支持status和ping页面
[root@fastcgi php-fpm.d]# sed -ri 's/^;(pm.status_path = .*)/\1/' /apps/php74/etc/php-fpm.d/www.conf
[root@fastcgi php-fpm.d]# grep '^pm.status' /apps/php74/etc/php-fpm.d/www.conf
pm.status_path = /status
[root@fastcgi php-fpm.d]# sed -ri 's/^;(ping.path = .*)/\1/' /apps/php74/etc/php-fpm.d/www.conf
[root@fastcgi php-fpm.d]# grep '^ping.path' /apps/php74/etc/php-fpm.d/www.conf
ping.path = /ping

#支持opcache加速
[root@fastcgi php-fpm.d]# mkdir /etc/php.d/
[root@fastcgi php-fpm.d]# vim /etc/php.d/opcache.ini 
[root@fastcgi php-fpm.d]# cat /etc/php.d/opcache.ini 
[opcache]
zend_extension=opcache.so
opcache.enable=1

[root@fastcgi php-fpm.d]# systemctl daemon-reload 
[root@fastcgi php-fpm.d]# systemctl enable --now php-fpm.service
[root@fastcgi php-fpm.d]# systemctl status php-fpm.service
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2022-01-04 23:23:08 CST; 19s ago
 Main PID: 24932 (php-fpm)
   CGroup: /system.slice/php-fpm.service
           ├─24932 php-fpm: master process (/apps/php74/etc/php-fpm.conf)
           ├─24933 php-fpm: pool www
           └─24934 php-fpm: pool www

Jan 04 23:23:27 fastcgi systemd[1]: [/usr/lib/systemd/system/php-fpm.service:31] Unknown lvalue 'ProtectKernelModules' in section 'Service'
Jan 04 23:23:27 fastcgi systemd[1]: [/usr/lib/systemd/system/php-fpm.service:38] Unknown lvalue 'ProtectKernelTunables' in section 'Service'
Jan 04 23:23:27 fastcgi systemd[1]: [/usr/lib/systemd/system/php-fpm.service:44] Unknown lvalue 'ProtectControlGroups' in section 'Service'
Jan 04 23:23:27 fastcgi systemd[1]: [/usr/lib/systemd/system/php-fpm.service:47] Unknown lvalue 'RestrictRealtime' in section 'Service'
Jan 04 23:23:27 fastcgi systemd[1]: [/usr/lib/systemd/system/php-fpm.service:54] Unknown lvalue 'RestrictNamespaces' in section 'Service'
Jan 04 23:23:27 fastcgi systemd[1]: [/usr/lib/systemd/system/php-fpm.service:31] Unknown lvalue 'ProtectKernelModules' in section 'Service'
Jan 04 23:23:27 fastcgi systemd[1]: [/usr/lib/systemd/system/php-fpm.service:38] Unknown lvalue 'ProtectKernelTunables' in section 'Service'
Jan 04 23:23:27 fastcgi systemd[1]: [/usr/lib/systemd/system/php-fpm.service:44] Unknown lvalue 'ProtectControlGroups' in section 'Service'
Jan 04 23:23:27 fastcgi systemd[1]: [/usr/lib/systemd/system/php-fpm.service:47] Unknown lvalue 'RestrictRealtime' in section 'Service'
Jan 04 23:23:27 fastcgi systemd[1]: [/usr/lib/systemd/system/php-fpm.service:54] Unknown lvalue 'RestrictNamespaces' in section 'Service'
2.5 修改配置 httpd 支持 php-fpm
[root@fastcgi ~]# sed -ri 's/^#(LoadModule proxy_module.*)/\1/' /apps/httpd24/conf/httpd.conf
[root@fastcgi ~]# grep 'LoadModule proxy_module' /apps/httpd24/conf/httpd.conf 
LoadModule proxy_module modules/mod_proxy.so
[root@fastcgi ~]# sed -ri 's/^#(LoadModule proxy_fcgi.*)/\1/' /apps/httpd24/conf/httpd.conf
[root@fastcgi ~]# grep 'LoadModule proxy_fcgi' /apps/httpd24/conf/httpd.conf 
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

# 插入index.php
[root@fastcgi ~]# vim /apps/httpd24/conf/httpd.conf 
<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

# 加入下面三行
AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps
ProxyRequests Off

# 创建虚拟主机
<virtualhost *:80>
  servername blog.test.org
  documentroot /data/wordpress
<directory /data/wordpress>
  require all granted
</directory>
  ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/wordpress/$1
  ProxyPassMatch ^/(fpm_status|ping)$ fcgi://127.0.0.1:9000/$1
  CustomLog "logs/access_wordpress_log" common
</virtualhost>

<virtualhost *:80>
  servername forum.test.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>

[root@fastcgi data]# apachectl restart
AH00112: Warning: DocumentRoot [/data/wordpress] does not exist
AH00112: Warning: DocumentRoot [/data/discuz] does not exist
2.6 准备wordpress和discuz! 相关文件
[root@fastcgi data]# tar xf latest.tar.gz
[root@fastcgi data]# setfacl -R -m u:apache:rwx /data/wordpress/
[root@fastcgi data]# unzip Discuz_X3.4_SC_UTF8_20211124.zip -d Discuz
[root@fastcgi data]# mv Discuz/upload/ /data/discuz
[root@fastcgi data]# setfacl -R -m u:apache:rwx /data/discuz/
2.7 测试访问

vim /etc/hosts
10.0.0.207 blog.test.org forum.test.org


3.通过loganalyzer展示数据库中的日志

3.1 httpd服务器安装php和相关软件包
[root@loganalyzer ~]# yum -y install httpd php-fpm php-mysqlnd php-gd
[root@loganalyzer ~]# systemctl restart httpd php-fpm
[root@loganalyzer ~]# systemctl is-active httpd php-fpm
active
active
3.2 httpd服务器安装 LogAnalyzer
[root@loganalyzer ~]# tar xf loganalyzer-4.1.12.tar.gz 
[root@loganalyzer ~]# mv loganalyzer-4.1.12/src/ /var/www/html/log
[root@loganalyzer ~]# touch /var/www/html/log/config.php
[root@loganalyzer ~]# chmod 666 /var/www/html/log/config.php

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Adorable老犀牛

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值