如何在Ubuntu 20.04上安装Drupal 9 CMS
Drupal 9是流行的Drupal内容管理系统(CMS)的最新版本。
Drupal是一个社区驱动平台,用于构建惊人的数字体验。
它使内容创建者能够在智能手机,平板电脑或者台式计算机上使用Web浏览器添加,编辑,发布或者删除内容。
此简短教程将向我们展示如何在Ubuntu 20.04上轻松安装和配置Drupal CMS。
在Ubuntu 20.04 Linux上安装Drupal 9 CMS
Drupal软件是用PHP编写的,并在GNU通用公共许可证下分发。
Drupal 9代表了在Drupal 8的过程中开发的所有特征的高潮,在更精简的更清洁的码比上。
Drupal 9中的一些功能是:Layout Builder:允许内容编辑器到无需工程HELPAI-First架构的设计页面:使得构建强大的解耦和无头应用程序媒体库:比以往任何时候都更容易管理图像,视频和其他资产。
自动更新管理界面和默认主题
Drupal 9系统要求
PHP> = 7.3mysql或者percona,版本> = 5.7.8mariadb> = 10.3.7postgresql> = 10
我们现在可以介绍在Ubuntu 20.04 Linux系统上安装Drupal 9 CMS的步骤。
第1步:更新系统
确保系统已更新到最新版本:
sudo apt update sudo apt -y upgrade && sudo systemctl reboot
等待服务器上来然后ssh继续配置。
$ssh Hyman@theitroad || ssh Hyman@theitroad
第2步:安装MariaDB数据库服务器
我们将使用MariaDB作为我们的数据库服务器。
在OS上游存储库中提供此数据库服务器的软件包。
触发以下命令以安装它。
sudo apt update sudo apt install -y mariadb-server mariadb-client
通过设置root密码来保护数据库服务器,禁用root远程登录和删除我们不需要的测试数据库。
$sudo 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): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
允许普通用户用密码作为root用户登录。
$sudo mysql -u root UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root'; FLUSH PRIVILEGES; QUIT;
测试我们可以使用密码设置为root用户登录数据库
$mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 59 Server version: 10.3.22-MariaDB-1ubuntu1 Ubuntu 20.04 Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
第3步:创建Drupal数据库
Drupal CMS需要数据库和用户是功能的。
打开Mariadb shell。
$mysql -u root -p
为Drupal创建数据库和用户。
CREATE DATABASE drupal; GRANT ALL ON drupal.* TO 'drupal'@'localhost' IDENTIFIED BY 'Hyman@theitroad'; FLUSH PRIVILEGES; \q
第4步:安装PHP和Apache Web服务器
在Ubuntu上安装PHP:
sudo apt install php php-{cli,fpm,json,common,mysql,zip,gd,intl,mbstring,curl,xml,pear,tidy,soap,bcmath,xmlrpc}
确保安装Apache。
sudo apt install apache2 libapache2-mod-php
设置PHP TimeZone和内存限制。
$sudo vim /etc/php/7.4/apache2/php.ini memory_limit = 256M date.timezone = Africa/Nairobi
第5步:在Ubuntu 20.04上下载Drupal 9
将Drupal 9 tar包下载到服务将运行的主机。
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目录的所有权设置为Apache用户和组。
sudo chown -R www-data:www-data /var/www/html/ sudo chmod -R 755 /var/www/html/
步骤6:配置Drupal的Apache
为Drupal创建新的Apache配置。
sudo vim /etc/apache2/sites-available/drupal.conf
修改以下内容并添加到文件 - 设置域,管理员用户和正确的Drupal数据路径。
<VirtualHost *:80> ServerName mysite.com ServerAlias www.mysite.com ServerAdmin Hyman@theitroad DocumentRoot /var/www/html/drupal/ CustomLog ${APACHE_LOG_DIR}/access.log combined ErrorLog ${APACHE_LOG_DIR}/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= [L,QSA] </Directory> </VirtualHost>
确认配置语法:
sudo apachectl -t
启用。
sudo a2dismod mpm_event sudo a2enmod mpm_prefork sudo sudo a2enmod php7.4 sudo a2enmod rewrite sudo a2ensite drupal.conf systemctl restart apache2
第7步:在Ubuntu 20.04上安装Drupal 9
对于要启动的Drupal的Web配置,需要在Apache中配置的有效DNS条目。
选择语言:
选择安装配置文件:
为Drupal配置数据库:
Drupal安装启动了。