Product docs and API reference are now on Akamai TechDocs.
Search product docs.
Search for “” in product docs.
Search API reference.
Search for “” in API reference.
Search Results
 results matching 
 results
No Results
Filters
Install Drupal using Drush on Ubuntu 18.04
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Drupal is a content management system (CMS) designed for building custom websites for personal and business use. Built for high performance and scalability, Drupal provides the necessary tools to create rich, interactive “community” websites with forums, user blogs, and private messaging. Drupal also has support for personal publishing projects and can power podcasts, blogs, and knowledge-based systems, all within a single, unified platform.
Drush is a command line tool for creating, administrating, and modifying Drupal websites. Command line tools, like Drush, add functionality through additional command packages. Once installed, Drush is as easy to use as any of the basic Linux commands.
Before You Begin
Familiarize yourself with our Getting Started guide and complete the steps for setting your Linode’s hostname and timezone.
Follow our Securing Your Server guide to create a standard user account, harden SSH access, and create firewall rules for your web server; you may need to make additional firewall exceptions for your specific application.
Note This guide is written for a non-root user. Commands that require elevated privileges are prefixed with
sudo
. If you’re not familiar with thesudo
command, visit our Users and Groups guide.All configuration files should be edited with elevated privileges. Remember to include
sudo
before running your text editor.Install and configure a How to Install a LAMP stack on Ubuntu 18.04
Download and Prepare Drupal 8
Navigate to your site’s document root. If you installed and configured your Apache server using our LAMP stack on Ubuntu 18.04 guide, your document root should be located in the
/var/www/html/example.com/public_html/
directory. Replaceexample.com
with your own document root path’s name.cd /var/www/html/example.com
Download the Drupal 8 tarball. As of writing this guide, Drupal 8.8.3 is the latest version. See Drupal’s download page for their latest core tarball. Replace
8.8.3
with the version number you wish to download.sudo wget http://ftp.drupal.org/files/projects/drupal-8.8.3.tar.gz
Important Ensure that the version number matches the Drupal 8 version you wish to download.Extract the downloaded tarball’s contents into your site’s document root:
sudo tar -zxvf drupal-8.*.tar.gz --strip-components=1 -C public_html
Drupal depends on a PHP graphics library called GD. Install GD and other dependencies:
sudo apt-get install php-gd php-xml php-dom php-simplexml php-mbstring
Create your Drupal 8 installation’s
settings.php
file from the default settings file. This file will be configured when you run through Drupal’s automated web configuration. See the Install and Configure Drupal on Ubuntu 18.04 guide for more details.sudo cp /var/www/html/example.com/public_html/sites/default/default.settings.php /var/www/html/example.com/public_html/sites/default/settings.php
Enforce trusted hostnames with those that users will access your site from. With the text editor of your choice, edit your
settings.php
file replacing the regular expression (RegEx) with a pattern that matches your own site’s URL(s).- File: /var/www/html/example.com/public_html/sites/default/settings.php
$settings['trusted_host_patterns'] = array( '^www\.example\.com$', '^example\.com$', );
Note trusted_host_patterns
also accepts IP addresses or localhost.
Configure Apache 2.4
Enable Apache’s rewrite module. This module is necessary since Drupal 8 enables Clean URLs by default.
sudo a2enmod rewrite
Specify the rewrite conditions for your Drupal site’s document root in Apache’s configuration file using the text editor of your choice. If you installed and configured your Apache server using LAMP stack on Debian 10 guide, the configuration file for your site is located at
/etc/apache2/sites-available/example.com.conf
.- File: /etc/apache2/sites-available/example.com.conf
<Directory /var/www/html/example.com/public_html> Options Indexes FollowSymLinks AllowOverride All Require all granted RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] </Directory>
Change the ownership of your site’s document root from
root
towww-data
. This allows you to install modules and themes, and to update Drupal without being prompted for FTP credentials.sudo chown -R www-data:www-data /var/www/html/example.com
Restart Apache so all changes are applied.
sudo systemctl restart apache2
Create a Drupal Website with Drush
In this section, you will use Drush to install a Drupal site with just a few commands.
Change the working directory to the location of your new Drupal website. The previous guides created a
/var/www/html/example.com/public_html
directory, wherepublic_html
is the document root or the publicly viewable directory. Replaceexample.com
with your own site’s name.cd /var/www/html/example.com/public_html
Your Linode is now ready for you to install a Drupal site. In the command below, replace
mysql://username:password@localhost/databasename
with your own site’s username, password, and database. For example, if you followed the How to Install a LAMP stack on Ubuntu 18.04 your username iswebuser
, password ispassword
, and the database iswebdata
. Also, replace--site-name=example.com
with your own website’s name.drush si standard --db-url=mysql://username:password@localhost/databasename --site-name=example.com
Note Although MySQL accepts passwords with a special character, for example an exclamation point, thedrush si standard
command does not. If you have a special character in your MySQL password, you may need to change it.Note If you encounter errors related to writing to thesites/default
directory, follow the steps in the Setting the Site’s Ownership and Permissions section to ensure the web server belongs to the current user’s group.After the installation is complete, Drush creates a user, named
admin
, and a random password. An example is pictured below. These credentials are used for the Drupal sign-in page.Optionally, if you’d like to change the admin’s password, it is best to do so with Drush, rather than sending the password over a non-secure HTTP connection. To update the admin password execute the following command and replace
newpass
with your new password:sudo drush user-password admin user-password=newpass
Setting the Site’s Ownership and Permissions
In server administration, there are many options for user and group permissions. The directions below create a site owner and a site owner’s group. The Apache user, named www-data
, is added to the site owner’s group. Then, read, write, and execute permissions are granted to both the site owner and the site owner’s group.
To create a new user for the site owner position, see the Add a Limited User Account section of the Setting Up and Securing a Compute Instance guide.
From the
public_html
directory, change ownership of the site to the site owner and group. Replaceexample_user
below with the chosen owner’s username:sudo chown -R example_user:example_user sites/default
Add Apache’s
www-data
user to the site owner’s group:sudo usermod -a -G example_user www-data
Make sure the permissions are set to allow access for the site owner and site owner’s group:
sudo chmod -R 770 sites/default
Now,
www-data
,example_user
, and any user within theexample_user
group has read, write, and execute permissions for the entire Drupal site directory tree.Restart Apache:
sudo systemctl restart apache2
Finally, check the status of the new site:
drush status
Note When installing new files, like a module or theme, make sure the Apache user has access rights. Use the commandls -al
to list the file permissions within a directory to determine which permissions are assigned to it.
Navigate to your site’s domain (or IP address if you did not set up a domain name). Sign-in with the generated username and password to begin creating content for your Drupal site.
Additional Options
There are many ways to set up administration for a website. Below are sections explaining some additional options. It’s important to be aware of multi-site setups and additional security measures. The topics below touch on these subjects.
File Ownership, Permissions, and Security
The above setup is designed for ease of use. However, there are setups designed for tighter security and other considerations.
- To design your own setup, read Linode’s documentation on Linux Users and Groups guide
- For an extremely secure setup, read Drupal’s Securing File Permissions and Ownership guide
Multi-site Servers
At a high-level, the steps you will need to follow to begin configuring a Drupal multisite set up are:
- Add a new MySQL user, password, and database
- Create a new Apache virtual hosts file and corresponding directories
- See Drupal’s Multisite documentation for more details.
This page was originally published on