在 CentOS 7 上安装和配置 Drupal 9 |在 CentOS 7 上安装和配置 Drupal 9 |在 CentOS 7 上安装和配置 Drupal 9 |在 CentOS 7 上安装和配置 Drupal 9 |
  • 业务
  • 目标
  • 支持
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容

在 CentOS 7 上安装和配置 Drupal 9 |

发表 admin at 2025年2月28日
类别
  • 未分类
标签

Drupal 是一个免费的开源内容管理平台,专为高效地创建专业内容而创建。 Drupal 使您能够轻松创建网站、在线内容和用户参与社区。 Drupal 是用 PHP 编写的,它使用数据库后端来存储数据 – MySQL、MariaDB、SQLite 或 PostgreSQL。本指南将向您展示在 CentOS 7 Linux 系统上安装和配置 Drupal 9 所需的步骤。

以下是在 CentOS 7 上运行 Drupal 9 的最低要求:

  • PHP >=7.3
  • MySQL 或 Percona,版本 >=5.7.8
  • MariaDB >=10.3.7
  • PostgreSQL >=10

Drupal 9 的一些功能包括:

  • 布局生成器:允许内容编辑者在没有工程帮助的情况下设计页面
  • API优先架构:能够构建强大的解耦和无头应用程序
  • 媒体库:使图像、视频和其他资产的管理比以往更加轻松。
  • 自动更新
  • 新的管理界面和默认主题

在 CentOS 7 上安装和配置 Drupal 9

在本节中,我们将介绍在 CentOS 7 上运行 Drupal 所需的依赖项的安装。本指南中使用的 Web 服务器是 Apache,但您可以选择使用 Nginx 或任何其他 Web 服务器。 Drupal 的优点之一是它的定制水平,有许多可用的插件。

第1步:安装数据库服务器

选择您要使用的数据库服务器,可以是 MySQL、MariaDB 或 PostgreSQL。在本指南中,我们将使用 MariaDB 数据库服务器。

在安装数据库之前更新并重新启动系统:

sudo yum -y update
sudo systemctl reboot

然后参考我们在 CentOS 7 上安装 MariaDB 的指南:

  • 如何在 CentOS 7 上安装 MariaDB

第2步:创建Drupal数据库

Drupal CMS 需要数据库和用户才能正常运行。打开 MariaDB shell。

$ mysql -u root -p

为 Drupal 创建数据库和用户。

CREATE DATABASE drupal;
GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'localhost' IDENTIFIED BY 'Str0ngDrupaLP@SS';
FLUSH PRIVILEGES;
\q

第 3 步:安装 PHP 和所需的扩展

我们需要为 Drupal 9 安装 PHP 7.4 或更高版本。为此安装需要 EPEL 和 REMI 存储库:

sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install epel-release

启用 PHP 7.4 REMI 存储库:

sudo yum -y install yum-utils
sudo yum-config-manager --disable remi-php54
sudo yum-config-manager --enable remi-php74

在 CentOS 7 上安装 PHP 7.4:

sudo yum -y install php php-{cli,gd,mysqlnd,mbstring,json,common,dba,dbg,devel,embedded,enchant,bcmath,gmp,intl,ldap,odbc,pdo,opcache,pear,pgsql,process,recode,snmp,soap,xml,xmlrpc}

确认PHP版本:

$ php -v
PHP 7.4.19 (cli) (built: Jun  9 2020 08:06:30) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.19, Copyright (c) 1998-2018 Zend Technologies

第四步:安装网络服务器

在本指南中,我们将使用 Apache 作为 CentOS 7 上 Drupal 的 Web 服务器:

sudo yum -y install httpd

设置 PHP 时区和内存限制。

$ sudo vi /etc/php.ini
memory_limit = 256M
date.timezone = Africa/Nairobi

启动并启用 httpd 服务。

sudo systemctl enable --now httpd

