您想学习如何在Ubuntu Linux上安装Drupal吗? 在本教程中,我们将向您展示如何在运行Ubuntu Linux的计算机上安装,配置和访问Drupal CMS。

•Ubuntu Linux版本:18.04

硬件清单:

以下部分介绍了用于创建此Drupal教程的设备列表。

上面列出的每一件硬件都可以在亚马逊网站上找到。

Drupal相关教程:

在此页面上,我们提供了与Drupal安装相关的教程列表的快速访问。

教程 - Ubuntu Linux上的NTP

我们将使用NTP配置系统以使用正确的日期和时间。

在Linux控制台上,使用以下命令设置正确的时区。

# dpkg-reconfigure tzdata

安装Ntpdate包并立即设置正确的日期和时间。

# apt-get update
# apt-get install ntpdate
# ntpdate pool.ntp.br

Ntpdate命令用于使用server:pool.ntp.br设置正确的日期和时间

我们来安装NTP服务。

# apt-get install ntp

NTP是保持我们的服务器更新的服务。

使用命令日期检查Ubuntu Linux上配置的日期和时间。

# date

如果系统显示正确的日期和时间,则表示您已正确执行所有步骤。

教程 - 在Ubuntu Linux上安装MySQL

现在,我们可以继续安装数据库服务。

在Linux控制台上,使用以下命令安装所需的软件包。

# apt-get update
# apt-get install mysql-server mysql-client

完成安装后,使用以下命令访问MySQL数据库服务器。

# mysql -u root -p

使用以下SQL命令创建名为Drupal的数据库。

CREATE DATABASE drupal CHARACTER SET UTF8 COLLATE UTF8_BIN;

使用以下SQL命令创建名为drupal的数据库用户。

CREATE USER 'drupal'@'%' IDENTIFIED BY 'kamisama123';

为名为drupal的数据库提供名为drupal的sql用户权限。

GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'%';
quit;

教程 - 在Linux上安装Apache

现在,我们需要安装Apache Web服务器和所有必需的软件。

在Linux控制台上,使用以下命令安装所需的软件包。

# apt-get install apache2 php7.2 php7.2-mysql libapache2-mod-php7.2
# apt-get install php7.2-gd php7.2-mbstring php7.2-xml

启用Apache mod_rewrite并编辑apache2.conf文件。

# a2enmod rewrite
# vi /etc/apache2/apache2.conf

在配置之前,这是原始文件。

DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf

在文件末尾添加以下行。

<Directory /var/www/html>
AllowOverride All
</Directory>

这是我们配置的新文件。

DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
<Directory /var/www/html>
AllowOverride All
</Directory>

现在,您应该在系统上找到php.ini文件的位置。

找到后,您需要编辑php.ini文件。

# updatedb
# locate php.ini
# vi /etc/php/7.2/apache2/php.ini

请记住,您的PHP版本和文件的位置可能与我的不同。

在配置之前,这是原始文件。

file_uploads = On
max_execution_time = 30
memory_limit = 128M
post_max_size = 8M
max_input_time = 60
; max_input_vars = 1000

这是我们配置的新文件。

file_uploads = On
max_execution_time = 300
memory_limit = 256M
post_max_size = 32M
max_input_time = 60
max_input_vars = 4440

您还应该手动重启apache并验证服务状态。

# service apache2 stop
# service apache2 start
# service apache2 status

以下是Apache服务状态输出的示例。

● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Mon 2018-04-23 00:02:09 -03; 1min 4s ago

教程 - Ubuntu上的Drupal安装

现在,我们需要在Ubuntu Linux上安装Drupal CMS。

在Linux控制台上,使用以下命令下载Drupal软件包。

# mkdir /downloads
# cd /downloads
# wget https://ftp.drupal.org/files/projects/drupal-8.6.4.tar.gz
# tar -zxvf drupal-8.6.4.tar.gz
# ls
drupal-8.6.4.tar.gz drupal-8.6.4

将所有Drupal文件移动到Apache安装的根目录。

为所有移动的文件设置正确的文件权限。

# mv drupal-8.6.4 /var/www/html/drupal
# chown www-data.www-data /var/www/html/drupal/* -R

打开浏览器并输入您的Web服务器加/ drupal的IP地址。

在我们的示例中,在浏览器中输入了以下URL:

•http://35.162.85.57/drupal

应该显示Drupal Web安装界面。

选择所需的语言。

Drupal installation

选择标准安装方法。

Drupal installation mode

输入Drupal数据库的MySQL连接信息。

Drupal Database connection

等待Drupal数据库安装过程完成。

在下一个屏幕上,您必须输入以下信息:

•您的网站名称。
•您的网站电子邮件。
•您的管理员用户名。
•您的管理员密码。
•您的管理员电子邮件帐户。
•默认国家/地区
•默认时区

Drupal website information
Drupal website admin

完成安装后,您将被发送到Drupal仪表板。

Drupal Dashboard

恭喜,您已经在Ubuntu Linux上安装了Drupal。