Install and Configure Drupal 8
Updated by Linode Written by Linode
DeprecatedThis guide has been deprecated and is no longer being maintained.Please refer to the updated version of this guide.
Drupal 8 is the latest version of the popular Drupal content management system. This guide demonstrates how to install Drupal 8 on your Linode running Debian or Ubuntu.
Before You Begin
Familiarize yourself with our Getting Started guide and complete the steps for setting your Linode’s hostname and timezone.
This guide will use
sudo
wherever possible. Complete the sections of our Securing Your Server guide to create a standard user account, harden SSH access, remove unnecessary network services and create firewall rules for your web server; you may need to make additional firewall exceptions for your specific application.Update your system:
sudo apt-get update && sudo apt-get upgrade
Install and configure a LAMP stack. You can do this in one of two ways:
See our Hosting a Website guide to configure each component manually.
Deploy using our LAMP StackScript.
Download and Prepare Drupal 8
See Drupal’s download page for the exact URL of Drupal 8’s core tarball.
If you installed and configured your Apache server using one of the methods above, the publicly accessible DocumentRoot should be located at
/var/www/html/example.com/public_html/
. Change to that directory and download Drupal 8 with wget:cd /var/www/html/example.com sudo wget http://ftp.drupal.org/files/projects/drupal-8.0.5.tar.gz
Caution
Ensure that the version number matches the Drupal 8 version you wish to download.Extract the downloaded tarball’s contents into Apache’s DocumentRoot:
sudo tar -zxvf drupal-8.*.tar.gz --strip-components=1 -C public_html
Drupal depends on a PHP graphics library called GD. Install GD with:
sudo apt-get install php5-gd
Drupal 8’s
settings.php
andservices.yml
files are configured when the first start configuration is run. The files must be created from the default templates and their permissions changed so that Drupal can write to them.cd /var/www/html/example.com/public_html/sites/default sudo cp default.settings.php settings.php && sudo cp default.services.yml services.yml sudo chmod 666 {services.yml,settings.php}
Enforce trusted hostnames with those that users will access your site by.
- /var/www/html/example.com/public_html/sites/default/settings.php
-
1 2 3 4
$settings['trusted_host_patterns'] = array( '^www\.example\.com$', '^example\.com$', );
Note
trusted_host_patterns also accepts IP addresses or localhost.
Configure Apache 2.4
Drupal 8 enables Clean URLs by default so Apache’s rewrite module must also be enabled:
sudo a2enmod rewrite
Then specify the rewrite conditions for DocumentRoot in Apache’s configuration file.
- /etc/apache2/apache2.conf
-
1 2 3 4 5 6 7 8 9 10 11
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^ index.php [L] </Directory>
Change ownership of Apache’s DocumentRoot from the system’s root user to Apache. This allows you to install modules and themes, and to update Drupal, all without being prompted for FTP credentials.
sudo chown -R www-data /var/www/html/example.com
Restart Apache so all changes are applied. If you’re using a Linux distribution which uses systemd (CentOS 7, Debian 8, Fedora, Ubuntu 15.10+):
sudo systemctl restart apache2
If your init system is SystemV or Upstart (CentOS 6, Debian 7, Ubuntu 14.04):
sudo service apache2 restart
Drupal First Start
Go to your Linode’s domain or IP address in a web browser. This will show you the first step of Drupal 8’s web configuration. Choose your language and proceed to the next page.
Choose whether you want a Standard or Minimal installation profile.
Complete the database configuration using the DB name, username and password you created when setting up your LAMP stack with a MySQL or MariaDB database.
Note
If you forgot the name of your database, log back in to MySQL with:mysql -u root -p
and enter:show databases;
.After Drupal 8 installs your site, you’ll be shown a site configuration page where you must create the admin user for your website. Do not use the same password that you used for your database.
Next, you’ll be taken to the administrative dashboard which will say that Drupal 8 was installed successfully.
Now that Drupal 8 is finished writing to
settings.php
andservices.yaml
, you can restore their default permissions:sudo chmod 644 /var/www/html/example.com/public_html/sites/default/{settings.php,services.yml}
Where to Go From Here
Drupal has a significant amount of documentation for security best practices to consider when hardening any Drupal server. There is also extensive community documentation and there are multiple ways of participating in the Drupal community.
Join our Community
Find answers, ask questions, and help others.
This guide is published under a CC BY-ND 4.0 license.