Centos8 创建 LAMP

Centos8 创建 LAMP

        • 第一部分:信息收集
          • 1.1 环境
        • 第二部分:安装 APACHE
          • 2.1 安装 APACHE WEB 服务器
          • 2.1 查看 HTTPD 运行状态
          • 2.2 启动 HTTPD 与开机自启动服务
        • 第三部分:安装 MariaDB
          • 3.1 安装 MariaDB
          • 3.2 启动 MariaDB 与开机启动服务
          • 3.3 查看 MariaDB 运行状态
          • 3.4 启用 Secure 来保护 MariaDB 数据库引擎
        • 第四部分:安装 PHP7
          • 4.1 通过 Remi 信息库安装最新版本的 PHP
          • 4.2 安装 yum utils 并使用以下命令启用 remi-repository
          • 4.3 安装 yum-utils 和 remi-packages 后,通过以下命令搜索可下载的 PHP 模块
          • 4.4 安装 PHP、PHP-FPM(FastCGI 进程管理器)和关联 PHP 模块
          • 4.5 查看 PHP 版本
          • 4.6 启用 PHP 与开机启用服务
          • 4.7 查看运行状态
        • 完结

作者:高玉涵
时间:2022.01.18 14:44
博客:blog.csdn.net/cg_i

第一部分:信息收集
1.1 环境
[root@centos8 ~]# uname -a
Linux centos8 5.13.6-1.el8.elrepo.x86_64 #1 SMP Tue Jul 27 09:43:50 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux
第二部分:安装 APACHE
2.1 安装 APACHE WEB 服务器
[root@centos8 ~]# yum install -y httpd httpd-tools
Failed to set locale, defaulting to C.UTF-8
Repository extras is listed more than once in the configuration
Last metadata expiration check: 1:46:00 ago on Tue Jan 18 12:58:41 2022.
Dependencies resolved.
====================================================================================================================
 Package                    Architecture   Version                                          Repository         Size
====================================================================================================================
Installing:
 httpd                      x86_64         2.4.37-43.module_el8.5.0+1022+b541f3b1           appstream         1.4 M
 httpd-tools                x86_64         2.4.37-43.module_el8.5.0+1022+b541f3b1           appstream         107 k
Installing dependencies:
 apr                        x86_64         1.6.3-12.el8                                     appstream         129 k
 apr-util                   x86_64         1.6.1-6.el8                                      appstream         105 k
 centos-logos-httpd         noarch         85.8-2.el8                                       baseos             75 k
 httpd-filesystem           noarch         2.4.37-43.module_el8.5.0+1022+b541f3b1           appstream          39 k
 mod_http2                  x86_64         1.15.7-3.module_el8.4.0+778+c970deab             appstream         154 k
Installing weak dependencies:
 apr-util-bdb               x86_64         1.6.1-6.el8                                      appstream          25 k
 apr-util-openssl           x86_64         1.6.1-6.el8                                      appstream          27 k
Enabling module streams:
 httpd                                     2.4                                                                     

Transaction Summary
====================================================================================================================
Install  9 Packages

Total download size: 2.1 M
Installed size: 5.6 M
Downloading Packages:
(1/9): apr-util-bdb-1.6.1-6.el8.x86_64.rpm                                          184 kB/s |  25 kB     00:00    
(2/9): apr-util-openssl-1.6.1-6.el8.x86_64.rpm                                      574 kB/s |  27 kB     00:00    
(3/9): apr-1.6.3-12.el8.x86_64.rpm                                                  580 kB/s | 129 kB     00:00    
(4/9): apr-util-1.6.1-6.el8.x86_64.rpm                                              459 kB/s | 105 kB     00:00    
(5/9): httpd-filesystem-2.4.37-43.module_el8.5.0+1022+b541f3b1.noarch.rpm           741 kB/s |  39 kB     00:00    
(6/9): httpd-tools-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64.rpm                1.0 MB/s | 107 kB     00:00    
(7/9): mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64.rpm                    1.7 MB/s | 154 kB     00:00    
(8/9): httpd-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64.rpm                      2.3 MB/s | 1.4 MB     00:00    
(9/9): centos-logos-httpd-85.8-2.el8.noarch.rpm                                     154 kB/s |  75 kB     00:00    
--------------------------------------------------------------------------------------------------------------------
Total                                                                               1.0 MB/s | 2.1 MB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                            1/1 
  Installing       : apr-1.6.3-12.el8.x86_64                                                                    1/9 
  Running scriptlet: apr-1.6.3-12.el8.x86_64                                                                    1/9 
