iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 27
0
自我挑戰組

30天學 LAMP 安裝系列 第 27

Day27 CentOS Stream 安裝基本 LAMP 環境 (1)

  • 分享至 

  • xImage
  •  

安裝 Apache

安裝 httpd

[doraemon@centos8-gui ~]$ sudo yum install httpd -y
[sudo] password for doraemon:
CentOS-8 - AppStream                                                                 2.3 kB/s | 4.3 kB     00:01
CentOS-8 - Base                                                                      1.4 kB/s | 3.8 kB     00:02
CentOS-8 - Extras                                                                    620  B/s | 1.5 kB     00:02
依賴關係解析完畢。
=====================================================================================================================
 軟體包                      架構            版本                                           軟體庫              大小
=====================================================================================================================
Installing:
 httpd                       x86_64          2.4.37-11.module_el8.0.0+172+85fc1f40          AppStream          1.7 M
正在安裝相依性:
 apr                         x86_64          1.6.3-9.el8                                    AppStream          125 k
 apr-util                    x86_64          1.6.1-6.el8                                    AppStream          105 k
 centos-logos-httpd          noarch          80.5-2.el8                                     AppStream           24 k
 httpd-filesystem            noarch          2.4.37-11.module_el8.0.0+172+85fc1f40          AppStream           34 k
 httpd-tools                 x86_64          2.4.37-11.module_el8.0.0+172+85fc1f40          AppStream          102 k
 mod_http2                   x86_64          1.11.3-2.module_el8.0.0+10+abf51267            AppStream          156 k
正在安裝脆弱的相依軟體包:
 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

處理事項摘要
=====================================================================================================================
安裝  9 軟體包

總下載大小:2.2 M
安裝的大小:6.0 M
下載軟體包:
(1/9): apr-util-bdb-1.6.1-6.el8.x86_64.rpm                                           112 kB/s |  25 kB     00:00
(2/9): apr-util-1.6.1-6.el8.x86_64.rpm                                               401 kB/s | 105 kB     00:00
(3/9): apr-1.6.3-9.el8.x86_64.rpm                                                    390 kB/s | 125 kB     00:00
(4/9): centos-logos-httpd-80.5-2.el8.noarch.rpm                                      190 kB/s |  24 kB     00:00
(5/9): httpd-filesystem-2.4.37-11.module_el8.0.0+172+85fc1f40.noarch.rpm             460 kB/s |  34 kB     00:00
(6/9): apr-util-openssl-1.6.1-6.el8.x86_64.rpm                                        65 kB/s |  27 kB     00:00
(7/9): httpd-tools-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64.rpm                  258 kB/s | 102 kB     00:00
(8/9): httpd-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64.rpm                        2.3 MB/s | 1.7 MB     00:00
(9/9): mod_http2-1.11.3-2.module_el8.0.0+10+abf51267.x86_64.rpm                      315 kB/s | 156 kB     00:00
---------------------------------------------------------------------------------------------------------------------
總計                                                                                 825 kB/s | 2.2 MB     00:02
執行處理事項檢查
處理事項檢查成功。
執行處理事項測試
處理事項測試成功。
執行處理事項
  準備        :                                                                                                  1/1
  Installing  : apr-1.6.3-9.el8.x86_64                                                                           1/9
  執行指令小稿: apr-1.6.3-9.el8.x86_64                                                                           1/9
  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
  執行指令小稿: apr-util-1.6.1-6.el8.x86_64                                                                      4/9
  Installing  : httpd-tools-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64                                         5/9
  執行指令小稿: httpd-filesystem-2.4.37-11.module_el8.0.0+172+85fc1f40.noarch                                    6/9
  Installing  : httpd-filesystem-2.4.37-11.module_el8.0.0+172+85fc1f40.noarch                                    6/9
  Installing  : centos-logos-httpd-80.5-2.el8.noarch                                                             7/9
  Installing  : mod_http2-1.11.3-2.module_el8.0.0+10+abf51267.x86_64                                             8/9
  Installing  : httpd-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64                                               9/9
  執行指令小稿: httpd-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64                                               9/9
  核驗        : apr-1.6.3-9.el8.x86_64                                                                           1/9
  核驗        : apr-util-1.6.1-6.el8.x86_64                                                                      2/9
  核驗        : apr-util-bdb-1.6.1-6.el8.x86_64                                                                  3/9
  核驗        : apr-util-openssl-1.6.1-6.el8.x86_64                                                              4/9
  核驗        : centos-logos-httpd-80.5-2.el8.noarch                                                             5/9
  核驗        : httpd-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64                                               6/9
  核驗        : httpd-filesystem-2.4.37-11.module_el8.0.0+172+85fc1f40.noarch                                    7/9
  核驗        : httpd-tools-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64                                         8/9
  核驗        : mod_http2-1.11.3-2.module_el8.0.0+10+abf51267.x86_64                                             9/9

