如何在 Fedora 36 上配置 LAMP 环境?

本文将逐步向您展示如何在 Fedora 36 上安装 LAMP 集成环境。

LAMP 是一组用于构建基于 web 的应用程序的开源工具,它包括以下工具:

  • L: Linux (物理机,虚拟机,者容器)
  • A : Apache Web Server
  • M: MariaDB / MySQL
  • P: PHP

LAMP 是 WordPress、Drupal、Joomla 和 OpenCart 等 web 程序的基石。

先决条件

  • Minimal Installed Fedora 36
  • Sudo User with admin rights
  • Internet Connectivity

(1) 安装 Apache

在 Fedora Linux 中,dnf 是默认的 Package Manager,软件或 RPM 包通过 dnf 安装。

Apache Web Server (httpd) RPM 包在默认库中可用,因此可以直接安装

$ sudo dnf install -y httpd

Install-Apache-Fedora-Linux

查看 Apache 版本

$ sudo rpm -q httpd
httpd-2.4.54-3.fc36.x86_64
$

启动 Apache (httpd)服务

$ sudo systemctl start httpd
$ sudo systemctl enable httpd

查看 httpd 服务状态

$ sudo systemctl status httpd

Apache-Service-Check-Fedora-Linux

防火墙放行 http 端口

$ sudo firewall-cmd --permanent --add-service=http
$ sudo firewall-cmd --permanent --add-service=https
$ sudo firewall-cmd --reload

访问 127.0.0.1 或者本机 IP 验证 Apache 安装

Default-Apache-WebPage-Fedora-Linux

(2) 安装 MariaDB 数据库服务器

MariaDB 及其依赖项在 Fedora 36 的默认包存储库中可用。执行以下命令安装它。

$ sudo dnf install mariadb-server mariadb -y

MariaDB-Install-Fedora-Linux

启动并启用 mariadb 服务

$ sudo systemctl enable mariadb --now

检查 mariadb 服务状态

$ sudo systemctl status mariadb

Secure MariaDB installation by configuring initial settings of database and root password using “mysql_secure_installation”

使用 mysql_secure_installation 配置数据库和 root 密码的初始设置

$ sudo mysql_secure_installation

Secure-MariaDB-Installation-Fedora-Linux-Part1

Secure-MariaDB-Installation-Fedora-Linux-Part2

(3) 安装 PHP

PHP 是一种用于构建 web 应用程序的开源服务器端脚本语言。最新的 php 8.1 及其依赖项也可在默认包存储库中使用。

$ sudo dnf install -y php php-common php-cli

Install-PHP-Fedora-Linux-Dnf-Command

要测试 PHP 安装,请在 /var/www/html 中创建一个 PHP 文件 (fedora.php)

$ sudo vi /var/www/html/fedora.php
<?php
phpinfo()
?>

重启 apache 服务

$ sudo systemctl restart httpd

从浏览器访问 fedora.php 文件

PHP-Default-Apache-Fedora-Linux

上面的页面证实了 PHP 8.1 已成功安装。

我的开源项目

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值