/sbin/ldconfig: /etc/ld.so.conf.d/kernel-ml-5.13.6-1.el8.elrepo.x86_64.conf:6: hwcap directive ignored

  Installing       : apr-util-bdb-1.6.1-6.el8.x86_64                                                            2/9 
  Installing       : apr-util-openssl-1.6.1-6.el8.x86_64                                                        3/9 
  Installing       : apr-util-1.6.1-6.el8.x86_64                                                                4/9 
  Running scriptlet: apr-util-1.6.1-6.el8.x86_64                                                                4/9 
/sbin/ldconfig: /etc/ld.so.conf.d/kernel-ml-5.13.6-1.el8.elrepo.x86_64.conf:6: hwcap directive ignored

  Installing       : httpd-tools-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64                                  5/9 
  Installing       : centos-logos-httpd-85.8-2.el8.noarch                                                       6/9 
  Running scriptlet: httpd-filesystem-2.4.37-43.module_el8.5.0+1022+b541f3b1.noarch                             7/9 
  Installing       : httpd-filesystem-2.4.37-43.module_el8.5.0+1022+b541f3b1.noarch                             7/9 
  Installing       : mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64                                      8/9 
  Installing       : httpd-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64                                        9/9 
  Running scriptlet: httpd-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64                                        9/9 
/sbin/ldconfig: /etc/ld.so.conf.d/kernel-ml-5.13.6-1.el8.elrepo.x86_64.conf:6: hwcap directive ignored

[/usr/lib/tmpfiles.d/pesign.conf:1] Line references path below legacy directory /var/run/, updating /var/run/pesign → /run/pesign; please update the tmpfiles.d/ drop-in file accordingly.

  Verifying        : apr-1.6.3-12.el8.x86_64                                                                    1/9 
  Verifying        : apr-util-1.6.1-6.el8.x86_64                                                                2/9 
  Verifying        : apr-util-bdb-1.6.1-6.el8.x86_64                                                            3/9 
  Verifying        : apr-util-openssl-1.6.1-6.el8.x86_64                                                        4/9 
  Verifying        : httpd-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64                                        5/9 
  Verifying        : httpd-filesystem-2.4.37-43.module_el8.5.0+1022+b541f3b1.noarch                             6/9 
  Verifying        : httpd-tools-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64                                  7/9 
  Verifying        : mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64                                      8/9 
  Verifying        : centos-logos-httpd-85.8-2.el8.noarch                                                       9/9 

Installed:
  apr-1.6.3-12.el8.x86_64                                                                                           
  apr-util-1.6.1-6.el8.x86_64                                                                                       
  apr-util-bdb-1.6.1-6.el8.x86_64                                                                                   
  apr-util-openssl-1.6.1-6.el8.x86_64                                                                               
  centos-logos-httpd-85.8-2.el8.noarch                                                                              
  httpd-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64                                                               
  httpd-filesystem-2.4.37-43.module_el8.5.0+1022+b541f3b1.noarch                                                    
  httpd-tools-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64                                                         
  mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64                                                             