已安裝:
  httpd-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64
  apr-util-bdb-1.6.1-6.el8.x86_64
  apr-util-openssl-1.6.1-6.el8.x86_64
  apr-1.6.3-9.el8.x86_64
  apr-util-1.6.1-6.el8.x86_64
  centos-logos-httpd-80.5-2.el8.noarch
  httpd-filesystem-2.4.37-11.module_el8.0.0+172+85fc1f40.noarch
  httpd-tools-2.4.37-11.module_el8.0.0+172+85fc1f40.x86_64
  mod_http2-1.11.3-2.module_el8.0.0+10+abf51267.x86_64

完成!

「立即啟用」httpd

[doraemon@centos8-gui ~]$ sudo systemctl enable --now httpd.service
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.

查看 httpd 版本及狀態

[doraemon@centos8-gui ~]$ httpd -v
Server version: Apache/2.4.37 (centos)
Server built:   Jul 30 2019 19:56:12
[doraemon@centos8-gui ~]$ sudo systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2019-09-29 16:43:55 CST; 2min 4s ago
     Docs: man:httpd.service(8)
 Main PID: 8515 (httpd)
   Status: "Running, listening on: port 80"
    Tasks: 213 (limit: 23869)
   Memory: 38.3M
   CGroup: /system.slice/httpd.service
           ├─8515 /usr/sbin/httpd -DFOREGROUND
           ├─8516 /usr/sbin/httpd -DFOREGROUND
           ├─8517 /usr/sbin/httpd -DFOREGROUND
           ├─8518 /usr/sbin/httpd -DFOREGROUND
           └─8519 /usr/sbin/httpd -DFOREGROUND

 9月 29 16:43:54 centos8-gui.lab.example.com systemd[1]: Starting The Apache HTTP Server...
 9月 29 16:43:55 centos8-gui.lab.example.com httpd[8515]: Server configured, listening on: port 80
 9月 29 16:43:55 centos8-gui.lab.example.com systemd[1]: Started The Apache HTTP Server.

開通防火牆 HTTP 服務(TCP 80 Port)

[doraemon@centos8-gui ~]$ sudo firewall-cmd --permanent --add-service=http
success
[doraemon@centos8-gui ~]$ sudo firewall-cmd --reload
success

於另外一台電腦開啟 http://192.168.250.95 網頁

https://ithelp.ithome.com.tw/upload/images/20190930/20119707VaHMIFvyE5.png

安裝 MySQL

安裝 mysql

[doraemon@centos8-gui ~]$ sudo yum module install mysql -y
[sudo] password for doraemon:
上次中介資料過期檢查:0:12:39 以前,時間點為 西元2019年09月29日 (週日) 16時42分32秒。
依賴關係解析完畢。
=====================================================================================================================
 軟體包                            架構          版本                                         軟體庫            大小
=====================================================================================================================
Installing group/module packages:
 mysql-server                      x86_64        8.0.13-1.module_el8.0.0+41+ca30bab6          AppStream         25 M
