如何在RHEL、CentOS及Fedora上安装Drupal 8

系统 Linux 系统运维
Drupal 是一个开源,灵活,高度可拓展和安全的内容管理系统Content Management System(CMS),使用户轻松的创建网站。

如何在RHEL、CentOS及Fedora上安装Drupal 8

Drupal 是一个开源,灵活,高度可拓展和安全的内容管理系统Content Management System(CMS),使用户轻松的创建网站。

它可以使用模块拓展,使用户将内容管理转换为强大的数字解决方案。

Drupal 运行在诸如 Apache、IIS、Lighttpd、Cherokee、Nginx 的 Web 服务器上,后端数据库可以使用 MySQL、MongoDB、MariaDB、PostgreSQL、MSSQL Server。

在这篇文章中, 我们会展示在 RHEL 7/6、CentOS 7/6 和 Fedora 20-25 发行版上使用 LAMP 架构,如何手动安装和配置 Drupal 8。

Drupal 需求:

  1. Apache 2.x (推荐)
  2. PHP 5.5.9 或 更高 (推荐 PHP 5.5)
  3. MySQL 5.5.3 或 MariaDB 5.5.20 与 PHP 数据对象(PDO) 支持

安装过程中,我使用 drupal.tecmint.com 作为网站主机名,IP 地址为 192.168.0.104。你的环境也许与这些设置不同,因此请适当做出更改。

步骤 1:安装 Apache Web 服务器

1、 首先我们从官方仓库开始安装 Apache Web 服务器。

# yum install httpd

2、 安装完成后,服务开始是被禁用的,因此我们需要手动启动它,同时让它下次系统启动时自动启动,如下: 

  1. -------------  通过 SystemD - CentOS/RHEL 7 和 Fedora 22+ ------------------- 
  2. # systemctl start httpd  
  3. # systemctl enable httpd 
  4. -------------  通过 SysVInit - CentOS/RHEL 6 和 Fedora ---------------------- 
  5. # service httpd start 
  6. # chkconfig --level 35 httpd on 

3、 接下来,为了允许通过 HTTP 和 HTTPS 访问 Apache 服务,我们必须打开 HTTPD 守护进程正在监听的 80 和 443 端口,如下所示:

  1. ------------ 通过 Firewalld - CentOS/RHEL 7 and Fedora 22+ -------------  
  2. # firewall-cmd --permanent --zone=public --add-service=http 
  3. # firewall-cmd --permanent --zone=public --add-service=https 
  4. # firewall-cmd --reload 
  5. ------------ 通过 IPtables - CentOS/RHEL 6 and Fedora 22+ -------------  
  6. # iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT 
  7. # iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT 
  8. # service iptables save 
  9. # service iptables restart  

4、 现在验证 Apache 是否正常工作, 打开浏览器在地址栏中输入 http://server_IP, 输入你的服务器 IP 地址, 默认 Apache2 页面应出现,如下面截图所示:

Apache 默认页面 

Apache 默认页面

步骤 2: 安装 Apache PHP 支持

5、 接下来,安装 PHP 和 PHP 所需模块。

  1. # yum install php php-mbstring php-gd php-xml php-pear php-fpm php-mysql php-pdo php-opcache 

重要: 假如你想要安装 PHP7, 你需要增加以下仓库:EPEL 和 Webtactic 才可以使用 yum 安装 PHP7.0:

  1. ------------- Install PHP 7 in CentOS/RHEL and Fedora -------------  
  2. # rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 
  3. # rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 
  4. # yum install php70w php70w-opcache php70w-mbstring php70w-gd php70w-xml php70w-pear php70w-fpm php70w-mysql php70w-pdo 

6、 接下来,要从浏览器得到关于 PHP 安装和配置完整信息,使用下面命令在 Apache 文档根目录 (/var/www/html) 创建一个 info.php 文件。

  1. # echo "<?php  phpinfo(); ?>" > /var/www/html/info.php 

然后重启 HTTPD 服务器 ,在浏览器地址栏输入 http://server_IP/info.php。

  1. # systemctl restart httpd 
  2. 或 
  3. # service httpd restart 

验证 PHP 信息 

验证 PHP 信息

步骤 3: 安装和配置 MariaDB 数据库

7、 请知晓, Red Hat Enterprise Linux/CentOS 7.0 从支持 MySQL 转为了 MariaDB 作为默认数据库管理系统。

要安装 MariaDB 数据库, 你需要添加 官方 MariaDB 库 到 /etc/yum.repos.d/MariaDB.repo 中,如下所示。

  1. [mariadb] 
  2. name = MariaDB 
  3. baseurl = http://yum.mariadb.org/10.1/centos7-amd64 
  4. gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB 
  5. gpgcheck=1 

当仓库文件准备好后,你可以像这样安装 MariaDB:

  1. # yum install mariadb-server mariadb 

8、 当 MariaDB 数据库安装完成,启动数据库的守护进程,同时使它能够在下次启动后自动启动。

  1. ------------- 通过 SystemD - CentOS/RHEL 7 and Fedora 22+ -------------  
  2. # systemctl start mariadb 
  3. # systemctl enable mariadb 
  4. ------------- 通过 SysVInit - CentOS/RHEL 6 and Fedora -------------  
  5. # service mysqld start 
  6. # chkconfig --level 35 mysqld on 

9、 然后运行 mysql_secure_installation 脚本去保护数据库(设置 root 密码, 禁用远程登录,移除测试数据库并移除匿名用户),如下所示:

  1. # mysql_secure_installation 

MySQL 安全安装 

MySQL 安全安装

步骤 4: 在 CentOS 中安装和配置 Drupal 8

