English version was created automatically using Drupal module auto_node_translate and free DeepL translator.

Drupal 8 - installation via Composer

zveřejněno 2019-02-12

As Drupal 8 has evolved over time (various major releases), it has become the preferred way to install via Composer.

Introduction

Although Drupal 8 is still basically just a packaged archive containing a bunch of mostly PHP files that you can just unzip in some directory, this can only be recommended for some testing and playing around with Drupal. The recommended way is to install via Composer:

The recommended way to get the Drupal source code is to use Composer - a PHP dependency manager.
https://www.drupal.org/docs/8/install/step-1-get-the-code

Note: For a quick installation of Drupal 8 (along with Udemi demo for example for a quick demo) you can use the quick-start from version 8.6 onwards, see. Two new easy ways to install Drupal https://www.drupal.org/blog/drupal-8-6-0

Our development environment is any Linux environment with AMP support (Apache, MySQL and PHP). By the way, the installation pages even mention three different concurrent Drupal installations: development (dev), production (live site) and backup (working backup site).

Composer installation

Composer installation is simple and is well described directly on the project website https://getcomposer.org/download/. With maybe a little modification:

php composer-setup.php --install-dir=/usr/local/bin --filename=composer

In this case, such a manual installation is probably a better way than installing a package included in the Linux distribution.

And we have composer installed:

root@debian9:~# composer -version
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Composer version 1.8.4 2019-02-11 10:52:10

Drupal install using Composer

https://www.drupal.org/docs/develop/using-composer/using-composer-to-ma…

There are a number of ways that you could install Drupal using composer, however the recommended approach (especially for beginners to Composer) is to use the composer template at drupal-composer/drupal-project.

Before installing, I still recommend sorting out Linux permissions - composer doesn't like to run as root (https://getcomposer.org/root), so it's best to run it as another user, and the webserver accesses files and directories as the www-data user.

Another good thing is to have git installed (apt-get install git -y), this will get rid of the message

sh: 1: git: not found

So here we go:

composer create-project drupal-composer/drupal-project:8.x-dev /var/www/drupal-demo/

The installation will probably end up with some error:

Chyby composeru

And now that we have all the problems solved, let's see the desired result:

Instalace je hotová

A little bit of numbers will show us why the installation took a while (composer solved its dependencies in the process): our directory is 194M big, contains 6550 folders and 25421 files.

Let's not forget to set our webserver to the /var/www/drupal-demo/web/ folder. The permissions of the /var/www/drupal-demo/web/sites/default/files/ directory should be drwxrwxrwx, so our www-data will be able to write there as well.

Drush = a command line shell for drupal

https://www.drush.org/

 [[img:57:small]]

Drush was and is an invaluable helper for controlling Drupal from the command line. In Drupal 7, it was the only option. For Drupal 8, there is a similar Drupal console project. Some functionality overlaps, other times one or the other does a given thing. So it's good to have both tools and know how to use them.

Installation is easy - with the above procedure, Drush is already included in our installation. It's also the only supported way to install Drush into Drupal 8: Drush 9 only supports one install method. It requires that your Drupal 8 site be built with Composer and Drush be listed as a dependency. http://docs.drush.org/en/master/install/ 

In order to run Drush from anywhere, we install the Drush Launcher https://github.com/drush-ops/drush-launcher. It's easy

wget -O drush.phar https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar
chmod +x drush.phar
mv drush.phar /usr/local/bin/drush9

Now in our installation folder, just run drush9 status

Drupal Console = The Drupal CLI. A tool to generate boilerplate code, interact with and debug Drupal

https://drupalconsole.com/

 [[img:58:small]]

Similar to drush. And it is also straight installed, and like drush, it is advisable to install the launcher https://github.com/hechoendrupal/drupal-console-launcher for it.

curl https://drupalconsole.com/installer -L -o drupal.phar
mv drupal.phar /usr/local/bin/drupal
chmod +x /usr/local/bin/drupal

Database Installation

Now that Drupal is installed, we can prepare the database before we launch it for the first time. There's no complication here.

First Launch

And here we go. After all the peripeteia, our Drupal 8 site is ready. So let's get going.

úvodní instalační obrazovkai

Most of the options are clear, just keep in mind when choosing a profile that minimal is already for more experienced Drupalers. The standard will install and configure unnecessary things from their point of view, which would then have to be removed anyway.

výběr instalačního profilu

I recommend leaving the language in English, at least then the English terminology makes it easier to find solutions to problems.
 
One more problem needs to be solved, and it concerns permissions (composer vs apache). Details https://github.com/drupal-composer/drupal-project/issues/274

ještě jedna chybka

The problem is solved as follows:

mkdir /var/www/drupal-demo/config
chown www-data /var/www/drupal-demo/config/

Note. According to the information in settings.php, the Drupal configuration should not be in the webserver folders.

Finally done!

a je hotovo

Now we will get acquainted with the modules and their settings.