正在安裝相依性:
 mariadb-connector-c-config        noarch        3.0.7-1.el8                                  AppStream         13 k
 mecab                             x86_64        0.996-1.module_el8.0.0+41+ca30bab6.9         AppStream        397 k
 mysql                             x86_64        8.0.13-1.module_el8.0.0+41+ca30bab6          AppStream        9.2 M
 mysql-common                      x86_64        8.0.13-1.module_el8.0.0+41+ca30bab6          AppStream        142 k
 mysql-errmsg                      x86_64        8.0.13-1.module_el8.0.0+41+ca30bab6          AppStream        523 k
 protobuf-lite                     x86_64        3.5.0-7.el8                                  AppStream        150 k
Installing module profiles:
 mysql/server
Enabling module streams:
 mysql                                           8.0

處理事項摘要
=====================================================================================================================
安裝  7 軟體包

總下載大小:36 M
安裝的大小:243 M
下載軟體包:
(1/7): mariadb-connector-c-config-3.0.7-1.el8.noarch.rpm                              70 kB/s |  13 kB     00:00
(2/7): mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64.rpm                         982 kB/s | 397 kB     00:00
(3/7): mysql-errmsg-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64.rpm                   2.4 MB/s | 523 kB     00:00
(4/7): mysql-common-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64.rpm                   273 kB/s | 142 kB     00:00
(5/7): protobuf-lite-3.5.0-7.el8.x86_64.rpm                                          240 kB/s | 150 kB     00:00
(6/7): mysql-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64.rpm                          3.7 MB/s | 9.2 MB     00:02
(7/7): mysql-server-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64.rpm                   5.8 MB/s |  25 MB     00:04
---------------------------------------------------------------------------------------------------------------------
總計                                                                                 5.4 MB/s |  36 MB     00:06
執行處理事項檢查
處理事項檢查成功。
執行處理事項測試
處理事項測試成功。
執行處理事項
  準備        :                                                                                                  1/1
  Installing  : mariadb-connector-c-config-3.0.7-1.el8.noarch                                                    1/7
  Installing  : mysql-common-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64                                          2/7
  Installing  : mysql-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64                                                 3/7
  Installing  : mysql-errmsg-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64                                          4/7
  Installing  : protobuf-lite-3.5.0-7.el8.x86_64                                                                 5/7
  Installing  : mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64                                                6/7
  執行指令小稿: mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64                                                6/7
  執行指令小稿: mysql-server-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64                                          7/7
  Installing  : mysql-server-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64                                          7/7
  執行指令小稿: mysql-server-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64                                          7/7
ValueError: 文件上下文 /var/log/mysql(/.*)? 已定義

  核驗        : mariadb-connector-c-config-3.0.7-1.el8.noarch                                                    1/7
  核驗        : mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64                                                2/7
  核驗        : mysql-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64                                                 3/7
  核驗        : mysql-common-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64                                          4/7
  核驗        : mysql-errmsg-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64                                          5/7
  核驗        : mysql-server-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64                                          6/7
  核驗        : protobuf-lite-3.5.0-7.el8.x86_64                                                                 7/7

已安裝:
  mysql-server-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64   mariadb-connector-c-config-3.0.7-1.el8.noarch
  mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64         mysql-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64
  mysql-common-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64   mysql-errmsg-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64
  protobuf-lite-3.5.0-7.el8.x86_64

完成!

「立即啟用」mysql

[doraemon@centos8-gui ~]$ sudo systemctl enable --now mysqld.service
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.

查看 mysql 版本及狀態

[doraemon@centos8-gui ~]$ mysqld --version
/usr/libexec/mysqld  Ver 8.0.13 for Linux on x86_64 (Source distribution)
[doraemon@centos8-gui ~]$ systemctl status mysqld.service
● mysqld.service - MySQL 8.0 database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2019-09-29 16:57:43 CST; 2min 13s ago
  Process: 10158 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 10034 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
  Process: 10009 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
 Main PID: 10117 (mysqld)
   Status: "SERVER_OPERATING"
    Tasks: 37 (limit: 23869)
   Memory: 528.6M
   CGroup: /system.slice/mysqld.service
           └─10117 /usr/libexec/mysqld --basedir=/usr

 9月 29 16:57:38 centos8-gui.lab.example.com systemd[1]: Starting MySQL 8.0 database server...
 9月 29 16:57:38 centos8-gui.lab.example.com mysql-prepare-db-dir[10034]: Initializing MySQL database
 9月 29 16:57:43 centos8-gui.lab.example.com systemd[1]: Started MySQL 8.0 database server.

