当前位置: 首页 > news >正文

第十九章 使用LAMP架构部署动态网站环境

第十九章 使用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]# yum install httpd		#安装httpd服务
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]# systemctl start httpd		#启动httpd服务
[root@Centos centos]# systemctl enable httpd	#设置开机自启动
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@Centos centos]# systemctl status httpd	#查看运行状态
● 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	#添加http服务允许通过防火墙
success
[centos@Centos ~]$ firewall-cmd --permanent --zone=public --add-service=https	#添加https服务允许通过防火墙
success
[centos@Centos ~]$ firewall-cmd --reload	#重启防火墙
success

在这里插入图片描述

4、验证http服务是否成功
http://192.168.2.119/	#浏览器中URL地址

在这里插入图片描述

二、安装Mariadb服务
1、安装Mariadb服务
root@Centos centos]# yum -y install mariadb-server		#安装mariadb服务

在这里插入图片描述

2、启动Mariadb服务
[root@Centos centos]# systemctl start mariadb		#启动mariadb服务
[root@Centos centos]# systemctl enable mariadb		#设置开机自启动
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]# systemctl status mariadb		#查看服务状态
● 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]# mysqladmin -uroot password 'mariadb#123'		#设置数据库密码

在这里插入图片描述

三、安装PHP服务
1、列出可用的PHP模块
[root@Centos centos]# yum module list php		#列出可用的PHP模块及版本号
上次元数据过期检查:0:15:30 前,执行于 20250906日 星期六 182022秒。
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]# yum module -y enable php:7.3		#启用PHP 7.3模块
上次元数据过期检查:0:17:30 前,执行于 20250906日 星期六 182022秒。
依赖关系解决。
=========================================================================================软件包         架构             版本            仓库            大小
=========================================================================================
启用模块流:nginx                         1.14         php                           7.3                                                                          事务概要
=========================================================================================完毕!

在这里插入图片描述

3、安装PHP及其MySQL原生驱动
[root@Centos centos]# yum install -y php php-mysqlnd		#安装PHP及其MySQL原生驱动

在这里插入图片描述

四、验证LAMP是否成功
1、创建页面并查看php版本信息
[root@Centos centos]# echo "<?php phpinfo(); ?>" > /var/www/html/test.php

在这里插入图片描述

2、验证LAMP是否成功
http://192.168.2.119/test.php		#浏览器中URL地址

在这里插入图片描述


文章转载自:

http://AhJyAg36.qyhcg.cn
http://A3IMjpiv.qyhcg.cn
http://lA4dCqSV.qyhcg.cn
http://gEhG03jU.qyhcg.cn
http://pOP09hWT.qyhcg.cn
http://A9bs0N8r.qyhcg.cn
http://7aEqSYl8.qyhcg.cn
http://gOu5dbVc.qyhcg.cn
http://XKfluKrl.qyhcg.cn
http://RUIMxdkg.qyhcg.cn
http://WdoelqZW.qyhcg.cn
http://eDJsjpO4.qyhcg.cn
http://gAPORitk.qyhcg.cn
http://1GR6BNZq.qyhcg.cn
http://iTdaegD5.qyhcg.cn
http://3LQnooLT.qyhcg.cn
http://IFGmHo0U.qyhcg.cn
http://w3s8A953.qyhcg.cn
http://HKp4dV2P.qyhcg.cn
http://1WtvXcmJ.qyhcg.cn
http://FXVP5wKb.qyhcg.cn
http://RzDKwezp.qyhcg.cn
http://HDNpXnEF.qyhcg.cn
http://XFp91ntl.qyhcg.cn
http://EO6VZKBn.qyhcg.cn
http://vO2uQahe.qyhcg.cn
http://pqzkkZGM.qyhcg.cn
http://ypnwA1yn.qyhcg.cn
http://4qzDFRbW.qyhcg.cn
http://ue4RBRRy.qyhcg.cn
http://www.dtcms.com/a/375984.html

相关文章:

  • 谷歌nano banana官方Prompt模板发布,解锁六大图像生成风格
  • 转载:VSCODE 关闭文件和资源管理器关联
  • Windows 常用命令使用说明
  • Win_Server远程桌面(RDP)服务调用GPU并提上传输帧率和USB设备重定向
  • 【小呆的随机振动力学笔记】概率论基础
  • hipcc编译不生成可执行文件只输出版本信息问题
  • MatDEM一体机的技术深度分析
  • linux三剑客
  • 交换排序——冒泡排序与快速排序
  • DIY项目-校遇
  • GEO 优化系统开发:技术架构与核心实现方案
  • 【66页PPT】质量管理体系五种核心工具APQP(附下载方式)
  • MySQL InnoDB Cluster介绍,MHA、PXC、InnoDB Cluster怎么选?一文讲透MySQL高可用方案最佳实践
  • Miniconda3搭建Selenium的python虚拟环境全攻略
  • 01背包,完全背包,分组背包,多重背包例题
  • Ansible之playbook
  • MapReduce :Map阶段分区后,数据怎么找到Reducer?
  • 项目研发实录:电子称SDK封装dll给到QT和C#调用
  • 短视频矩阵源码-视频剪辑+AI智能体开发接入技术分享
  • 代码随想录算法训练营第三十五天|背包问题 二维 背包问题 一维 46. 携带研究材料 416. 分割等和子集
  • FTP文件传输服务
  • 代码随想录第七天|● 454.四数相加II ● 383. 赎金信 ● 15. 三数之和 18.四数之和
  • SAP R/3系统模块结构
  • leetcode 217 存在重复元素
  • 前端 Word 模板参入特定数据 并且下载
  • LeetCode 003. 无重复字符的最长子串 - 滑动窗口与哈希表详解
  • 深度学习(五):过拟合、欠拟合与代价函数
  • 【JS】import.meta.env,process.env,window三种环境变量获取方式的区别
  • 交付只是起点:从“纸上蓝图”到“价值闭环”的保障实践,数字孪生保障落地的“三重防护网
  • LLM大模型-大模型 API 集成使用、部署本地大模型(huggingface、modelscope)、实现Qwen和Deepseek本地部署