阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 7.5 安装部署 Drupal 8.6.4 图文详解

137次阅读
没有评论

共计 5443 个字符,预计需要花费 14 分钟才能阅读完成。

Drupal 8.6.4 是目前一款流行的 Drupal 内容管理系统的最新版本。本指南详细演示了如何在运行 CentOS 7.5 或 CentOS 7.x 上安装部署 Drupal 8.6.4 的详细步骤及注意事项。

本指南将尽可能地使用 sudo。完成我们保护您的服务器指南的部分,以创建一个标准的用户帐户,加强 SSH 访问,删除不必要的网络服务,并为您的 web 服务器创建防火墙规则; 您可能需要为您的特定应用程序创建额外的防火墙异常。

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

CentOS 7.5 安装部署 Drupal 8.6.4 图文详解

Drupal 8 配置要求:

  • 数据库:MySQL 5.5.3/MariaDB 5.5.20
  • 网站服务器:Apache 2.x
  • PHP 版本:5.5, 5.6, 7.0, 7.1, 7.2(Drupal 8.4.4 之前版本只支持 php 7.1 及之前版本)

第 1 步:安装 Apache Web 服务器

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

#yum install httpd

CentOS 7.5 安装部署 Drupal 8.6.4 图文详解

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

————- 通过 SystemD-CentOS/RHEL 7 和 Fedora22+——————-
#systemctl start httpd
#systemctl enable httpd
————- 通过 SysVInit-CentOS/RHEL 6 和 Fedora———————-
# service httpd start
# chkconfig –level 35 httpd on

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

———— 通过 Firewalld-CentOS/RHEL 7andFedora22+————-
# firewall-cmd –permanent –zone=public–add-service=http
# firewall-cmd –permanent –zone=public–add-service=https
# firewall-cmd –reload
———— 通过 IPtables-CentOS/RHEL 6andFedora22+————-
# iptables -A INPUT -p tcp -m tcp –dport 80-j ACCEPT
# iptables -A INPUT -p tcp -m tcp –dport 443-j ACCEPT
# service iptables save
# service iptables restart

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

CentOS 7.5 安装部署 Drupal 8.6.4 图文详解

Apache 默认页面

第 2 步:安装 Apache PHP 支持

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

#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:

————-Install PHP 7inCentOS/RHEL andFedora————-
# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
#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 文件。

#echo”<?php phpinfo(); ?>”>/var/www/html/info.php
然后重启 HTTPD 服务器,在浏览器地址栏输入 http://server_IP/info.php。

#systemctl restart httpd

# service httpd restart

CentOS 7.5 安装部署 Drupal 8.6.4 图文详解

验证 PHP 信息

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

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

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

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

以上是官方源,下载很慢,这里我们用阿里源,内容如下:

[mariadb]
name = MariaDB
baseurl = http://mirrors.aliyun.com/mariadb/yum/10.3/centos7-amd64/
gpgkey =  http://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1

CentOS 7.5 安装部署 Drupal 8.6.4 图文详解

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

#yum install MariaDB-server MariaDB-client

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

————- 通过 SystemD-CentOS/RHEL 7andFedora22+————-
#systemctl start mariadb
#systemctl enable mariadb
————- 通过 SysVInit-CentOS/RHEL 6andFedora————-
# service mysqld start
# chkconfig –level 35 mysqld on

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

# mysql_secure_installation

先是设置密码,会提示先输入密码

Enter current password for root (enter for none):<–初次运行直接回车

设置密码

Set root password? [Y/n] <– 是否设置 root 用户密码,输入 y 并回车或直接回车

New password: <– 设置 root 用户的密码

Re-enter new password: <– 再输入一次你设置的密码

其他配置

Remove anonymous users? [Y/n] <– 是否删除匿名用户,Y,回车

Disallow root login remotely? [Y/n] <–是否禁止 root 远程登录,N,回车,

Remove test database and access to it? [Y/n] <– 是否删除 test 数据库,Y, 回车

Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车

初始化 MariaDB 完成,接下来测试登录

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

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

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

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

#tar -zxvf drupal-8.6.4.tar.gz
#mv drupal-8.6.4/var/www/html/drupal

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

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

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

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

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

[root@localhost default]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.3.11-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]> create database drupal;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> create user linuxidc@localhost identified by ‘linuxidc’;
Query OK, 0 rows affected (0.006 sec)

MariaDB [(none)]> grant all on drupal.* to linuxidc@localhost;
Query OK, 0 rows affected (0.005 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.005 sec)

MariaDB [(none)]> exit
Bye

CentOS 7.5 安装部署 Drupal 8.6.4 图文详解

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

CentOS 7.5 安装部署 Drupal 8.6.4 图文详解

Drupal 安装语言

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

CentOS 7.5 安装部署 Drupal 8.6.4 图文详解

Drupal 安装配置文件

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

CentOS 7.5 安装部署 Drupal 8.6.4 图文详解

验证 Drupal 需求

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

#nano /etc/httpd/conf/httpd.conf

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

CentOS 7.5 安装部署 Drupal 8.6.4 图文详解

在 Drupal 中启用 Clean URL

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

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

CentOS 7.5 安装部署 Drupal 8.6.4 图文详解

Drupal 数据库配置

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

CentOS 7.5 安装部署 Drupal 8.6.4 图文详解

Drupal 安装

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

站点名称  – Linux 公社 www.linuxidc.com
站点邮箱地址  – root@linuxidc.com
用户名  – linuxidc
密码  – ##########
用户的邮箱地址  – root@linuxidc.com
默认国家  – China
默认时区  – UTC
设置适当的值后,点击保存并继续完成站点安装过程。

CentOS 7.5 安装部署 Drupal 8.6.4 图文详解

Drupal 站点配置

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

CentOS 7.5 安装部署 Drupal 8.6.4 图文详解

Drupal 站点面板

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

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

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

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

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计5443字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中