執行讓 MySQL 服務更安全的交談式 Script

[doraemon@centos8-gui ~]$ sudo mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: Y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Please set the password for root here.

New password:

Re-enter new password:

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : Y
Success.

By default, MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : Y
Success.

All done!

安裝 PHP

安裝 yum-utils

[doraemon@centos8-gui ~]$ yum search epel
上次中介資料過期檢查:7:22:28 以前,時間點為 西元2019年09月29日 (週日) 15時08分13秒。
================================================= 名稱 符合: epel ==================================================
epel-release.noarch : Extra Packages for Enterprise Linux repository configuration
[doraemon@centos8-gui ~]$ sudo yum install yum-utils -y
[sudo] password for doraemon:
上次中介資料過期檢查:5:49:52 以前,時間點為 西元2019年09月29日 (週日) 16時42分32秒。
依賴關係解析完畢。
=====================================================================================================================
 軟體包                      架構                     版本                            軟體庫                    大小
=====================================================================================================================
Installing:
 dnf-utils                   noarch                   4.0.2.2-3.el8                   BaseOS                    62 k

處理事項摘要
=====================================================================================================================
安裝  1 軟體包

總下載大小:62 k
安裝的大小:18 k
下載軟體包:
dnf-utils-4.0.2.2-3.el8.noarch.rpm                                                    53 kB/s |  62 kB     00:01
---------------------------------------------------------------------------------------------------------------------
總計                                                                                  21 kB/s |  62 kB     00:02
執行處理事項檢查
處理事項檢查成功。
執行處理事項測試
處理事項測試成功。
執行處理事項
  準備        :                                                                                                  1/1
  Installing  : dnf-utils-4.0.2.2-3.el8.noarch                                                                   1/1
  執行指令小稿: dnf-utils-4.0.2.2-3.el8.noarch                                                                   1/1
  核驗        : dnf-utils-4.0.2.2-3.el8.noarch                                                                   1/1

已安裝:
  dnf-utils-4.0.2.2-3.el8.noarch

完成!

安裝 Extra Packages for Enterprise Linux repository configuration (epel-release)

[doraemon@centos8-gui ~]$ sudo yum install epel-release -y
上次中介資料過期檢查:5:52:16 以前,時間點為 西元2019年09月29日 (週日) 16時42分32秒。
依賴關係解析完畢。
=====================================================================================================================
 軟體包                         架構                     版本                         軟體庫                    大小
=====================================================================================================================
Installing:
 epel-release                   noarch                   8-5.el8                      extras                    22 k

處理事項摘要
=====================================================================================================================
安裝  1 軟體包

總下載大小:22 k
安裝的大小:30 k
下載軟體包:
epel-release-8-5.el8.noarch.rpm                                                       19 kB/s |  22 kB     00:01
---------------------------------------------------------------------------------------------------------------------
總計                                                                                 8.2 kB/s |  22 kB     00:02
執行處理事項檢查
處理事項檢查成功。
執行處理事項測試
處理事項測試成功。
執行處理事項
  準備        :                                                                                                  1/1
  Installing  : epel-release-8-5.el8.noarch                                                                      1/1
  執行指令小稿: epel-release-8-5.el8.noarch                                                                      1/1
  核驗        : epel-release-8-5.el8.noarch                                                                      1/1

已安裝:
  epel-release-8-5.el8.noarch

完成!

根據 EPEL 官網建議,CentOS 8安裝 EPEL 後,還需啟用 PowerTools 軟體庫,參考資料:https://fedoraproject.org/wiki/EPEL 。

on CentOS 8 it is recommended to also enable the PowerTools repository since EPEL packages may depend on packages from it:

dnf config-manager --set-enabled PowerTools

