在 RHEL 8 服务器上安装 MariaDB 10.3 数据库

以 root 用户身份使用 ssh 连接到 rhel-8-lemp.onitroad.com。

MariaDB Server 10.3 在 RHEL 8 本地 AppStream 存储库中可用。
因此,我们可以使用 dnf 命令轻松安装它。

[root@rhel-8-lemp ~]# dnf install -y mariadb-server

启用并启动 MariaDB 服务。

[root@rhel-8-lemp ~]# systemctl enable mariadb.service
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@rhel-8-lemp ~]# systemctl start mariadb.service

配置和保护 MariaDB 数据库实例。

[root@rhel-8-lemp ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
 ... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
 ... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
在 RHEL 8 服务器上安装 LEMP 堆栈

LEMP 是一种流行的软件堆栈。
LEMP 以构成 Stack 的四种软件的首字母命名,例如:Linux 、 Nginx 、 MySQL 和 PHP 。
LEMP 用于使用 MySQL 数据库后端部署基于 PHP 的 Web 应用程序。

在本文中,我们将在 RHEL 8 服务器上安装 LEMP 堆栈。

on  It Road.com

在 RHEL 8 上安装 Nginx Web Server 1.14

Nginx 1.14 在本地 AppStream 存储库中可用。
因此,我们可以使用 dnf 命令安装它。

[root@rhel-8-lemp ~]# yum install -y nginx

启用并启动 Nginx 服务。

[root@rhel-8-lemp ~]# systemctl enable nginx.service
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service -> /usr/lib/systemd/system/nginx.service.
[root@rhel-8-lemp ~]# systemctl start nginx.service

在 Linux 防火墙中允许 HTTP 服务。

[root@rhel-8-lemp ~]# firewall-cmd --permanent --add-service=http
success
[root@rhel-8-lemp ~]# firewall-cmd --reload
success

在客户端浏览器中浏览 URL http://rhel-8-lemp.onitroad.com。

Nginx Web 服务器已安装并在 RHEL 8 上运行良好。

在 RHEL 8 上安装 PHP 7.2

PHP 7.2 在本地 AppStream 存储库中可用。
因此,我们可以使用 dnf 命令安装它。

[root@rhel-8-lemp ~]# dnf install -y php php-mysqlnd php-pdo php-gd php-mbstring php-fpm

编辑 php-fpm 配置。

[root@rhel-8-lemp ~]# vi /etc/php-fpm.d/www.conf

其中找到并设置以下设置。

user = nginx
group = nginx
listen.owner = nginx
listen.group = nginx

启动并启用 php-fpm 服务。

[root@rhel-8-lemp ~]# systemctl enable php-fpm.service
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service -> /usr/lib/systemd/system/php-fpm.service.
[root@rhel-8-lemp ~]# systemctl start php-fpm.service

重启 Nginx 服务,将 PHP 与 Nginx 集成。

[root@rhel-8-lemp ~]# systemctl restart nginx.service

创建一个 PHP 文件以检查有关已安装 PHP 模块的信息。

[root@rhel-8-lemp ~]# echo "<?php phpinfo() ?>" > /usr/share/nginx/html/info.php

在客户端浏览器中浏览 URL http://rhel-8-lemp.onitroad.com/info.php。

PHP 7.2 已在 RHEL 8 上安装并运行。

我们已经在 RHEL 8 服务器上成功安装了 LEMP 堆栈。

日期:2020-09-17 00:12:41 来源:oir作者:oir