主頁 > 作業系統 > 編譯安裝基于 fastcgi 模式的多虛擬主機的wordpress和discuz的LAMP架構

編譯安裝基于 fastcgi 模式的多虛擬主機的wordpress和discuz的LAMP架構

2020-10-02 04:31:15 作業系統

實作CentOS 7 編譯安裝基于 fastcgi 模式的多虛擬主機的wordpress和discuz的LAMP架構

目錄
  • 實作CentOS 7 編譯安裝基于 fastcgi 模式的多虛擬主機的wordpress和discuz的LAMP架構
    • 準備環境:
      • 準備軟體版本:
      • 主機名修改用以區分
    • 資料庫服務器
      • 實作資料庫二進制安裝(并加上LAMP需要的配置)
    • websrv服務器端
      • 編譯安裝httpd
      • 編譯安裝fastcgi 方式的 php7.3
      • 部署wordpress和discuz
    • 測驗性能

準備環境:

兩臺主機:
    一臺主機:httpd+php(fastcgi模式)
    一臺主機:mariadb 服務器

準備軟體版本:

mariadb-10.2.27-linux-x86_64.tar.gz 通用二進制格式
apr-1.7.0.tar.bz2
apr-util-1.6.1.tar.bz2
httpd-2.4.41.tar.gz
php-7.4.0.tar.xz
wordpress-5.3-zh_CN.tar.gz
Discuz_X3.4_SC_UTF8【20190917】.zip

主機名修改用以區分

# 作為httpd和php服務器使用
[root@centos7 ~]$hostname websrv
[root@centos7 ~]$exit
[root@websrv ~]$
# 作為資料庫使用
[root@centos7 ~]$hostname mysql
[root@centos7 ~]$exit
[root@mysql ~]$

資料庫服務器

實作資料庫二進制安裝(并加上LAMP需要的配置)

  1. 準備好二進制mariadb安裝包
[root@centos7 data]$ll
total 449668
-rw-r--r-- 1 root root 460459738 Sep 12 09:08 mariadb-10.2.27-linux-x86_64.tar.gz
  1. 解壓安裝包
[root@centos7 data]$tar xvf mariadb-10.2.27-linux-x86_64.tar.gz
[root@centos7 data]$ll
total 449668
drwxrwxr-x 12 yang yang       282 Sep 10 02:02 mariadb-10.2.27-linux-x86_64
-rw-r--r--  1 root root 460459738 Sep 12 09:08 mariadb-10.2.27-linux-x86_64.tar.gz
  1. 把解壓后的資料庫目錄移動到usr/local下統一管理
[root@centos7 data]$mv mariadb-10.2.27-linux-x86_64 /usr/local/  # 移動
 
[root@centos7 local]$ln -s /usr/local/mariadb-10.2.27-linux-x86_64/ /usr/local/mysql  # 創建軟連接
[root@centos7 local]$ll /usr/local/mysql
lrwxrwxrwx 1 root root 40 Dec 15 14:44 /usr/local/mysql -> /usr/local/mariadb-10.2.27-linux-x86_64/
  1. 創建服務用戶,并修改mysql目錄下的權限,
[root@centos7 data]$useradd -s /sbin/nologin -d /data/mysql -r -u 306 mysql   # 創建服務用戶