10、 这里我们使用 wget 命令 下载***版本 Drupal(例如 8.2.6),如果你没有安装 wget 和 gzip 包 ,请使用下面命令安装它们:

  1. # yum install wget gzip 
  2. # wget -c https://ftp.drupal.org/files/projects/drupal-8.2.6.tar.gz 

11、 之后,解压 tar 文件 并移动 Drupal 目录到 Apache 文档根目录(/var/www/html)。

  1. # tar -zxvf drupal-8.2.6.tar.gz 
  2. # mv drupal-8.2.6 /var/www/html/drupal 

12、 然后,依据 /var/www/html/drupal/sites/default 目录下的示例设置文件 default.settings.php,创建设置文件 settings.php,然后给 Drupal 站点目录设置适当权限,包括子目录和文件,如下所示:

  1. # cd /var/www/html/drupal/sites/default
  2. # cp default.settings.php settings.php 
  3. # chown -R apache:apache /var/www/html/drupal/ 

13、 更重要的是在 /var/www/html/drupal/sites/ 目录设置 SElinux 规则,如下:

  1. # chcon -R -t httpd_sys_content_rw_t /var/www/html/drupal/sites/ 

14、 现在我们必须为 Drupal 站点去创建一个用于管理的数据库和用户。

  1. # mysql -u root -p 
  2. Enter password:  
  3. MySQL Shell 
  4. Welcome to the MariaDB monitor.  Commands end with ; or \g. 
  5. Your MySQL connection id is 12 
  6. Server version: 5.1.73 Source distribution 
  7. Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. 
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 
  9. **MySQL [(none)]> create database drupal;** 
  10. Query OK, 1 row affected (0.00 sec) 
  11. **MySQL [(none)]> create user ravi@localhost identified by 'tecmint123';** 
  12. Query OK, 0 rows affected (0.00 sec) 
  13. **MySQL [(none)]> grant all on drupal.* to ravi@localhost;** 
  14. Query OK, 0 rows affected (0.00 sec) 
  15. **MySQL [(none)]> flush privileges;** 
  16. Query OK, 0 rows affected (0.00 sec) 
  17. **MySQL [(none)]> exit** 
  18. Bye 

15、 ***,打开地址: http://server_IP/drupal/ 开始网站的安装,选择你***的安装语言然后点击保存以继续。

Drupal 安装语言 

Drupal 安装语言

16、 下一步,选择安装配置文件,选择 Standard(标准),点击保存继续。

Drupal 安装配置文件 

Drupal 安装配置文件

17、 在进行下一步之前查看并通过需求审查并启用 Clean URL。

验证 Drupal 需求 

验证 Drupal 需求

现在在你的 Apache 配置下启用 Clean URL 的 Drupal。

  1. # vi /etc/httpd/conf/httpd.conf 

确保为默认根文档目录 /var/www/html 设置 AllowOverride All,如下图所示:

在 Drupal 中启用 Clean URL 

在 Drupal 中启用 Clean URL

18、 当你为 Drupal 启用 Clean URL,刷新页面从下面界面执行数据库配置,输入 Drupal 站点数据库名,数据库用户和数据库密码。

当填写完所有信息点击保存并继续。

Drupal 数据库配置 

Drupal 数据库配置

若上述设置正确,Drupal 站点安装应该完成了,如下图界面。

Drupal 安装 

Drupal 安装

19、 接下来配置站点为下面的设置(使用适用你的情况的值):

  • 站点名称 – TecMint Drupal Site
  • 站点邮箱地址 – admin@tecmint.com
  • 用户名 – admin
  • 密码 – ##########
  • 用户的邮箱地址 – admin@tecmint.com
  • 默认国家 – India
  • 默认时区 – UTC

设置适当的值后,点击保存并继续完成站点安装过程。

Drupal 站点配置 

Drupal 站点配置

20、下图显示的是通过 LAMP 成功安装的 Drupal 8 站点。

Drupal 站点面板 

Drupal 站点面板

现在你可以点击增加内容,创建示例网页内容。

选项: 有些人使用 MySQL 命令行管理数据库不舒服,可以从浏览器界面 安装 PHPMYAdmin 管理数据库

浏览 Drupal 文档 : https://www.drupal.org/docs/8

就这样! 在这个文章, 我们展示了在 CentOS 7 上如何去下载、安装和使用基本配置来设置 LAMP 以及 Drupal 8。 欢迎就这个教程提供反馈,或提供给我们一些相关信息。 

责任编辑:庞桂玉 来源: Linux中国
相关推荐

2017-04-11 13:20:06

CentOSRHELFedora

2020-03-02 14:06:54

CentOS 8FFmpegLinux

2019-12-02 11:50:09

CentOS 8VirtualBoxLinux

2019-10-12 10:24:06

CentOSRHELCockpit

2023-03-16 08:55:51

RHEL 8MiniKube开源

2019-11-14 09:20:15

CentOS 8RHEL 8Nagios Core

2019-10-14 15:00:12

Centos 8 RHEL 8VNC

2019-12-02 15:45:53

CentOS 8AnsibleLinux

2023-11-26 16:23:16

FedoraVSCodium

2015-12-21 13:19:23

CentosRHEL 6.XWetty

2016-11-08 08:51:43

GitLinux开源

2023-05-05 16:20:15

2023-05-13 17:32:51

2021-11-28 06:33:24

Discord消息收发应用 Linux

2022-10-17 06:34:28

FedoraLinuxRPM Fusion

2021-08-18 11:19:25

FedoraLinuxJava

2020-12-28 06:44:45

FedoraLinux RPM文件

2019-11-05 11:20:36

CentOS 8RHEL 8Linux

2014-10-11 11:30:43

CentOSDocker

2019-09-27 08:52:12

RHELCentOSElastic sta
点赞
收藏

51CTO技术栈公众号