在RHEL 8上安装MariaDB

MariaDB可以用来替代Oracle MySQL服务器。
执行以下dnf命令:

$ sudo dnf install mariadb-server

启用和启动/停止/重启MariaDB服务

设置MariDB服务开机自启动:

$ sudo systemctl enable mariadb.service

在RHEL 8中使用systemctl命令停止/停止/重启MariDB服务:

sudo systemctl start mariadb.service 
sudo systemctl stop mariadb.service 
sudo systemctl restart mariadb.service 
sudo systemctl status mariadb.service

对MariaDB服务器进行安全性设置:

$ sudo mysql_secure_installation

在RHEL 8上安装PHP 7.x

安装PHP 7.2和流行的PHP模块:

$ sudo dnf install php php-mysqlnd php-mbstring php-opcache php-gd

必须重启httpd服务才能访问PHP:

$ sudo systemctl restart httpd.service

搜索并安装其他PHP模块

PHP附带许多模块。可以使用以下语法搜索:

$ sudo dnf search php-
$ sudo dnf search php- | grep -i mysql

查看有关php-mbstring的信息

$ dnf info {php_module_package_name_here}
$ sudo dnf info php-mbstring

安装php-mbstring,运行:

$ sudo dnf install php-mbstring

测试PHP安装

在/var/www/html /目录中创建一个php文件:

$ sudo vi /var/www/html/test.php

代码如下:

<?php
   phpinfo();
?>

在浏览器中打开

http://服务器ip/test.php
如何在RHEL 8上安装Linux,Apache,MySQL,PHP(LAMP)

如何在RHEL(Red Hat Enterprise Linux)8上安装Linux,Apache,MySQL/MariaDB,PHP(LAMP)?
如何在RHEL 8云服务器上安装LAMP技术栈?

LAMP堆栈是一组流行的软件,用于构建和运行动态网站和应用程序。
LAMP是下面软件的首字母缩写:

  • Linux操作系统
  • Apache 用于提供Web服务
  • MySQL或MariaDB服务器用于存储数据
  • PHP用于服务器端动态Web生成编程语言

在RHEL 8上安装Apache(HTTPD)

使用dnf命令安装:

$ sudo dnf install httpd

所有Apache配置文件如下:

  • /etc/httpd /Apache主配置目录
  • /etc/httpd/conf/httpd.conf主要的Aapache配置文件。
  • /var/log/httpd /保存Apache错误和访问日志文件
  • /var/log/httpd/access_log访问日志
  • /var/log/httpd/error_log错误日志
  • /etc/httpd/conf.modules.dApache模块(例如代理,php等)的配置目录

在默认配置中,httpd守护程序将在端口80上监听(如果安装了mod_ssl,则在端口443上接受TLS连接)。

如何启用httpd服务

运行以下systemctl命令,在引导时启动httpd服务:

sudo systemctl enable httpd.service

RHEL/CentOS上启动/停止/重启httpd的命令

sudo systemctl start httpd.service  
sudo systemctl stop httpd.service 
sudo systemctl restart httpd.service 
sudo systemctl reload httpd.service  
sudo systemctl status httpd.service 

通过运行ss命令和grep命令来验证端口80是否打开:

$ sudo ss -tulpn
$ sudo ss -tulpn | grep :80

配置防火墙

在RHEL 8 防火墙上打开HTTP端口80:

$ sudo firewall-cmd --permanent --add-service=http --zone=public
$ sudo firewall-cmd --reload
$ sudo firewall-cmd --list-services --zone=public

测试apache安装

查看服务器的IP地址:

ip a
ip a s ens3
ip a s eth0
ip a s ens3 | grep -w inet | awk '{ print }'

在浏览器中打开

http://服务器IP
http://rhel8.onitroad.local/

我们将能看到Apache的默认页面

更新RHEL 8服务器

只需运行以下dnf命令:

$ sudo dnf update
日期:2020-03-23 08:03:57 来源:oir作者:oir