在防火墙中允许 http 和 https 协议。

sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload

检查httpd服务是否正在运行:

$ systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2020-06-28 16:24:26 CEST; 2min 48s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 2708 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
 Main PID: 2713 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─2713 /usr/sbin/httpd -DFOREGROUND
           ├─2714 /usr/sbin/httpd -DFOREGROUND
           ├─2715 /usr/sbin/httpd -DFOREGROUND
           ├─2716 /usr/sbin/httpd -DFOREGROUND
           ├─2717 /usr/sbin/httpd -DFOREGROUND
           └─2718 /usr/sbin/httpd -DFOREGROUND

Jun 28 16:24:26 centos.computingforgeeks.com systemd[1]: Starting The Apache HTTP Server...
Jun 28 16:24:26 centos.computingforgeeks.com systemd[1]: Started The Apache HTTP Server.

步骤 5:在 CentOS 7 上下载 Drupal 9

下载 Drupal 9 tarball:

sudo yum install -y wget
wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz

提取下载的文件。

tar xvf drupal.tar.gz

将生成的文件夹移动到 /var/www/html 目录。

rm -f drupal*.tar.gz
sudo mv drupal-*/  /var/www/html/drupal

确认文件内容:

$ ls /var/www/html/drupal
autoload.php   core               INSTALL.txt  profiles    sites       vendor
composer.json  example.gitignore  LICENSE.txt  README.txt  themes      web.config
composer.lock  index.php          modules      robots.txt  update.php

创建 Drupal 安装程序所需的其他目录和文件。

sudo mkdir /var/www/html/drupal/sites/default/files
sudo cp /var/www/html/drupal/sites/default/default.settings.php /var/www/html/drupal/sites/default/settings.php

将 drupal 目录的所有权设置为 Apache 用户和组。

sudo chown -R apache:apache /var/www/html/
sudo chmod -R 755 /var/www/html/

修复 SELinux 标签:

sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/drupal(/.*)?"
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/drupal/sites/default/settings.php'
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/drupal/sites/default/files'
sudo restorecon -Rv /var/www/html/drupal
sudo restorecon -v /var/www/html/drupal/sites/default/settings.php
sudo restorecon -Rv /var/www/html/drupal/sites/default/files

第 6 步:为 Drupal 配置 Apache

为 Drupal 网站创建新的 Apache 配置。

sudo vi /etc/httpd/conf.d/drupal.conf

修改以下内容并添加到文件 - 设置域、管理员用户和 Drupal 数据的正确路径。

<VirtualHost *:80>
     ServerName mysite.com
     ServerAlias www.mysite.com
     ServerAdmin [email 
     DocumentRoot /var/www/html/drupal/

     CustomLog /var/log/httpd/access_log combined
     ErrorLog /var/log/httpd/error_log

     <Directory /var/www/html/drupal>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
            RewriteEngine on
            RewriteBase /
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
     </Directory>
</VirtualHost>

确认配置语法:

$ sudo apachectl -t
Syntax OK

重新启动 httpd Web 服务器。

systemctl restart httpd

步骤7:在CentOS 7上安装Drupal 9

打开您最喜欢的网络浏览器以完成 Drupal 9 在 CentOS 7 上的安装。

选择安装语言:

选择要使用的安装配置文件。

设置先前为 Drupal 配置的数据库访问详细信息:

等待它完成:

配置您的站点:

完成后,您将被引导至网站管理控制台。

有关 Drupal 自定义和其他配置选项的更多信息,请参阅官方文档。

对于 https 访问,请查看 Drupal SSL 配置指南

在其他系统上安装:

  • 在 Ubuntu 上安装 Drupal 9 CMS
  • 在 CentOS 8 上安装 Drupal 9

读的书:

  • 学习 Web 开发的最佳书籍 - PHP、HTML、CSS、JavaScript 和 jQuery
©2015-2025 Norria support@norria.com