[doraemon@centos8-gui ~]$ sudo yum-config-manager enable PowerTools
[doraemon@centos8-gui ~]$ sudo yum update
CentOS-8 - AppStream                                                                 1.6 kB/s | 4.3 kB     00:02
CentOS-8 - Base                                                                      1.4 kB/s | 3.8 kB     00:02
CentOS-8 - Extras                                                                    589  B/s | 1.5 kB     00:02
CentOS-8 - PowerTools                                                                209 kB/s | 1.8 MB     00:08
Extra Packages for Enterprise Linux 8 - x86_64                                        18 kB/s |  40 kB     00:02
依賴關係解析完畢。
無事可做。
完成!
[doraemon@centos8-gui ~]$ yum repolist
CentOS-8 - PowerTools                                                                532 kB/s | 1.8 MB     00:03
上次中介資料過期檢查:0:00:01 以前,時間點為 西元2019年09月29日 (週日) 22時48分28秒。
軟體庫 ID                             軟體庫名稱                                                                狀態
AppStream                             CentOS-8 - AppStream                                                      4,928
BaseOS                                CentOS-8 - Base                                                           2,713
PowerTools                            CentOS-8 - PowerTools                                                     1,473
*epel                                 Extra Packages for Enterprise Linux 8 - x86_64                            1,655
extras                                CentOS-8 - Extras                                                             3

安裝 Remi repository configuration package

[doraemon@centos8-gui ~]$ sudo yum install <https://rpms.remirepo.net/enterprise/remi-release-8.rpm> -y
[sudo] password for doraemon:
CentOS-8 - AppStream                                                                 567 kB/s | 5.6 MB     00:10
CentOS-8 - Base                                                                      717 kB/s | 5.3 MB     00:07
CentOS-8 - Extras                                                                    593  B/s | 2.1 kB     00:03
CentOS-8 - PowerTools                                                                451 kB/s | 1.8 MB     00:04
Extra Packages for Enterprise Linux 8 - x86_64                                       330 kB/s | 1.8 MB     00:05
remi-release-8.rpm                                                                   8.1 kB/s |  20 kB     00:02
依賴關係解析完畢。
=====================================================================================================================
 軟體包                      架構                  版本                            軟體庫                       大小
=====================================================================================================================
Installing:
 remi-release                noarch                8.0-4.el8.remi                  @commandline                 20 k

處理事項摘要
=====================================================================================================================
安裝  1 軟體包

總大小:20 k
安裝的大小:14 k
下載軟體包:
執行處理事項檢查
處理事項檢查成功。
執行處理事項測試
處理事項測試成功。
執行處理事項
  準備        :                                                                                                  1/1
  Installing  : remi-release-8.0-4.el8.remi.noarch                                                               1/1
  核驗        : remi-release-8.0-4.el8.remi.noarch                                                               1/1

已安裝:
  remi-release-8.0-4.el8.remi.noarch

完成!
[doraemon@centos8-gui ~]$ sudo yum update
Remi's Modular repository for Enterprise Linux 8 - x86_64                             84 kB/s | 499 kB     00:05
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                           162 kB/s | 1.3 MB     00:08
依賴關係解析完畢。
無事可做。
完成!
[doraemon@centos8-gui ~]$ yum repolist
Remi's Modular repository for Enterprise Linux 8 - x86_64                             61 kB/s | 499 kB     00:08
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                           153 kB/s | 1.3 MB     00:09
上次中介資料過期檢查:0:00:01 以前,時間點為 西元2019年09月29日 (週日) 22時53分43秒。
軟體庫 ID                        軟體庫名稱                                                                     狀態
AppStream                        CentOS-8 - AppStream                                                           4,890
BaseOS                           CentOS-8 - Base                                                                2,713
PowerTools                       CentOS-8 - PowerTools                                                          1,473
*epel                            Extra Packages for Enterprise Linux 8 - x86_64                                 1,655
extras                           CentOS-8 - Extras                                                                  3
remi-modular                     Remi's Modular repository for Enterprise Linux 8 - x86_64                          0
remi-safe                        Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                     1,945
[doraemon@centos8-gui ~]$ sudo yum module list | grep php
php                  7.2          common [d], devel, minimal               PHP scripting language                    
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

透過 Remi 軟體庫安裝 PHP 7.3

