第十九章 使用LAMP架構部署動態網站環境
文章目錄 第十九章 使用LAMP架構部署動態網站環境 一、安裝Httpd服務 1、安裝httpd服務 2、啟動httpd服務 3、設置允許通過防火墻 4、驗證http服務是否成功 二、安裝Mariadb服務 1、安裝Mariadb服務 2、啟動Mariadb服務 三、安裝PHP服務 1、列出可用的PHP模塊 2、啟用PHP 7.3模塊 3、安裝PHP及其MySQL原生驅動 四、驗證LAMP是否成功 1、創建頁面并查看php版本信息 2、驗證LAMP是否成功
一、安裝Httpd服務
1、安裝httpd服務
[ root@Centos centos]
CentOS- 8.5 .2111 - Base - mirrors. aliyun. com 5.7 MB/ s | 4.6 MB 00 : 00
CentOS- 8.5 .2111 - Extras - mirrors. aliyun. com 47 kB/ s | 10 kB 00 : 00
CentOS- 8.5 .2111 - AppStream - mirrors. aliyun. com 5.4 MB/ s | 8.4 MB 00 : 01
2、啟動httpd服務
[ root@Centos centos]
[ root@Centos centos]
Created symlink / etc/ systemd/ system/ multi- user. target. wants/ httpd. service → / usr/ lib/ systemd/ system/ httpd. service.
[ root@Centos centos]
● httpd. service - The Apache HTTP ServerLoaded: loaded ( / usr/ lib/ systemd/ system/ httpd. service; enabled; vendor preset: disabled) Active: active ( running) since Sat 2025 - 09 - 06 18 : 25 : 01 CST; 29s agoDocs: man: httpd. service( 8 ) Main PID: 40539 ( httpd) Status: "Running, listening on: port 80" Tasks: 213 ( limit: 11087 ) Memory: 17 . 2MCGroup: / system. slice / httpd. service├─40539 / usr/ sbin/ httpd - DFOREGROUND├─40546 / usr/ sbin/ httpd - DFOREGROUND├─40547 / usr/ sbin/ httpd - DFOREGROUND├─40548 / usr/ sbin/ httpd - DFOREGROUND└─40549 / usr/ sbin/ httpd - DFOREGROUND
3、設置允許通過防火墻
[ centos@Centos ~ ] $ firewall- cmd - - permanent - - zone= public - - add- service= http
success
[ centos@Centos ~ ] $ firewall- cmd - - permanent - - zone= public - - add- service= https
success
[ centos@Centos ~ ] $ firewall- cmd - - reload
success
4、驗證http服務是否成功
http: // 192.168 .2 .119 /
二、安裝Mariadb服務
1、安裝Mariadb服務
root@Centos centos]
2、啟動Mariadb服務
[ root@Centos centos]
[ root@Centos centos]
Created symlink / etc/ systemd/ system/ mysql. service → / usr/ lib/ systemd/ system/ mariadb. service.
Created symlink / etc/ systemd/ system/ mysqld. service → / usr/ lib/ systemd/ system/ mariadb. service.
Created symlink / etc/ systemd/ system/ multi- user. target. wants/ mariadb. service → / usr/ lib/ systemd/ system/ mariadb. service.
[ root@Centos centos]
● mariadb. service - MariaDB 10.3 database serverLoaded: loaded ( / usr/ lib/ systemd/ system/ mariadb. service; enabled; vendor preset: disabled) Active: active ( running) since Sat 2025 - 09 - 06 18 : 33 : 08 CST; 1min 8s agoDocs: man: mysqld( 8 ) https: // mariadb. com/ kb/ en/ library/ systemd/ Main PID: 42001 ( mysqld) Status: "Taking your SQL requests now..." Tasks: 30 ( limit: 11087 ) Memory: 76 . 9MCGroup: / system. slice / mariadb. service└─42001 / usr/ libexec/ mysqld - - basedir= / usr[ root@Centos centos]
三、安裝PHP服務
1、列出可用的PHP模塊
[ root@Centos centos]
上次元數據過期檢查:0 : 15 : 30 前,執行于 2025 年09 月06 日 星期六 18 時20 分22 秒。
CentOS- 8.5 .2111 - AppStream - mirrors. aliyun. com
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 提示:[ d] 默認,[ e] 已啟用,[ x] 已禁用,[ i] 已安裝
2、啟用PHP 7.3模塊
[ root@Centos centos]
上次元數據過期檢查:0 : 17 : 30 前,執行于 2025 年09 月06 日 星期六 18 時20 分22 秒。
依賴關系解決。
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == = 軟件包 架構 版本 倉庫 大小
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
啟用模塊流: nginx 1.14 php 7.3 事務概要
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == = 完畢!
3、安裝PHP及其MySQL原生驅動
[ root@Centos centos]
四、驗證LAMP是否成功
1、創建頁面并查看php版本信息
[ root@Centos centos]
2、驗證LAMP是否成功
http: // 192.168 .2 .119 / test. php