如何在 Fedora 35 上安装 Drupal

Drupal 是一个开源、灵活、高度可扩展且安全的内容管理系统 (CMS),它允许用户轻松构建和创建网站。它是用 PHP 编程语言编写的,并使用 MySQL/ MariaDB作为后端数据库。Drupal 提供了数千个附加组件,这使得它具有高度可定制性。drupal-logo-1

在 Fedora 35 上安装 Drupal

第 1 步:在继续之前,更新您的 Fedora 操作系统以确保所有现有的软件包都是最新的。使用此命令更新服务器包:

sudo dnf upgrade
sudo dnf update

步骤 2. 安装 LAMP 堆栈。

在安装 Drupal 之前,您必须在 Fedora 系统上完成 LAMP Stack 的安装。如果您没有安装 LAMP,您可以在此处按照我们的指南进行操作。

步骤 3. 在 Fedora 35 上安装 Drupal。

默认情况下,Drupal 在 Fedora 35 基础存储库中不可用。现在我们从 Drupal 网站下载最新的 Drupal 版本:

cd /var/www
wget -O /tmp/drupal.tar.gz https://www.drupal.org/download-latest/tar.gz

接下来,解压下载的文件:

sudo tar -zxf /tmp/drupal.tar.gz
sudo mv drupal-* drupal-app

然后,从模板创建配置文件的副本。切换到“ ”目录并将文件复制到:drupal-app/sites/defaultdefault.settings.phpsettings.php

cd drupal-app/sites/default 
sudo cp -p default.settings.php settings.php

之后,我们在同一目录 ( ) 中创建一个名为“files”的文件夹:drupal-app/sites/defaultsettings.php

sudo mkdir files

我们将需要更改一些文件夹权限:

sudo chmod 777 settings.php 
sudo chmod 775 files/ 
sudo chown -R www-data:www-data /var/www/drupal-app

步骤 4. 配置 MariaDB。

默认情况下,MariaDB 未加固。mysql_secure_installation您可以使用脚本保护 MariaDB 。您应该仔细阅读下面的每个步骤,这些步骤将设置 root 密码、删除匿名用户、禁止远程 root 登录、删除测试数据库和访问安全 MariaDB:

mysql_secure_installation

像这样配置它:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

接下来,我们需要登录 MariaDB 控制台并为 Drupal 创建一个数据库。运行以下命令:

mysql -u root -p

这将提示您输入密码,因此请输入您的 MariaDB 根密码并按 Enter。登录到数据库服务器后,您需要为 Drupal 安装创建一个数据库:

MariaDB [(none)]> CREATE DATABASE drupal_db;
MariaDB [(none)]> CREATE USER 'drupal_user'@'localhost' IDENTIFIED BY 'your-strong-password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON drupal_db.* TO 'drupal_user'@'localhost' IDENTIFIED BY 'your-strong-password' WITH GRANT OPTION;
MariaDB [(none)]> ALTER DATABASE drupal_db charset=utf8;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

步骤 5. 配置 Apache。

让我们为您的域创建一个 Apache 配置文件:

sudo nano /etc/httpd/conf.d/drupal.your-domain.com.conf

添加以下文件:

<VirtualHost *:80>   ServerAdmin admin@your-domain.com    ServerName drupal.your-domain.com    DocumentRoot /var/www/drupal-app    <Directory /var/www/drupal-app>        Allowoverride all    </Directory></VirtualHost>

保存并关闭配置文件,然后重新启动 Apache 服务以使更改生效:

sudo systemctl restart httpd
sudo systemctl enable httpd

步骤 6. 使用 Let’s Encrypt SSL 免费证书保护 Apache。

首先,我们使用以下命令安装 Certbot:

sudo dnf install certbot python3-certbot-apache

然后,为 Apache 安装 SSL 证书,如下所示:

sudo certbot --apache

进入交互式提示并安装证书。如果安装了证书,您将看到以下祝贺消息:

Congratulations! You have successfully enabled HTTPS on https://drupal.your-domain.com
NEXT STEPS:
- The certificate will need to be renewed before it expires. Certbot can automatically renew the certificate in the background, but you may need to take steps to enable that functionality. See https://certbot.org/renewal-setup for instructions.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

步骤 7. 配置防火墙。

使用以下命令将防火墙配置为 HTTP 端口 80 和 HTTPS 端口 443 允许流量:

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

步骤 8. 访问 Drupal Web 界面。

成功安装后,打开您的 Web 浏览器并使用 URL 访问 Drupal 。您将被重定向到以下页面:https://drupal.your-domain.com

drupal-interface-install-1

感谢您使用本教程在 Fedora 35 系统上安装 Drupal 内容管理系统。如需更多帮助或有用信息,我们建议您查看Drupal 官方网站

未经允许不得转载:统信UOS之家 » 如何在 Fedora 35 上安装 Drupal

相关文章