[doraemon@centos8-gui ~]$ sudo yum module install php:remi-7.3 -y
上次中介資料過期檢查:0:11:06 以前,時間點為 西元2019年09月30日 (週一) 09時57分53秒。
依賴關係解析完畢。
=====================================================================================================================
 軟體包                    架構            版本                                          軟體庫                 大小
=====================================================================================================================
Installing group/module packages:
 php-cli                   x86_64          7.3.10-1.el8.remi                             remi-modular          4.6 M
 php-common                x86_64          7.3.10-1.el8.remi                             remi-modular          1.1 M
 php-fpm                   x86_64          7.3.10-1.el8.remi                             remi-modular          1.6 M
 php-json                  x86_64          7.3.10-1.el8.remi                             remi-modular           71 k
 php-mbstring              x86_64          7.3.10-1.el8.remi                             remi-modular          520 k
 php-xml                   x86_64          7.3.10-1.el8.remi                             remi-modular          229 k
正在安裝相依性:
 nginx-filesystem          noarch          1:1.14.1-8.module_el8.0.0+5+258f653c          AppStream              24 k
 oniguruma                 x86_64          6.8.2-1.el8                                   AppStream             188 k
 libargon2                 x86_64          20171227-3.el8                                epel                   29 k
Installing module profiles:
 php/common
Enabling module streams:
 nginx                                     1.14
 php                                       remi-7.3

處理事項摘要
=====================================================================================================================
安裝  9 軟體包

總下載大小:8.3 M
安裝的大小:36 M
下載軟體包:
(1/9): nginx-filesystem-1.14.1-8.module_el8.0.0+5+258f653c.noarch.rpm                 20 kB/s |  24 kB     00:01
(2/9): oniguruma-6.8.2-1.el8.x86_64.rpm                                              135 kB/s | 188 kB     00:01
(3/9): libargon2-20171227-3.el8.x86_64.rpm                                           6.1 kB/s |  29 kB     00:04
(4/9): php-common-7.3.10-1.el8.remi.x86_64.rpm                                       272 kB/s | 1.1 MB     00:04
(5/9): php-json-7.3.10-1.el8.remi.x86_64.rpm                                          44 kB/s |  71 kB     00:01
(6/9): php-cli-7.3.10-1.el8.remi.x86_64.rpm                                          721 kB/s | 4.6 MB     00:06
(7/9): php-xml-7.3.10-1.el8.remi.x86_64.rpm                                           92 kB/s | 229 kB     00:02
(8/9): php-fpm-7.3.10-1.el8.remi.x86_64.rpm                                          299 kB/s | 1.6 MB     00:05
(9/9): php-mbstring-7.3.10-1.el8.remi.x86_64.rpm                                     138 kB/s | 520 kB     00:03
---------------------------------------------------------------------------------------------------------------------
總計                                                                                 537 kB/s | 8.3 MB     00:15
警告:/var/cache/dnf/epel-6519ee669354a484/packages/libargon2-20171227-3.el8.x86_64.rpm: 表頭 V3 RSA/SHA256 Signature, key ID 2f86d6a1: NOKEY
Extra Packages for Enterprise Linux 8 - x86_64                                       1.6 MB/s | 1.6 kB     00:00
匯入 GPG 密鑰 0x2F86D6A1:
使用者識別碼:"Fedora EPEL (8) <epel@fedoraproject.org>"
指紋                :94E2 79EB 8D8F 25B2 1810 ADF1 21EA 45AB 2F86 D6A1
來自                :/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
密鑰匯入成功
警告:/var/cache/dnf/remi-modular-6408ecca79e22107/packages/php-cli-7.3.10-1.el8.remi.x86_64.rpm: 表頭 V4 RSA/SHA256 Signature, key ID 5f11735a: NOKEY
Remi's Modular repository for Enterprise Linux 8 - x86_64                            3.0 MB/s | 3.1 kB     00:00
匯入 GPG 密鑰 0x5F11735A:
使用者識別碼:"Remi's RPM repository <remi@remirepo.net>"
指紋                :6B38 FEA7 231F 87F5 2B9C A9D8 5550 9759 5F11 735A
來自                :/etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8
密鑰匯入成功
執行處理事項檢查
處理事項檢查成功。
執行處理事項測試
處理事項測試成功。
執行處理事項
  準備        :                                                                                                  1/1
  Installing  : php-json-7.3.10-1.el8.remi.x86_64                                                                1/9
  執行指令小稿: php-common-7.3.10-1.el8.remi.x86_64                                                              2/9
  Installing  : php-common-7.3.10-1.el8.remi.x86_64                                                              2/9
  Installing  : libargon2-20171227-3.el8.x86_64                                                                  3/9
  Installing  : oniguruma-6.8.2-1.el8.x86_64                                                                     4/9
  執行指令小稿: oniguruma-6.8.2-1.el8.x86_64                                                                     4/9
  執行指令小稿: nginx-filesystem-1:1.14.1-8.module_el8.0.0+5+258f653c.noarch                                     5/9
  Installing  : nginx-filesystem-1:1.14.1-8.module_el8.0.0+5+258f653c.noarch                                     5/9
  Installing  : php-fpm-7.3.10-1.el8.remi.x86_64                                                                 6/9
  執行指令小稿: php-fpm-7.3.10-1.el8.remi.x86_64                                                                 6/9
  Installing  : php-mbstring-7.3.10-1.el8.remi.x86_64                                                            7/9
  Installing  : php-cli-7.3.10-1.el8.remi.x86_64                                                                 8/9
  Installing  : php-xml-7.3.10-1.el8.remi.x86_64                                                                 9/9
  執行指令小稿: php-xml-7.3.10-1.el8.remi.x86_64                                                                 9/9
  執行指令小稿: php-fpm-7.3.10-1.el8.remi.x86_64                                                                 9/9
  核驗        : nginx-filesystem-1:1.14.1-8.module_el8.0.0+5+258f653c.noarch                                     1/9
  核驗        : oniguruma-6.8.2-1.el8.x86_64                                                                     2/9
  核驗        : libargon2-20171227-3.el8.x86_64                                                                  3/9
  核驗        : php-cli-7.3.10-1.el8.remi.x86_64                                                                 4/9
  核驗        : php-common-7.3.10-1.el8.remi.x86_64                                                              5/9
  核驗        : php-fpm-7.3.10-1.el8.remi.x86_64                                                                 6/9
  核驗        : php-json-7.3.10-1.el8.remi.x86_64                                                                7/9
  核驗        : php-mbstring-7.3.10-1.el8.remi.x86_64                                                            8/9
  核驗        : php-xml-7.3.10-1.el8.remi.x86_64                                                                 9/9

