第十九章 使用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