Complete!
2.1 查看 HTTPD 运行状态
[root@centos8 ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd.service(8)
2.2 启动 HTTPD 与开机自启动服务
systemctl status httpd
systemctl enable httpd
第三部分:安装 MariaDB
3.1 安装 MariaDB
[root@centos8 html]# yum install -y mariadb-server mariadb
Failed to set locale, defaulting to C.UTF-8
Repository extras is listed more than once in the configuration
Last metadata expiration check: 1:52:16 ago on Tue Jan 18 12:58:41 2022.
Dependencies resolved.
====================================================================================================================
 Package                          Architecture Version                                        Repository       Size
====================================================================================================================
Installing:
 mariadb                          x86_64       3:10.3.28-1.module_el8.3.0+757+d382997d        appstream       6.0 M
 mariadb-server                   x86_64       3:10.3.28-1.module_el8.3.0+757+d382997d        appstream        16 M
Installing dependencies:
 mariadb-common                   x86_64       3:10.3.28-1.module_el8.3.0+757+d382997d        appstream        64 k
 mariadb-connector-c              x86_64       3.1.11-2.el8_3                                 appstream       200 k
 mariadb-connector-c-config       noarch       3.1.11-2.el8_3                                 appstream        15 k
 mariadb-errmsg                   x86_64       3:10.3.28-1.module_el8.3.0+757+d382997d        appstream       234 k
 perl-DBD-MySQL                   x86_64       4.046-3.module_el8.3.0+419+c2dec72b            appstream       156 k
Installing weak dependencies:
 mariadb-backup                   x86_64       3:10.3.28-1.module_el8.3.0+757+d382997d        appstream       6.1 M
 mariadb-gssapi-server            x86_64       3:10.3.28-1.module_el8.3.0+757+d382997d        appstream        51 k
 mariadb-server-utils             x86_64       3:10.3.28-1.module_el8.3.0+757+d382997d        appstream       1.1 M
Enabling module streams:
 mariadb                                       10.3                                                                
 perl-DBD-MySQL                                4.046                                                               

Transaction Summary
====================================================================================================================
Install  10 Packages

Total download size: 30 M
Installed size: 153 M
Downloading Packages:
(1/10): mariadb-common-10.3.28-1.module_el8.3.0+757+d382997d.x86_64.rpm             306 kB/s |  64 kB     00:00    
(2/10): mariadb-connector-c-3.1.11-2.el8_3.x86_64.rpm                               1.1 MB/s | 200 kB     00:00    
(3/10): mariadb-connector-c-config-3.1.11-2.el8_3.noarch.rpm                        276 kB/s |  15 kB     00:00    
(4/10): mariadb-errmsg-10.3.28-1.module_el8.3.0+757+d382997d.x86_64.rpm             2.4 MB/s | 234 kB     00:00    
(5/10): mariadb-gssapi-server-10.3.28-1.module_el8.3.0+757+d382997d.x86_64.rpm      551 kB/s |  51 kB     00:00    
(6/10): mariadb-backup-10.3.28-1.module_el8.3.0+757+d382997d.x86_64.rpm             4.4 MB/s | 6.1 MB     00:01    
(7/10): mariadb-server-10.3.28-1.module_el8.3.0+757+d382997d.x86_64.rpm              11 MB/s |  16 MB     00:01    
(8/10): mariadb-10.3.28-1.module_el8.3.0+757+d382997d.x86_64.rpm                    2.8 MB/s | 6.0 MB     00:02    
(9/10): mariadb-server-utils-10.3.28-1.module_el8.3.0+757+d382997d.x86_64.rpm       1.4 MB/s | 1.1 MB     00:00    
(10/10): perl-DBD-MySQL-4.046-3.module_el8.3.0+419+c2dec72b.x86_64.rpm              2.0 MB/s | 156 kB     00:00    
--------------------------------------------------------------------------------------------------------------------
Total                                                                                11 MB/s |  30 MB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                            1/1 
  Installing       : mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                          1/10 
  Installing       : mariadb-common-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                             2/10 
  Installing       : mariadb-errmsg-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                             3/10 
  Installing       : perl-DBD-MySQL-4.046-3.module_el8.3.0+419+c2dec72b.x86_64                                 4/10 
  Installing       : mariadb-connector-c-3.1.11-2.el8_3.x86_64                                                 5/10 
  Installing       : mariadb-backup-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                             6/10 
  Installing       : mariadb-gssapi-server-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                      7/10 
  Installing       : mariadb-server-utils-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                       8/10 
  Running scriptlet: mariadb-server-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                             9/10 
  Installing       : mariadb-server-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                             9/10 
  Running scriptlet: mariadb-server-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                             9/10 
  Installing       : mariadb-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                                   10/10 
  Running scriptlet: mariadb-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                                   10/10 
/sbin/ldconfig: /etc/ld.so.conf.d/kernel-ml-5.13.6-1.el8.elrepo.x86_64.conf:6: hwcap directive ignored

[/usr/lib/tmpfiles.d/pesign.conf:1] Line references path below legacy directory /var/run/, updating /var/run/pesign → /run/pesign; please update the tmpfiles.d/ drop-in file accordingly.

  Verifying        : mariadb-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                                    1/10 
  Verifying        : mariadb-backup-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                             2/10 
  Verifying        : mariadb-common-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                             3/10 
  Verifying        : mariadb-connector-c-3.1.11-2.el8_3.x86_64                                                 4/10 
  Verifying        : mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                          5/10 
  Verifying        : mariadb-errmsg-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                             6/10 
  Verifying        : mariadb-gssapi-server-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                      7/10 
  Verifying        : mariadb-server-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                             8/10 
  Verifying        : mariadb-server-utils-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                       9/10 
  Verifying        : perl-DBD-MySQL-4.046-3.module_el8.3.0+419+c2dec72b.x86_64                                10/10 

Installed:
  mariadb-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                                                            
  mariadb-backup-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                                                     
  mariadb-common-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                                                     
  mariadb-connector-c-3.1.11-2.el8_3.x86_64                                                                         
  mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                                                  
  mariadb-errmsg-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                                                     
  mariadb-gssapi-server-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                                              
  mariadb-server-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                                                     
  mariadb-server-utils-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                                               
  perl-DBD-MySQL-4.046-3.module_el8.3.0+419+c2dec72b.x86_64                                                         

Complete!
3.2 启动 MariaDB 与开机启动服务
systemctl start mariadb.service
systemctl enable  mariadb.service
3.3 查看 MariaDB 运行状态
[root@centos8 html]# systemctl status  mariadb.service 
● mariadb.service - MariaDB 10.3 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2022-01-18 14:52:27 CST; 38s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
 Main PID: 1888713 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 30 (limit: 50479)
   Memory: 81.1M
   CGroup: /system.slice/mariadb.service
           └─1888713 /usr/libexec/mysqld --basedir=/usr

Jan 18 14:52:27 centos8 mysql-prepare-db-dir[1888610]: See the MariaDB Knowledgebase at http://mariadb.com/kb or the
Jan 18 14:52:27 centos8 mysql-prepare-db-dir[1888610]: MySQL manual for more instructions.
Jan 18 14:52:27 centos8 mysql-prepare-db-dir[1888610]: Please report any problems at http://mariadb.org/jira
Jan 18 14:52:27 centos8 mysql-prepare-db-dir[1888610]: The latest information about MariaDB is available at http://>
Jan 18 14:52:27 centos8 mysql-prepare-db-dir[1888610]: You can find additional information about the MySQL part at:
Jan 18 14:52:27 centos8 mysql-prepare-db-dir[1888610]: http://dev.mysql.com
Jan 18 14:52:27 centos8 mysql-prepare-db-dir[1888610]: Consider joining MariaDB's strong and vibrant community:
Jan 18 14:52:27 centos8 mysql-prepare-db-dir[1888610]: https://mariadb.org/get-involved/
Jan 18 14:52:27 centos8 mysqld[1888713]: 2022-01-18 14:52:27 0 [Note] /usr/libexec/mysqld (mysqld 10.3.28-MariaDB) >
Jan 18 14:52:27 centos8 systemd[1]: Started MariaDB 10.3 database server.
3.4 启用 Secure 来保护 MariaDB 数据库引擎
[root@centos8 html]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
第四部分:安装 PHP7
4.1 通过 Remi 信息库安装最新版本的 PHP
[root@centos8 ~]# yum install  https://mirrors.aliyun.com/remi/enterprise/remi-release-8.rpm
Failed to set locale, defaulting to C.UTF-8
Repository extras is listed more than once in the configuration
Last metadata expiration check: 2:18:09 ago on Tue Jan 18 12:58:41 2022.
remi-release-8.rpm                                                                   92 kB/s |  26 kB     00:00    
Dependencies resolved.
====================================================================================================================
 Package                     Architecture          Version                        Repository                   Size
====================================================================================================================
Installing:
 remi-release                noarch                8.5-2.el8.remi                 @commandline                 26 k

Transaction Summary
====================================================================================================================
Install  1 Package

Total size: 26 k
Installed size: 21 k
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                            1/1 
  Installing       : remi-release-8.5-2.el8.remi.noarch                                                         1/1 
  Verifying        : remi-release-8.5-2.el8.remi.noarch                                                         1/1 

Installed:
  remi-release-8.5-2.el8.remi.noarch                                                                                

Complete!
4.2 安装 yum utils 并使用以下命令启用 remi-repository
[root@centos8 ~]# yum install dnf-utils 
Failed to set locale, defaulting to C.UTF-8
Repository extras is listed more than once in the configuration
Remi's Modular repository for Enterprise Linux 8 - x86_64                           182  B/s | 858  B     00:04    
Remi's Modular repository for Enterprise Linux 8 - x86_64                           3.0 MB/s | 3.1 kB     00:00    
Importing GPG key 0x5F11735A:
 Userid     : "Remi's RPM repository "
 Fingerprint: 6B38 FEA7 231F 87F5 2B9C A9D8 5550 9759 5F11 735A
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8
Is this ok [y/N]: y
Remi's Modular repository for Enterprise Linux 8 - x86_64                           270 kB/s | 956 kB     00:03    
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                           31  B/s | 858  B     00:27    
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                          3.0 MB/s | 3.1 kB     00:00    
Importing GPG key 0x5F11735A:
 Userid     : "Remi's RPM repository <[email protected]>"
 Fingerprint: 6B38 FEA7 231F 87F5 2B9C A9D8 5550 9759 5F11 735A
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8
Is this ok [y/N]: y
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                           48 kB/s | 2.0 MB     00:43    
Last metadata expiration check: 0:00:01 ago on Tue Jan 18 15:19:01 2022.
Dependencies resolved.
====================================================================================================================
 Package                     Architecture             Version                        Repository                Size
====================================================================================================================
Installing:
 yum-utils                   noarch                   4.0.21-3.el8                   baseos                    73 k

Transaction Summary
====================================================================================================================
Install  1 Package

Total download size: 73 k
Installed size: 22 k
Is this ok [y/N]: y
Downloading Packages:
yum-utils-4.0.21-3.el8.noarch.rpm                                                    46 kB/s |  73 kB     00:01    
--------------------------------------------------------------------------------------------------------------------
Total                                                                                37 kB/s |  73 kB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                            1/1 
  Installing       : yum-utils-4.0.21-3.el8.noarch                                                              1/1 
  Running scriptlet: yum-utils-4.0.21-3.el8.noarch                                                              1/1 
/sbin/ldconfig: /etc/ld.so.conf.d/kernel-ml-5.13.6-1.el8.elrepo.x86_64.conf:6: hwcap directive ignored

  Verifying        : yum-utils-4.0.21-3.el8.noarch                                                              1/1 

Installed:
  yum-utils-4.0.21-3.el8.noarch                                                                                     

Complete!
4.3 安装 yum-utils 和 remi-packages 后,通过以下命令搜索可下载的 PHP 模块
[root@centos8 ~]# dnf module list php
Failed to set locale, defaulting to C.UTF-8
Repository extras is listed more than once in the configuration
Last metadata expiration check: 0:02:26 ago on Tue Jan 18 15:19:01 2022.
CentOS-8 - AppStream
Name               Stream                Profiles                                Summary                            
php                7.2 [d]               common [d], devel, minimal              PHP scripting language             
php                7.3                   common [d], devel, minimal              PHP scripting language             
php                7.4                   common [d], devel, minimal              PHP scripting language             

CentOS Linux 8 - AppStream
Name               Stream                Profiles                                Summary                            
php                7.2 [d]               common [d], devel, minimal              PHP scripting language             
php                7.3                   common [d], devel, minimal              PHP scripting language             
php                7.4                   common [d], devel, minimal              PHP scripting language             

Remi's Modular repository for Enterprise Linux 8 - x86_64
Name               Stream                Profiles                                Summary                            
php                remi-7.2              common [d], devel, minimal              PHP scripting language             
php                remi-7.3              common [d], devel, minimal              PHP scripting language             
php                remi-7.4              common [d], devel, minimal              PHP scripting language             
php                remi-8.0              common [d], devel, minimal              PHP scripting language             
php                remi-8.1              common [d], devel, minimal              PHP scripting language             

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

输出表明当前安装的 PHP 版本是 7.2,要安装较新版本 7.4,请重置 PHP 模块。

[root@centos8 ~]# dnf module reset php
Failed to set locale, defaulting to C.UTF-8
Repository extras is listed more than once in the configuration
Last metadata expiration check: 0:08:46 ago on Tue Jan 18 15:19:01 2022.
Dependencies resolved.
Nothing to do.
Complete!
  • 注:当前系统未安装任何 PHP 这一部原本可省略,这里做演示用。

重置 PHP 模块后,通过运行启用 PHP 7.4 模块。

[root@centos8 ~]# dnf module enable php:remi-7.4
Failed to set locale, defaulting to C.UTF-8
Repository extras is listed more than once in the configuration
Last metadata expiration check: 0:12:50 ago on Tue Jan 18 15:19:01 2022.
Dependencies resolved.
====================================================================================================================
 Package                    Architecture              Version                      Repository                  Size
====================================================================================================================
Enabling module streams:
 php                                                  remi-7.4                                                     

Transaction Summary
====================================================================================================================

Is this ok [y/N]: y
Complete!
4.4 安装 PHP、PHP-FPM(FastCGI 进程管理器)和关联 PHP 模块
[root@centos8 ~]#  yum install -y  php php-opcache php-gd php-curl php-mysqlnd
Failed to set locale, defaulting to C.UTF-8
Repository extras is listed more than once in the configuration
Last metadata expiration check: 0:13:23 ago on Tue Jan 18 15:19:01 2022.
Dependencies resolved.
====================================================================================================================
 Package                  Architecture   Version                                         Repository            Size
====================================================================================================================
Installing:
 php                      x86_64         7.4.27-1.el8.remi                               remi-modular         3.0 M
 php-common               x86_64         7.4.27-1.el8.remi                               remi-modular         1.2 M
 php-gd                   x86_64         7.4.27-1.el8.remi                               remi-modular          95 k
 php-mysqlnd              x86_64         7.4.27-1.el8.remi                               remi-modular         262 k
 php-opcache              x86_64         7.4.27-1.el8.remi                               remi-modular         338 k
Installing dependencies:
 gd3php                   x86_64         2.3.3-4.el8.remi                                remi-safe            146 k
 libimagequant            x86_64         2.12.5-1.el8                                    epel                  63 k
 libraqm                  x86_64         0.7.0-4.el8                                     epel                  19 k
 libsodium                x86_64         1.0.18-2.el8                                    epel                 162 k
 oniguruma5php            x86_64         6.9.7.1-1.el8.remi                              remi-safe            210 k
 php-json                 x86_64         7.4.27-1.el8.remi                               remi-modular          79 k
 php-pdo                  x86_64         7.4.27-1.el8.remi                               remi-modular         145 k
Installing weak dependencies:
 nginx-filesystem         noarch         1:1.14.1-9.module_el8.0.0+184+e34fea82          appstream             24 k
 php-cli                  x86_64         7.4.27-1.el8.remi                               remi-modular         4.6 M
 php-fpm                  x86_64         7.4.27-1.el8.remi                               remi-modular         1.6 M
 php-mbstring             x86_64         7.4.27-1.el8.remi                               remi-modular         528 k
 php-sodium               x86_64         7.4.27-1.el8.remi                               remi-modular          91 k
 php-xml                  x86_64         7.4.27-1.el8.remi                               remi-modular         217 k
Enabling module streams:
 nginx                                   1.14                                                                      

Transaction Summary
====================================================================================================================
Install  18 Packages

Total download size: 13 M
Installed size: 54 M
Downloading Packages:
(1/18): nginx-filesystem-1.14.1-9.module_el8.0.0+184+e34fea82.noarch.rpm            164 kB/s |  24 kB     00:00    
(2/18): libraqm-0.7.0-4.el8.x86_64.rpm                                               30 kB/s |  19 kB     00:00    
(3/18): libsodium-1.0.18-2.el8.x86_64.rpm                                           106 kB/s | 162 kB     00:01    
(4/18): libimagequant-2.12.5-1.el8.x86_64.rpm                                        30 kB/s |  63 kB     00:02    
(5/18): php-common-7.4.27-1.el8.remi.x86_64.rpm                                     142 kB/s | 1.2 MB     00:08    
(6/18): php-cli-7.4.27-1.el8.remi.x86_64.rpm                                        443 kB/s | 4.6 MB     00:10    
(7/18): php-gd-7.4.27-1.el8.remi.x86_64.rpm                                         318 kB/s |  95 kB     00:00    
(8/18): php-json-7.4.27-1.el8.remi.x86_64.rpm                                        64 kB/s |  79 kB     00:01    
(9/18): php-mbstring-7.4.27-1.el8.remi.x86_64.rpm                                   470 kB/s | 528 kB     00:01    
(10/18): php-mysqlnd-7.4.27-1.el8.remi.x86_64.rpm                                   925 kB/s | 262 kB     00:00    
(11/18): php-opcache-7.4.27-1.el8.remi.x86_64.rpm                                   397 kB/s | 338 kB     00:00    
(12/18): php-pdo-7.4.27-1.el8.remi.x86_64.rpm                                       515 kB/s | 145 kB     00:00    
(13/18): php-sodium-7.4.27-1.el8.remi.x86_64.rpm                                    311 kB/s |  91 kB     00:00    
(14/18): php-xml-7.4.27-1.el8.remi.x86_64.rpm                                       385 kB/s | 217 kB     00:00    
(15/18): php-fpm-7.4.27-1.el8.remi.x86_64.rpm                                       230 kB/s | 1.6 MB     00:07    
(16/18): gd3php-2.3.3-4.el8.remi.x86_64.rpm                                         102 kB/s | 146 kB     00:01    
(17/18): oniguruma5php-6.9.7.1-1.el8.remi.x86_64.rpm                                232 kB/s | 210 kB     00:00    
(18/18): php-7.4.27-1.el8.remi.x86_64.rpm                                            92 kB/s | 3.0 MB     00:33    
--------------------------------------------------------------------------------------------------------------------
Total                                                                               349 kB/s |  13 MB     00:37     
Remi's Modular repository for Enterprise Linux 8 - x86_64                           3.0 MB/s | 3.1 kB     00:00    
Importing GPG key 0x5F11735A:
 Userid     : "Remi's RPM repository <[email protected]>"
 Fingerprint: 6B38 FEA7 231F 87F5 2B9C A9D8 5550 9759 5F11 735A
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                            1/1 
  Installing       : php-json-7.4.27-1.el8.remi.x86_64                                                         1/18 
  Running scriptlet: php-common-7.4.27-1.el8.remi.x86_64                                                       2/18 
  Installing       : php-common-7.4.27-1.el8.remi.x86_64                                                       2/18 
  Installing       : php-pdo-7.4.27-1.el8.remi.x86_64                                                          3/18 
  Installing       : php-cli-7.4.27-1.el8.remi.x86_64                                                          4/18 
  Installing       : php-opcache-7.4.27-1.el8.remi.x86_64                                                      5/18 
  Installing       : php-xml-7.4.27-1.el8.remi.x86_64                                                          6/18 
  Installing       : oniguruma5php-6.9.7.1-1.el8.remi.x86_64                                                   7/18 
  Installing       : php-mbstring-7.4.27-1.el8.remi.x86_64                                                     8/18 
  Installing       : libsodium-1.0.18-2.el8.x86_64                                                             9/18 
  Installing       : php-sodium-7.4.27-1.el8.remi.x86_64                                                      10/18 
  Installing       : libraqm-0.7.0-4.el8.x86_64                                                               11/18 
  Installing       : libimagequant-2.12.5-1.el8.x86_64                                                        12/18 
  Installing       : gd3php-2.3.3-4.el8.remi.x86_64                                                           13/18 
  Running scriptlet: nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                           14/18 
  Installing       : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                           14/18 
  Installing       : php-fpm-7.4.27-1.el8.remi.x86_64                                                         15/18 
  Running scriptlet: php-fpm-7.4.27-1.el8.remi.x86_64                                                         15/18 
  Installing       : php-7.4.27-1.el8.remi.x86_64                                                             16/18 
  Installing       : php-gd-7.4.27-1.el8.remi.x86_64                                                          17/18 
  Installing       : php-mysqlnd-7.4.27-1.el8.remi.x86_64                                                     18/18 
  Running scriptlet: php-mysqlnd-7.4.27-1.el8.remi.x86_64                                                     18/18 
/sbin/ldconfig: /etc/ld.so.conf.d/kernel-ml-5.13.6-1.el8.elrepo.x86_64.conf:6: hwcap directive ignored

  Running scriptlet: php-fpm-7.4.27-1.el8.remi.x86_64                                                         18/18 
  Verifying        : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch                            1/18 
  Verifying        : libimagequant-2.12.5-1.el8.x86_64                                                         2/18 
  Verifying        : libraqm-0.7.0-4.el8.x86_64                                                                3/18 
  Verifying        : libsodium-1.0.18-2.el8.x86_64                                                             4/18 
  Verifying        : php-7.4.27-1.el8.remi.x86_64                                                              5/18 
  Verifying        : php-cli-7.4.27-1.el8.remi.x86_64                                                          6/18 
  Verifying        : php-common-7.4.27-1.el8.remi.x86_64                                                       7/18 
  Verifying        : php-fpm-7.4.27-1.el8.remi.x86_64                                                          8/18 
  Verifying        : php-gd-7.4.27-1.el8.remi.x86_64                                                           9/18 
  Verifying        : php-json-7.4.27-1.el8.remi.x86_64                                                        10/18 
  Verifying        : php-mbstring-7.4.27-1.el8.remi.x86_64                                                    11/18 
  Verifying        : php-mysqlnd-7.4.27-1.el8.remi.x86_64                                                     12/18 
  Verifying        : php-opcache-7.4.27-1.el8.remi.x86_64                                                     13/18 
  Verifying        : php-pdo-7.4.27-1.el8.remi.x86_64                                                         14/18 
  Verifying        : php-sodium-7.4.27-1.el8.remi.x86_64                                                      15/18 
  Verifying        : php-xml-7.4.27-1.el8.remi.x86_64                                                         16/18 
  Verifying        : gd3php-2.3.3-4.el8.remi.x86_64                                                           17/18 
  Verifying        : oniguruma5php-6.9.7.1-1.el8.remi.x86_64                                                  18/18 

Installed:
  gd3php-2.3.3-4.el8.remi.x86_64                                       libimagequant-2.12.5-1.el8.x86_64            
  libraqm-0.7.0-4.el8.x86_64                                           libsodium-1.0.18-2.el8.x86_64                
  nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch       oniguruma5php-6.9.7.1-1.el8.remi.x86_64      
  php-7.4.27-1.el8.remi.x86_64                                         php-cli-7.4.27-1.el8.remi.x86_64             
  php-common-7.4.27-1.el8.remi.x86_64                                  php-fpm-7.4.27-1.el8.remi.x86_64             
  php-gd-7.4.27-1.el8.remi.x86_64                                      php-json-7.4.27-1.el8.remi.x86_64            
  php-mbstring-7.4.27-1.el8.remi.x86_64                                php-mysqlnd-7.4.27-1.el8.remi.x86_64         
  php-opcache-7.4.27-1.el8.remi.x86_64                                 php-pdo-7.4.27-1.el8.remi.x86_64             
  php-sodium-7.4.27-1.el8.remi.x86_64                                  php-xml-7.4.27-1.el8.remi.x86_64             

Complete!
4.5 查看 PHP 版本
[root@centos8 ~]# php -v
PHP 7.4.27 (cli) (built: Dec 14 2021 17:17:06) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.27, Copyright (c), by Zend Technologies
4.6 启用 PHP 与开机启用服务
systemctl start php-fpm
systemctl enable  php-fpm
4.7 查看运行状态
[root@centos8 ~]# systemctl status   php-fpm
● 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-18 15:35:56 CST; 23s ago
 Main PID: 1894356 (php-fpm)
   Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0, Traffic: 0req/sec"
    Tasks: 6 (limit: 50479)
   Memory: 14.7M
   CGroup: /system.slice/php-fpm.service
           ├─1894356 php-fpm: master process (/etc/php-fpm.conf)
           ├─1894358 php-fpm: pool www
           ├─1894359 php-fpm: pool www
           ├─1894360 php-fpm: pool www
           ├─1894361 php-fpm: pool www
           └─1894362 php-fpm: pool www

Jan 18 15:35:56 centos8 systemd[1]: Starting The PHP FastCGI Process Manager...
Jan 18 15:35:56 centos8 systemd[1]: Started The PHP FastCGI Process Manager.

使 SELinux 允许 Apache 通过 PHP-FPM 运行来执行PHP代码。
最后,重新启动 Apache Web 服务器以使 PHP 与 Apache Web 服务器一起使用。

setsebool -P httpd_execmem 1
systemctl restart httpd
完结

你可能感兴趣的:(OS/Network,apache,centos,linux)