已安裝:
  php-cli-7.3.10-1.el8.remi.x86_64                                      php-common-7.3.10-1.el8.remi.x86_64
  php-fpm-7.3.10-1.el8.remi.x86_64                                      php-json-7.3.10-1.el8.remi.x86_64
  php-mbstring-7.3.10-1.el8.remi.x86_64                                 php-xml-7.3.10-1.el8.remi.x86_64
  nginx-filesystem-1:1.14.1-8.module_el8.0.0+5+258f653c.noarch          oniguruma-6.8.2-1.el8.x86_64
  libargon2-20171227-3.el8.x86_64

完成!
[doraemon@centos8-gui ~]$ php -v
PHP 7.3.10 (cli) (built: Sep 24 2019 09:20:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.10, Copyright (c) 1998-2018 Zend Technologies

於 /var/www/html/ 目錄下,編寫一個 PHP 測試頁面,檔名為 info.php。再重啟 Apache 服務。

$ sudo vim /var/www/html/info.php
$ cat /var/www/html/info.php
<?php phpinfo(); ?>
$ sudo systemctl restart httpd

於另外一台電腦開啟 http://192.168.250.95/info.php 網頁

https://ithelp.ithome.com.tw/upload/images/20190930/20119707AMzoK5TphS.png


上一篇
Day26 CentOS Stream 圖形模式安裝後簡單設定
下一篇
Day28 CentOS Stream 安裝基本 LAMP 環境 (2)
系列文
30天學 LAMP 安裝33
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言