[root@centos7 local]$chown -R root.root mysql/*   # 修改為root
[root@centos7 local]$ll mysql/
total 176
drwxrwxr-x  2 root root  4096 Aug 14 02:55 bin
-rw-r--r--  1 root root 17987 Sep  8 21:25 COPYING
-rw-r--r--  1 root root  2354 Sep  8 21:25 CREDITS
drwxrwxr-x  3 root root    18 Sep 10 02:02 data
-rw-r--r--  1 root root  8245 Sep  8 21:25 EXCEPTIONS-CLIENT
drwxrwxr-x  3 root root    19 Sep 10 02:02 include
-rw-r--r--  1 root root  8694 Sep  8 21:25 INSTALL-BINARY
drwxrwxr-x  5 root root   335 Aug 14 02:55 lib
drwxrwxr-x  4 root root    30 Sep 10 02:02 man
drwxrwxr-x 11 root root  4096 Sep 10 02:02 mysql-test
-rw-r--r--  1 root root  2843 Sep  8 21:25 README.md
-rw-r--r--  1 root root 19477 Sep  8 21:25 README-wsrep
drwxrwxr-x  2 root root    30 Sep 10 02:02 scripts
drwxrwxr-x 32 root root  4096 Sep 10 02:02 share
drwxrwxr-x  4 root root  4096 Sep 10 02:02 sql-bench
drwxrwxr-x  3 root root   275 Sep 10 02:02 support-files
-rw-r--r--  1 root root 86263 Sep  8 21:25 THIRDPARTY
  1. 創建資料庫
[root@centos7 mysql]$/usr/local/mysql/scripts/mysql_install_db --datadir=/data/mysql --user=mysql
Installing MariaDB/MySQL system tables in '/data/mysql' ...
./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
# 創建資料庫時缺少包(libaio)

[root@centos7 mysql]$yum install libaio -y  # 下載依賴包

[root@centos7 mysql]$/usr/local/mysql/scripts/mysql_install_db --datadir=/data/mysql --user=mysql  # 創建資料庫(/data下沒有這個目錄會自動創建)

[root@centos7 mysql]$ll /data/
total 449668
-rw-r--r-- 1 root  root 460459738 Sep 12 09:08 mariadb-10.2.27-linux-x86_64.tar.gz
drwx------ 5 mysql root       181 Dec 15 14:55 mysql       # 資料庫創建成功

[root@centos7 mysql]$ll /data/mysql/   # 查看用戶和所屬組
total 110620
-rw-rw---- 1 mysql mysql    16384 Dec 15 14:55 aria_log.00000001
-rw-rw---- 1 mysql mysql       52 Dec 15 14:55 aria_log_control
-rw-rw---- 1 mysql mysql      938 Dec 15 14:55 ib_buffer_pool
-rw-rw---- 1 mysql mysql 12582912 Dec 15 14:55 ibdata1
-rw-rw---- 1 mysql mysql 50331648 Dec 15 14:55 ib_logfile0
-rw-rw---- 1 mysql mysql 50331648 Dec 15 14:55 ib_logfile1
drwx------ 2 mysql mysql     4096 Dec 15 14:55 mysql
drwx------ 2 mysql mysql       20 Dec 15 14:55 performance_schema
drwx------ 2 mysql mysql       20 Dec 15 14:55 test
  1. 準備組態檔(指明資料庫路徑)
[root@centos7 ~]$cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf -b  # 找到解壓目錄下的組態檔替換掉/etc下的組態檔并備份
cp: overwrite ‘/etc/my.cnf’? y
# 原系統/etc下就有一個my.cnf的組態檔但是需要改配置


[root@centos7 mysql]$vim /etc/my.cnf
[mysqld]
datadir=/data/mysql   # 加上這一行就夠了 (需要啟用二進制日志啊之類的根據需要啟動)
如果上一步cp沒做直接用的自帶的檔案,注意sock路經,(服務可能起不來是因為啟動過一次之后系統建立了一個sock路徑但是用的是系統自帶的組態檔建立的路徑,你在拷貝組態檔過去后一定要確保沒有啟動過服務,如果啟動過請重啟電腦或刪掉舊的組態檔建立的sock檔案再啟動服務)

在這里插入圖片描述
6. 制作啟動服務(類似于centos6的啟動腳本)

[root@centos7 mysql]$cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld  # 拷貝目錄下的server啟動腳本到

[root@centos7 mysql]$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]'.

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

[root@centos7 mysql]$chkconfig --add mysqld   # 添加服務

[root@centos7 mysql]$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   # 添加上了
  1. 添加PATH變數
[root@centos7 ~]$echo "PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh 
[root@centos7 ~]$. /etc/profile.d/mysql.sh
  1. 創建部署軟體需要的資料庫和用戶并授權
# 創建資料庫
MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.00 sec)

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

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| discuz             |
| information_schema |
| mysql              |
| performance_schema |
| test               |
| wordpress          |
+--------------------+
6 rows in set (0.00 sec)

# 創建用戶并授權
MariaDB [(none)]> grant all on wordpress.* to wordpress@'192.168.39.%' identified by 'taotaobao';

Query OK, 0 rows affected (0.00 sec)

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

MariaDB [(none)]> select user,host,password from mysql.user;   # 查看創建的賬戶
+-----------+--------------+-------------------------------------------+
| user      | host         | password                                  |
+-----------+--------------+-------------------------------------------+
| root      | localhost    |                                           |
| root      | centos7      |                                           |
| root      | 127.0.0.1    |                                           |
| root      | ::1          |                                           |
|           | localhost    |                                           |
|           | centos7      |                                           |
| wordpress | 192.168.39.% | *114893F4494D9D1D5AE2BCCACDD663C08715DA05 |
| discuz    | 192.168.39.% | *114893F4494D9D1D5AE2BCCACDD663C08715DA05 |
+-----------+--------------+-------------------------------------------+
8 rows in set (0.00 sec)
資料庫需要的基本配置完畢

websrv服務器端

  • websrv端需要的包
[root@centos7 ~]$ll
total 43984
-rw-r--r--  1 root root   872238 May 14  2019 apr-1.7.0.tar.bz2
-rw-r--r--  1 root root   428595 May 14  2019 apr-util-1.6.1.tar.bz2
-rw-r--r--  1 root root 11800498 Dec 12 14:57 Discuz_X3.4_SC_UTF8【20191201】.zip
-rw-r--r--  1 root root  9267917 Oct  8 15:10 httpd-2.4.41.tar.gz
-rw-r--r--  1 root root 10232208 Dec 14 08:30 php-7.4.0.tar.xz
-rw-r--r--  1 root root 12423575 Dec 12 14:18 wordpress-5.3-zh_CN.tar.gz

編譯安裝httpd

  1. 解壓httpd和apr包
[root@centos7 data]$ll
total 10324
-rw-r--r-- 1 root root  872238 May 14  2019 apr-1.7.0.tar.bz2
-rw-r--r-- 1 root root  428595 May 14  2019 apr-util-1.6.1.tar.bz2
-rw-r--r-- 1 root root 9267917 Oct  8 15:10 httpd-2.4.41.tar.gz

[root@centos7 data]$tar xvf apr-1.7.0.tar.bz2   # 最小化安裝缺少包
tar (child): cannot run bzip2: No such file or directory
tar (child): trying lbzip2
tar (child): lbzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

[root@centos7 data]$yum install bzip2 # 下載解壓需要的包

# 解壓
[root@centos7 data]$tar xvf apr-1.7.0.tar.bz2 
[root@centos7 data]$tar xvf apr-util-1.6.1.tar.bz2 
[root@centos7 data]$tar xvf httpd-2.4.41.tar.gz

[root@centos7 data]$ll
total 10336
drwxr-xr-x 27 1001 1001    4096 Apr  2  2019 apr-1.7.0
-rw-r--r--  1 root root  872238 May 14  2019 apr-1.7.0.tar.bz2
drwxr-xr-x 20 1001 1001    4096 Oct 18  2017 apr-util-1.6.1
-rw-r--r--  1 root root  428595 May 14  2019 apr-util-1.6.1.tar.bz2
drwxr-sr-x 11 root   40    4096 Aug  9 21:36 httpd-2.4.41
-rw-r--r--  1 root root 9267917 Oct  8 15:10 httpd-2.4.41.tar.gz
  1. 合并三個目錄一起編譯
[root@centos7 data]$mv apr-1.7.0 httpd-2.4.41/srclib/apr
[root@centos7 data]$mv apr-util-1.6.1 httpd-2.4.41/srclib/apr-util
  1. 下載相關依賴包
[root@centos7 data]$yum install gcc pcre-devel openssl-devel expat-devel -y
  1. 進入目錄下進行編譯安裝
[root@centos7 data]$cd httpd-2.4.41/  # 進入目錄
[root@centos7 httpd-2.4.41]$./configure \
> --prefix=/app/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=prefork

[root@centos7 httpd-2.4.41]$make -j 4 && make install   # 制作安裝

  1. 準備PATH變數
[root@centos7 httpd-2.4.41]$echo 'PATH=/app/httpd24/bin:$PATH' > /etc/profile.d/lamp.sh  # 添加變數
[root@centos7 httpd-2.4.41]$. /etc/profile.d/lamp.sh   # 加載變數

[root@centos7 httpd-2.4.41]$echo $PATH  # 查看變數
/app/httpd24/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

  1. 創建apache賬戶
# 作業中最好指明UID,UID要統一.
[root@centos7 httpd-2.4.41]$useradd -s /sbin/nologin -r -u 88 apache
  1. 修改httpd組態檔
[root@centos7 httpd-2.4.41]$vim /app/httpd24/conf/httpd.conf
<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User apache   # 默認為daemon監管改為apache
Group apache  # 同上

</IfModule>

# 網站主頁面定義為/data/(隨自己需求)
DocumentRoot "/data/"
<Directory "/data/">

  1. 啟動服務
[root@centos7 httpd-2.4.41]$apachectl restart    
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:feac:5484%eth0. Set the 'ServerName' directive globally to suppress this message
httpd not running, trying to start   

[root@centos7 httpd-2.4.41]$ss -ntlup
Netid State      Recv-Q Send-Q                                               Local Address:Port                                                              Peer Address:Port              
tcp   LISTEN     0      128                                                              *:22                                                                           *:*                   users:(("sshd",pid=6461,fd=3))
tcp   LISTEN     0      100                                                      127.0.0.1:25                                                                           *:*                   users:(("master",pid=6581,fd=13))
tcp   LISTEN     0      128                                                             :::80                                                                          :::*                   users:(("httpd",pid=49496,fd=4),("httpd",pid=49495,fd=4),("httpd",pid=49494,fd=4),("httpd",pid=49493,fd=4),("httpd",pid=49492,fd=4),("httpd",pid=49491,fd=4))
tcp   LISTEN     0      128                                                             :::22                                                                          :::*                   users:(("sshd",pid=6461,fd=4))
tcp   LISTEN     0      100                                                            ::1:25                                                                          :::*                   users:(("master",pid=6581,fd=14))
  1. 修改ServerName配置不在提示
[root@centos7 httpd-2.4.41]$vim /app/httpd24/conf/httpd.conf
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName www.example.com:80   # 這一行取消注釋,名字是什么都可以,

[root@centos7 httpd-2.4.41]$apachectl restart   # 不在提示
[root@centos7 httpd-2.4.41]$
  1. 修改為event模式
[root@centos7 httpd-2.4.41]$vim /app/httpd24/conf/httpd.conf 
#  默認centos7為prefork模式,所以需要修改
LoadModule mpm_event_module modules/mod_mpm_event.so    # 取消注釋啟用
#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so # 加上注釋禁用
#LoadModule mpm_worker_module modules/mod_mpm_worker.so

[root@centos7 httpd-2.4.41]$apachectl restart
  1. 可以根據需求調節這些配置對應生產調到生產中最大值
[root@centos7 httpd-2.4.41]$vim /app/httpd24/conf/extra/httpd-mpm.conf
# event MPM
# StartServers: initial number of server processes to start
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestWorkers: maximum number of worker threads
# MaxConnectionsPerChild: maximum number of connections a server process serves
#                         before terminating
<IfModule mpm_event_module>
    StartServers             3
    MinSpareThreads         75
    MaxSpareThreads        250
    ThreadsPerChild         25
    MaxRequestWorkers      400
    MaxConnectionsPerChild   0
</IfModule>
現在httpd服務已經可以訪問了!

web界面測驗訪問(it works! 是默認顯示)
在這里插入圖片描述

編譯安裝fastcgi 方式的 php7.3

  • php7.3和php7.4依賴包稍有差別
#安裝相關包,依賴EPEL源
#php 7.3 相關包
yum install gcc libxml2-devel bzip2-devel libmcrypt-devel
#php 7.4 相關包
yum install gcc libxml2-devel bzip2-devel libmcrypt-devel sqlite-devel
oniguruma-devel
  1. 安裝依賴包
[root@centos7 data]$yum install gcc libxml2-devel bzip2-devel libmcrypt-devel sqlite-devel oniguruma-devel
  1. 解壓php編譯安裝包
[root@centos7 data]$tar xvf php-7.4.0.tar.xz 
[root@centos7 data]$ll
total 20328
-rw-r--r--  1 root root   872238 May 14  2019 apr-1.7.0.tar.bz2
-rw-r--r--  1 root root   428595 May 14  2019 apr-util-1.6.1.tar.bz2
drwxr-sr-x 12 root   40     4096 Dec 15 16:14 httpd-2.4.41
-rw-r--r--  1 root root  9267917 Oct  8 15:10 httpd-2.4.41.tar.gz
drwxrwxr-x 16 root root     4096 Nov 27 04:13 php-7.4.0     # 解壓完的目錄
-rw-r--r--  1 root root 10232208 Dec 14 08:30 php-7.4.0.tar.xz
  1. 進入php目錄下進行編譯
# 7.4編譯方式
[root@centos7 data]$cd php-7.4.0/
[root@centos7 data]$./configure \
--prefix=/app/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@centos7 data]$make -j 4 && make install

[root@centos7 php-7.4.0]$/app/php74/bin/php --version   # 查看版本號
PHP 7.4.0 (cli) (built: Dec 15 2019 17:15:08) ( ZTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies   # 這行是引擎版本


# 7.3編譯方式
./configure --prefix=/app/php73 \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--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
  1. 準備PATH變數
# 修改之前準備好的變數
[root@centos7 php-7.4.0]$vim /etc/profile.d/lamp.sh
PATH=/app/httpd24/bin:/app/php/bin/:$PATH     
[root@centos7 php-7.4.0]$. /etc/profile.d/lamp.sh
  1. 準備php組態檔
[root@centos7 php-7.4.0]$cp php.ini-production /etc/php.ini
  1. 準本fastcgi(fpm)主組態檔(改名=啟用)
[root@centos7 php-7.4.0]$cd /app/php74/etc/
[root@centos7 etc]$cp php-fpm.conf.default php-fpm.conf
[root@centos7 etc]$ll
total 16
-rw-r--r-- 1 root root 5357 Dec 15 17:28 php-fpm.conf
-rw-r--r-- 1 root root 5357 Dec 15 17:15 php-fpm.conf.default
drwxr-xr-x 2 root root   30 Dec 15 17:15 php-fpm.d
  1. 子組態檔fpm改名
[root@centos7 etc]$cd php-fpm.d/
[root@centos7 php-fpm.d]$ll
total 20
-rw-r--r-- 1 root root 19602 Dec 15 17:15 www.conf.default
[root@centos7 php-fpm.d]$cp www.conf.default www.conf
  1. 修改fpm子組態檔
[root@centos7 php-fpm.d]$vim www.conf
# 修改為apache,以apache的身份來創建fastcgi的行程
user = apache
group = apache
# 開啟狀態頁
; Default Value: not set
pm.status_path = /status
# 開啟ping測驗
; Default Value: not set
ping.path = /ping
  1. 準備啟動腳本
# 查找一下啟動腳本
[root@centos7 php74]$updatedb
[root@centos7 php74]$locate php-fpm
/app/php74/etc/php-fpm.conf
/app/php74/etc/php-fpm.conf.default
/app/php74/etc/php-fpm.d
/app/php74/etc/php-fpm.d/www.conf
/app/php74/etc/php-fpm.d/www.conf.default
/app/php74/php/man/man8/php-fpm.8
/app/php74/sbin/php-fpm
/data/php-7.4.0/sapi/fpm/init.d.php-fpm
/data/php-7.4.0/sapi/fpm/init.d.php-fpm.in
/data/php-7.4.0/sapi/fpm/php-fpm
/data/php-7.4.0/sapi/fpm/php-fpm.8
/data/php-7.4.0/sapi/fpm/php-fpm.8.in
/data/php-7.4.0/sapi/fpm/php-fpm.conf
/data/php-7.4.0/sapi/fpm/php-fpm.conf.in
/data/php-7.4.0/sapi/fpm/php-fpm.service
/data/php-7.4.0/sapi/fpm/php-fpm.service.in

# 拷貝過去作為啟動檔案
[root@centos7 php74]$cp /data/php-7.4.0/sapi/fpm/php-fpm.service /usr/lib/system
d/system

# 重新加載服務
[root@centos7 php74]$systemctl daemon-reload
  1. 修改配置httpd 支持php-fpm
# 啟用代理
#LoadModule remoteip_module modules/mod_remoteip.so
LoadModule proxy_module modules/mod_proxy.so    # 啟用
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so  # 啟用

# 添加index.php
<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

# 添加這三行
AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    ProxyRequests Off

# 多虛擬主機和status啟用
<virtualhost *:80>
servername wordpress.atotaobao.org
documentroot /data/wordpress
<directory /data/wordpress>
require all granted
</directory>
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/wordpress/$1

ProxyPassMatch ^/(status|ping)$ fcgi://127.0.0.1:9000/$1
CustomLog "logs/access_wordpress_log" common
</virtualhost>

<virtualhost *:80>
servername discuz.taotaobao.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>
  1. 創建部署軟體需要的目錄并建立一個測驗php檔案測驗使用
[root@centos7 php74]$mkdir /data/wordpress
[root@centos7 php74]$mkdir /data/discuz

[root@centos7 php74]$vim /data/discuz/test.php
<?php
phpinfo();
?>

[root@centos7 php74]$cp /data/discuz/test.php /data/wordpress/
  • windows更改host檔案
    在這里插入圖片描述
  • 添加這一行對應虛擬主機的域名和虛擬機ip
    在這里插入圖片描述
  • web界面測驗
    在這里插入圖片描述
  • web狀態頁測驗
    在這里插入圖片描述
  • web界面ping測驗
    在這里插入圖片描述
  1. 準備opcache加速
  • 查找opcache.so模塊路徑
[root@centos7 wordpress]$locate opcache.so
/app/php74/lib/php/extensions/no-debug-zts-20190902/opcache.so   # 這個是opcache加速模塊 
/data/php-7.4.0/ext/opcache/.libs/opcache.so
/data/php-7.4.0/modules/opcache.so

# 這三個檔案是一樣的只是在不同目錄里作用不同
[root@centos7 wordpress]$ll /app/php74/lib/php/extensions/no-debug-zts-20190902/opcache.so
-rwxr-xr-x 1 root root 2491984 Dec 15 17:15 /app/php74/lib/php/extensions/no-debug-zts-20190902/opcache.so
[root@centos7 wordpress]$ll /data/php-7.4.0/ext/opcache/.libs/opcache.so
-rwxr-xr-x 1 root root 2491984 Dec 15 17:15 /data/php-7.4.0/ext/opcache/.libs/opcache.so
[root@centos7 wordpress]$ll /data/php-7.4.0/modules/opcache.so
-rwxr-xr-x 1 root root 2491984 Dec 15 17:15 /data/php-7.4.0/modules/opcache.so
  • 準備加速插件檔案(用來加速php處理動態資源)
[root@centos7 wordpress]$mkdir /etc/php.d/
[root@centos7 wordpress]$vim /etc/php.d/opcache.ini
[opcache]
zend_extension=opcache.so
#zend_extension=/app/php74/lib/php/extensions/no-debug-zts-20190902/opcache.so
opcache.enable=1   # 1 啟用   0 關閉

# 路徑以寫全也可以只寫模塊名都可以找到,

[root@centos7 wordpress]$systemctl restart php-fpm.service  # 重啟服務

部署wordpress和discuz

  1. 解壓wordpress
[root@centos7 wordpress]$rm -rf /data/wordpress/   # wordpress 不用準備目錄里面的所有檔案都需要
[root@centos7 data]$ll
total 32464
-rw-r--r--  1 root root   872238 May 14  2019 apr-1.7.0.tar.bz2
-rw-r--r--  1 root root   428595 May 14  2019 apr-util-1.6.1.tar.bz2
drwxr-xr-x  2 root root       22 Dec 15 18:23 discuz
drwxr-sr-x 12 root   40     4096 Dec 15 16:14 httpd-2.4.41
-rw-r--r--  1 root root  9267917 Oct  8 15:10 httpd-2.4.41.tar.gz
drwxrwxr-x 19 root root     4096 Dec 15 17:11 php-7.4.0
-rw-r--r--  1 root root 10232208 Dec 14 08:30 php-7.4.0.tar.xz
-rw-r--r--  1 root root 12423575 Dec 12 14:18 wordpress-5.3-zh_CN.tar.gz


[root@centos7 data]$tar xvf wordpress-5.3-zh_CN.tar.gz  # 解壓
[root@centos7 data]$ll
total 32468
-rw-r--r--  1 root root   872238 May 14  2019 apr-1.7.0.tar.bz2
-rw-r--r--  1 root root   428595 May 14  2019 apr-util-1.6.1.tar.bz2
drwxr-xr-x  2 root root       22 Dec 15 18:23 discuz
drwxr-sr-x 12 root   40     4096 Dec 15 16:14 httpd-2.4.41
-rw-r--r--  1 root root  9267917 Oct  8 15:10 httpd-2.4.41.tar.gz
drwxrwxr-x 19 root root     4096 Dec 15 17:11 php-7.4.0
-rw-r--r--  1 root root 10232208 Dec 14 08:30 php-7.4.0.tar.xz
drwxr-xr-x  5 1006 1006     4096 Nov 14 09:00 wordpress
-rw-r--r--  1 root root 12423575 Dec 12 14:18 wordpress-5.3-zh_CN.tar.gz

  1. 解壓discuz
[root@centos7 data]$unzip wordpress-5.3-zh_CN.tar.gz   # 解壓沒有這個解壓軟體
-bash: unzip: command not found
[root@centos7 data]$yum install unzip    # 下載解壓軟體

[root@centos7 ~]$unzip Discuz_X3.4_SC_UTF8【20191201】.zip -d /opt  # 指定目錄安裝因為有的東西不能放在網站主頁目錄下

[root@centos7 ~]$rm -f /data/discuz/test.php   # 洗掉之前的測驗檔案
[root@centos7 ~]$mv /opt/upload/* /data/discuz/  # 把upload下的所有檔案移動到discuz目錄下
  1. 修改權限
[root@centos7 ~]$cd /data/
[root@centos7 data]$chown -R apache.apache discuz/ wordpress

web界面測驗wordpress
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
web界面測驗discuz
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

測驗性能

  1. 找一臺虛擬機當客戶端,現在客戶端添加主機頭決議,
[root@centos ~]# vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.39.7 wordpress.taotaobao.org discuz.taotaobao.org  # 添加這一行就行了
  1. 使用ab命令測驗
# 如果沒有這個命令下載這個包
[root@centos ~]# yum install httpd-tools

[root@centos ~]# ab -c 10 -n 100 http://wordpress.taotaobao.org/  # 測驗
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking wordpress.taotaobao.org (be patient)...^[[A..done


Server Software:        Apache/2.4.41
Server Hostname:        wordpress.taotaobao.org
Server Port:            80

Document Path:          /
Document Length:        27338 bytes


# 第一次測驗
Concurrency Level:      10
Time taken for tests:   1.936 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      2759700 bytes
HTML transferred:       2733800 bytes
Requests per second:    51.66 [#/sec] (mean)   # 主要看這行多測驗幾遍取平均值
Time per request:       193.561 [ms] (mean)
Time per request:       19.356 [ms] (mean, across all concurrent requests)
Transfer rate:          1392.34 [Kbytes/sec] received


# 第二次測驗
Concurrency Level:      10
Time taken for tests:   1.117 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      2759700 bytes
HTML transferred:       2733800 bytes
Requests per second:    89.51 [#/sec] (mean)
Time per request:       111.724 [ms] (mean)
Time per request:       11.172 [ms] (mean, across all concurrent requests)
Transfer rate:          2412.21 [Kbytes/sec] received




# 第三次測驗
Concurrency Level:      10
Time taken for tests:   0.840 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      2759700 bytes
HTML transferred:       2733800 bytes
Requests per second:    119.09 [#/sec] (mean)
Time per request:       83.967 [ms] (mean)
Time per request:       8.397 [ms] (mean, across all concurrent requests)
Transfer rate:          3209.61 [Kbytes/sec] received

  1. 關閉opcache加速,測驗,
# websrv服務端修改
[root@centos7 ~]$vim /etc/php.d/opcache.ini
opcache.enable=0   # 這一項修改為0

[root@centos7 ~]$systemctl restart php-fpm.service # 重啟服務或重新加載

# 測驗第一次
Concurrency Level:      10
Time taken for tests:   3.421 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      2759700 bytes
HTML transferred:       2733800 bytes
Requests per second:    29.23 [#/sec] (mean)
Time per request:       342.077 [ms] (mean)
Time per request:       34.208 [ms] (mean, across all concurrent requests)
Transfer rate:          787.84 [Kbytes/sec] received

# 測驗第二次
Concurrency Level:      10
Time taken for tests:   2.786 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      2759700 bytes
HTML transferred:       2733800 bytes
Requests per second:    35.89 [#/sec] (mean)
Time per request:       278.639 [ms] (mean)
Time per request:       27.864 [ms] (mean, across all concurrent requests)
Transfer rate:          967.21 [Kbytes/sec] received

# 測驗第三次
Concurrency Level:      10
Time taken for tests:   2.806 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      2759700 bytes
HTML transferred:       2733800 bytes
Requests per second:    35.64 [#/sec] (mean)
Time per request:       280.607 [ms] (mean)
Time per request:       28.061 [ms] (mean, across all concurrent requests)
Transfer rate:          960.43 [Kbytes/sec] received
結論:加速與不加速性能可能相差三倍

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/147222.html

標籤:Linux

上一篇:Seafile對接Amazon S3存盤后端

下一篇:如何在Ubuntu上給軟體創建快捷方式

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • CA和證書

    1、在 CentOS7 中使用 gpg 創建 RSA 非對稱密鑰對 gpg --gen-key #Centos上生成公鑰/密鑰對(存放在家目錄.gnupg/) 2、將 CentOS7 匯出的公鑰,拷貝到 CentOS8 中,在 CentOS8 中使用 CentOS7 的公鑰加密一個檔案 gpg -a ......

    uj5u.com 2020-09-10 00:09:53 more
  • Kubernetes K8S之資源控制器Job和CronJob詳解

    Kubernetes的資源控制器Job和CronJob詳解與示例 ......

    uj5u.com 2020-09-10 00:10:45 more
  • VMware下安裝CentOS

    VMware下安裝CentOS 一、軟硬體準備 1 Centos鏡像準備 1.1 CentOS鏡像下載地址 下載地址 1.2 CentOS鏡像下載程序 點擊下載地址進入如下圖的網站,選擇需要下載的版本,這里選擇的是Centos8,點擊如圖所示。 決定選擇Centos8后,選擇想要的鏡像源進行下載,此 ......

    uj5u.com 2020-09-10 00:12:10 more
  • 如何使用Grep命令查找多個字串

    如何使用Grep 命令查找多個字串 大家好,我是良許! 今天向大家介紹一個非常有用的技巧,那就是使用 grep 命令查找多個字串。 簡單介紹一下,grep 命令可以理解為是一個功能強大的命令列工具,可以用它在一個或多個輸入檔案中搜索與正則運算式相匹配的文本,然后再將每個匹配的文本用標準輸出的格式 ......

    uj5u.com 2020-09-10 00:12:28 more
  • git配置http代理

    git配置http代理 經常遇到克隆 github 慢的問題,這里記錄一下幾種配置 git 代理的方法,解決 clone github 過慢。 目錄 git配置代理 git單獨配置github代理 git配置全域代理 配置終端環境變數 git配置代理 主要使用 git config 命令 git單獨 ......

    uj5u.com 2020-09-10 00:12:33 more
  • Linux npm install 裝包時提示Error EACCES permission denied解

    npm install 裝包時提示Error EACCES permission denied解決辦法 ......

    uj5u.com 2020-09-10 00:12:53 more
  • Centos 7下安裝nginx,使用yum install nginx,提示沒有可用的軟體包

    Centos 7下安裝nginx,使用yum install nginx,提示沒有可用的軟體包。 18 (flaskApi) [root@67 flaskDemo]# yum -y install nginx 19 已加載插件:fastestmirror, langpacks 20 Loading ......

    uj5u.com 2020-09-10 00:13:13 more
  • Linux查看服務器暴力破解ssh IP

    在公網的服務器上經常遇到別人爆破你服務器的22埠,用來挖礦或者干其他嘿嘿嘿的事情~ 這種情況下正確的做法是: 修改默認ssh的22埠 使用設定密鑰登錄或者白名單ip登錄 建議服務器密碼為復雜密碼 創建普通用戶登錄服務器(root權限過大) 建立堡壘機,實作統一管理服務器 統計爆破IP [root ......

    uj5u.com 2020-09-10 00:13:17 more
  • CentOS 7系統常見快捷鍵操作方式

    Linux系統中一些常見的快捷方式,可有效提高操作效率,在某些時刻也能避免操作失誤帶來的問題。 ......

    uj5u.com 2020-09-10 00:13:31 more
  • CentOS 7作業系統目錄結構介紹

    作業系統存在著大量的資料檔案資訊,相應檔案資訊會存在于系統相應目錄中,為了更好的管理資料資訊,會將系統進行一些目錄規劃,不同目錄存放不同的資源。 ......

    uj5u.com 2020-09-10 00:13:35 more
最新发布
  • vim的常用命令

    Vim的6種基本模式 1. 普通模式在普通模式中,用的編輯器命令,比如移動游標,洗掉文本等等。這也是Vim啟動后的默認模式。這正好和許多新用戶期待的操作方式相反(大多數編輯器默認模式為插入模式)。 2. 插入模式在這個模式中,大多數按鍵都會向文本緩沖中插入文本。大多數新用戶希望文本編輯器編輯程序中一 ......

    uj5u.com 2023-04-20 08:43:21 more
  • vim的常用命令

    Vim的6種基本模式 1. 普通模式在普通模式中,用的編輯器命令,比如移動游標,洗掉文本等等。這也是Vim啟動后的默認模式。這正好和許多新用戶期待的操作方式相反(大多數編輯器默認模式為插入模式)。 2. 插入模式在這個模式中,大多數按鍵都會向文本緩沖中插入文本。大多數新用戶希望文本編輯器編輯程序中一 ......

    uj5u.com 2023-04-20 08:42:36 more
  • docker學習

    ###Docker概述 真實專案部署環境可能非常復雜,傳統發布專案一個只需要一個jar包,運行環境需要單獨部署。而通過Docker可將jar包和相關環境(如jdk,redis,Hadoop...)等打包到docker鏡像里,將鏡像發布到Docker倉庫,部署時下載發布的鏡像,直接運行發布的鏡像即可。 ......

    uj5u.com 2023-04-19 09:26:53 more
  • 設定Windows主機的瀏覽器為wls2的默認瀏覽器

    這里以Chrome為例。 1. 準備作業 wsl是可以使用Windows主機上安裝的exe程式,出于安全考慮,默認情況下改功能是無法使用。要使用的話,終端需要以管理員權限啟動。 我這里以Windows Terminal為例,介紹如何默認使用管理員權限打開終端,具體操作如下圖所示: 2. 操作 wsl ......

    uj5u.com 2023-04-19 09:25:49 more
  • docker學習

    ###Docker概述 真實專案部署環境可能非常復雜,傳統發布專案一個只需要一個jar包,運行環境需要單獨部署。而通過Docker可將jar包和相關環境(如jdk,redis,Hadoop...)等打包到docker鏡像里,將鏡像發布到Docker倉庫,部署時下載發布的鏡像,直接運行發布的鏡像即可。 ......

    uj5u.com 2023-04-19 09:19:04 more
  • Linux學習筆記

    IP地址和主機名 IP地址 ifconfig可以用來查詢本機的IP地址,如果不能使用,可以通過install net-tools安裝。 Centos系統下ens33表示主網卡;inet后表示IP地址;lo表示本地回環網卡; 127.0.0.1表示代指本機;0.0.0.0可以用于代指本機,同時在放行設 ......

    uj5u.com 2023-04-18 06:52:01 more
  • 解決linux系統的kdump服務無法啟動的問題

    問題:專案麒麟系統服務器的kdump服務無法啟動,沒有相關日志無法定位問題。 1、查看服務狀態是關閉的,重啟系統也無法啟動 systemctl status kdump 2、修改grub引數,修改“crashkernel”為“512M(有的機器數值太大太小都會導致報錯,建議從128M開始試,或者加個 ......

    uj5u.com 2023-04-12 09:59:50 more
  • 解決linux系統的kdump服務無法啟動的問題

    問題:專案麒麟系統服務器的kdump服務無法啟動,沒有相關日志無法定位問題。 1、查看服務狀態是關閉的,重啟系統也無法啟動 systemctl status kdump 2、修改grub引數,修改“crashkernel”為“512M(有的機器數值太大太小都會導致報錯,建議從128M開始試,或者加個 ......

    uj5u.com 2023-04-12 09:59:01 more
  • 你是不是暴露了?

    作者:袁首京 原創文章,轉載時請保留此宣告,并給出原文連接。 如果您是計算機相關從業人員,那么應該經歷不止一次網路安全專項檢查了,你肯定是收到過資訊系統技術檢測報告,要求你加強風險監測,確保你提供的系統服務堅實可靠了。 沒檢測到問題還好,檢測到問題的話,有些處理起來還是挺麻煩的,尤其是線上正在運行的 ......

    uj5u.com 2023-04-05 16:52:56 more
  • 細節拉滿,80 張圖帶你一步一步推演 slab 記憶體池的設計與實作

    1. 前文回顧 在之前的幾篇記憶體管理系列文章中,筆者帶大家從宏觀角度完整地梳理了一遍 Linux 記憶體分配的整個鏈路,本文的主題依然是記憶體分配,這一次我們會從微觀的角度來探秘一下 Linux 內核中用于零散小記憶體塊分配的記憶體池 —— slab 分配器。 在本小節中,筆者還是按照以往的風格先帶大家簡單 ......

    uj5u.com 2023-04-05 16:44:11 more