CentOS 8.1下搭建LAMP(Linux+Apache+MySQL+PHP)环境(2)

[linuxidc@localhost ~/www.linuxidc.com]$systemctl start mariadb
[linuxidc@localhost ~/www.linuxidc.com]$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.

CentOS 8.1下搭建LAMP(Linux+Apache+MySQL+PHP)环境

您可以通过运行命令来验证MariaDB的状态。

mariadb.service - MariaDB 10.3 database server
  Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor pre>
  Active: active (running) since Wed 2020-02-26 07:23:30 EST; 47s ago
    Docs: man:mysqld(8)
          https://mariadb.com/kb/en/library/systemd/
 Main PID: 90101 (mysqld)
  Status: "Taking your SQL requests now..."
    Tasks: 30 (limit: 23820)
  Memory: 81.7M
  CGroup: /system.slice/mariadb.service
          └─90101 /usr/libexec/mysqld --basedir=/usr
~

CentOS 8.1下搭建LAMP(Linux+Apache+MySQL+PHP)环境

最后,我们需要通过secure来保护MariaDB数据库引擎。

[linuxidc@localhost ~/www.linuxidc.com]$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):

CentOS 8.1下搭建LAMP(Linux+Apache+MySQL+PHP)环境

系统将提示您输入root密码(如果您已经有root密码)或进行设置。在随后的每个提示中回答Y。

CentOS 8.1下搭建LAMP(Linux+Apache+MySQL+PHP)环境

步骤4:在CentOS 8上安装PHP 7

我们需要安装的LAMP堆栈中的最后一个组件是PHP,并且如前所述,PHP是用于开发动态网页的脚本Web编程语言。

我们将使用Remi信息库安装最新版本的PHP(在撰写本指南时为PHP 7.4)。

首先,安装EPEL存储库。

[linuxidc@localhost ~/www.linuxidc.com]$sudo dnf install https://dl.Fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

CentOS 8.1下搭建LAMP(Linux+Apache+MySQL+PHP)环境

接下来,安装yum utils并使用以下命令启用remi-repository。

[linuxidc@localhost ~/www.linuxidc.com]$sudo dnf install dnf-utils

CentOS 8.1下搭建LAMP(Linux+Apache+MySQL+PHP)环境

成功安装yum-utils和Remi-packages之后,通过运行命令搜索可下载的PHP模块。

[linuxidc@localhost ~/www.linuxidc.com]$sudo dnf module list php

输出将包括可用的PHP模块,流和安装配置文件,如下所示。

Extra Packages for Enterprise Linux 8 - x86_64  3.3 MB/s | 5.9 MB    00:01   
Remi's Modular repository for Enterprise Linux  7.1 kB/s | 535 kB    01:15   
Safe Remi's RPM repository for Enterprise Linux 3.7 kB/s | 1.4 MB    06:27   
上次元数据过期检查:0:00:03 前,执行于 2020年02月26日 星期三 07时39分24秒。
CentOS-8 - AppStream
Name    Stream        Profiles                      Summary                 
php      7.2 [d][e]    common [d], devel, minimal    PHP scripting language 
php      7.3            common, devel, minimal        PHP scripting language 

Remi's Modular repository for Enterprise Linux 8 - x86_64
Name    Stream        Profiles                      Summary                 
php      remi-7.2      common [d], devel, minimal    PHP scripting language 
php      remi-7.3      common [d], devel, minimal    PHP scripting language 
php      remi-7.4      common [d], devel, minimal    PHP scripting language 

CentOS 8.1下搭建LAMP(Linux+Apache+MySQL+PHP)环境

 

提示:[d]默认,[e]已启用,[x]已禁用,[i]已安装

输出表明当前安装的PHP版本是PHP 7.2。要安装较新的版本PHP 7.4,请重置PHP模块。

[linuxidc@localhost ~/www.linuxidc.com]$sudo dnf module reset php

CentOS 8.1下搭建LAMP(Linux+Apache+MySQL+PHP)环境

重置PHP模块后,通过运行启用PHP 7.4模块。

[linuxidc@localhost ~/www.linuxidc.com]$sudo dnf module enable php:remi-7.4

CentOS 8.1下搭建LAMP(Linux+Apache+MySQL+PHP)环境

最后,使用命令安装PHP,PHP-FPM(FastCGI进程管理器)和关联的PHP模块。

[linuxidc@localhost ~/www.linuxidc.com]$ sudo dnf install php php-opcache php-gd php-curl php-mysqlnd

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/2a45db40e1e9303a667c95665f589b20.html