手机版

Debian 9配置Apache MariaDB Drupal运行环境

时间:2020-05-05 来源:互联网 编辑:宝哥软件园 浏览:

Drupal是一个免费的开源内容管理系统,可用于创建在线内容,网站和用户社区。 它是用PHP语言编写的,使用MySQL作为数据库后端,并在GNU通用公共许可证下分发。 Drupal拥有超过17,000个插件来自定义其功能。 Drupal在所有Web服务器上运行,包括Apache,Nginx,IIS,Lighttpd以及后端数据库MySQL,MariaDB,MongoDB,SQLite,MS SQL Server,PostgreSQL等。

在本文中,我们将演示如何在Debian 9服务器上安装Drupal 8。

要求

在您的系统上运行Debian 9的服务器。 Apache 2.x,MySQL或具有PDO的MariaDB。 在您的服务器上设置sudo权限的非root用户。

1. 入门指南

首先,建议使用最新的稳定版本来更新系统。 您可以通过运行以下命令来执行此操作:

sudo apt-get update -y
sudo apt-get upgrade -y

一旦您的系统更新,您将需要安装一些所需的软件包到您的系统。 您可以通过运行以下命令来安装它们:

sudo apt-get install wget git unzip nano -y

2. 安装LAMP服务器

在开始安装Drupal之前,需要在服务器上安装并配置LAMP服务器(Apache,PHP和MySQL)。

首先,使用以下命令开始安装Apache Web服务器:

sudo apt-get install apache2 -y

安装完成后,您将需要启动Apache服务,并使其能够在下次系统引导时自动启动。 为此,请运行以下命令:

sudo systemctl start apache2
sudo systemctl enable apache2

接下来,通过运行以下命令来安装PHP所需的模块:

sudo apt-get install php7.0 libapache2-mod-php7.0 php7.0-cli php7.0-mcrypt php7.0-intl php7.0-mysql php7.0-curl php7.0-gd php7.0-soap php7.0-xml php7.0-zip -y

接下来,您需要在php.ini文件中进行一些更改:

sudo nano /etc/php/7.0/cli/php.ini

更改行如下所示:

memory_limit = 512M
date.timezone = UTC
cgi.fix_pathinfo=0
upload_max_filesize = 100M
post_max_size = 100M

完成后,保存并关闭文件。

3. 安装并配置MariaDB

Drupal需要用于数据库后端的MariaDB / MySQL,因此您需要安装它。 您可以通过运行以下命令来安装它:

sudo apt-get install mariadb-server -y

安装完成后,启动MariaDB服务,并通过运行以下命令使其在系统启动时自动启动:

sudo systemctl start mysql
sudo systemctl enable mysql

接下来,您将需要为数据库设置安全性。 您可以运行以下命令来保护MariaDB数据库:

sudo mysql_secure_installation

此脚本设置root密码,禁用远程root登录,删除测试数据库并删除匿名用户,如下所示:

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.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n

 ... skipping.

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!

确保数据库后,Drupal需要一个空的MySQL数据库。 因此,您将需要为Drupal安装创建一个MySQL数据库和用户。

首先,使用以下命令登录到MySQL shell:

mysql -u root -p

在询问时输入root密码,然后使用以下命令创建Drupal的数据库:

MariaDB [(none)]>CREATE DATABASE drupaldb;

接下来,创建drupal数据库的用户,并使用以下命令向drupal数据库授予权限:

MariaDB [(none)]>GRANT ALL PRIVILEGES on drupaldb.* to ‘drupal’@’localhost’ identified by ‘password’;

接下来,运行FLUSH PRIVILEGES命令,以退出特权:

MariaDB [(none)]>FLUSH PRIVILEGES;

最后,使用以下命令退出MariaDB控制台:

MariaDB [(none)]>q

4. 安装并配置Drupal

首先,您需要从其官方网站下载最新的稳定版本的Drupal,否则您可以使用wget命令直接下载,如下所示:

wget https://ftp.drupal.org/files/projects/drupal-8.3.4.zip

之后,提取下载的zip文件,并将提取的Drupal目录移动到Apache根目录:

unzip drupal-8.3.4.zip
sudo mv drupal-8.3.4 /var/www/html/drupal

接下来,您将需要更改drupal目录的一些权限:

sudo chown -R www-data:www-data /var/www/html/drupal
sudo chmod -R 777 /var/www/html/drupal

接下来,您将需要为drupal创建一个Apache虚拟主机文件。 为此,请在/ etc / apache2 / sites-available /目录中创建一个新的drupal.conf文件:

sudo nano /etc/apache2/sites-available/drupal.conf

添加以下行:

<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/drupal
ServerName 192.168.15.189
ServerAlias www.example.com
<<Directory "/var/www/html/drupal/">
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/drupal-error_log
CustomLog /var/log/apache2/drupal-access_log common
</VirtualHost>

完成后保存并关闭文件,然后使用以下命令启用虚拟主机:

sudo a2ensite drupal

您还需要激活重写模块。

sudo a2enmod rewrite

最后,重新启动Apache服务以使用以下命令应用此更改:

sudo systemctl restart apache2

5. 访问Drupal Web界面

一切都已安装和配置。 接下来,您将需要通过UFW防火墙允许Drupal。 默认情况下,UFW防火墙在Debian 9中禁用,因此您需要先启用它。

sudo ufw enable

然后,通过运行以下命令,通过UFW防火墙允许端口80:

sudo ufw allow 80

最后,打开您的网页浏览器,并导航到URL http://192.168.15.189启动Drupal Web安装程序。 您应该看到以下页面:

Debian 9配置Apache MariaDB Drupal运行环境

选择英文,然后点击保存并继续按钮,您应该看到以下图像:

选择安装配置文件,然后单击保存并继续按钮,然后验证所有要求,然后单击保存并继续按钮。 您应该看到以下图像:

 MariaDB

在“数据库配置”页面中,提供数据库名称,数据库用户名和密码,数据库主机等所需的所有数据库详细信息,然后单击“保存并继续”按钮,您应该看到以下图像:

 drupal

在Drupal站点配置页面中,提供您的站点名称,管理员用户名和密码,然后单击保存并继续按钮开始安装Drupal。 安装Drupal后,您应该在以下图像中看到Drupal仪表板:

 Apache

结论

恭喜! 您已经在Debian 9服务器上成功安装并配置了Drupal。

版权声明:Debian 9配置Apache MariaDB Drupal运行环境是由宝哥软件园云端程序自动收集整理而来。如果本文侵犯了你的权益,请联系本站底部QQ或者邮箱删除。

相关文章推荐