We continue to expand our marketplace. We recently talked about how made a Gitlab image, and this week Drupal appeared in our marketplace.
We tell why we chose it and how the image was created.
Drupal is a convenient and powerful platform for creating any type of sites: from microsites and blogs to large social projects, which is also used as the basis for web applications, written in PHP and using relational databases as data storage.
Drupal 9 includes all the features introduced in version 8.9. The key difference between version 9 and version 8 is that the platform will continue to receive updates and security fixes after November 2021. Also in version 9, the upgrade process has been simplified, making the upgrade process from version 8 even easier.
Server Requirements
To use Drupal, it is recommended to use 2 GB of RAM and 2 CPU cores.
The main Drupal files are about 100 MB, additionally you will need space to store images, database, themes, add-ons and backups, which will depend on the size of your site.
Drupal 9 requires PHP 7.4 or higher with a minimum limit (memory_limit) to 64 MB memory, in case of using additional modules, it is recommended to install 128 MB.
Drupal can use Apache or Nginx as a web server, and MySQL, PostgreSQL or SQLite as a database.
We will install Drupal using Nginx and MySQL.
Installation
Update the installed packages to the latest version:
sudo dnf update -y
Let's add a permanent permission for incoming traffic to http/80 and https/443 ports:
Since PHP 7.2 is currently used in the main Centos repository, let's add the REMI repository with PHP 7.4 (the minimum version for Drupal 9).
To do this, add the EPEL repository (required by the REMI repository):
Since we are making a template for VDS, and they can be slow, we will add a mysqld start delay of 30 seconds, otherwise there may be problems starting the server during the initial system boot:
sudo sed -i '/Group=mysql/a
ExecStartPre=/bin/sleep 30
' /usr/lib/systemd/system/mysqld.service
Let's change the group and user under which nginx will run by making changes to /etc/php-fpm.d/www.conf:
sudo sed -i --follow-symlinks 's/user = apache/user = nginx/g' /etc/php-fpm.d/www.conf
sudo sed -i --follow-symlinks 's/group = apache/group = nginx/g' /etc/php-fpm.d/www.conf
Change the owner of the PHP session directory to nginx accordingly:
sudo chown -R nginx. /var/lib/php/session
Let's remove the comment lines from the /etc/nginx/nginx.conf configuration file (so that there are no double hits for sed):
sudo sed -i -e '/^[ t]*#/d' /etc/nginx/nginx.conf
Add gzip compression settings to /etc/nginx/nginx.conf
Let's add the settings of the index.php index file to /etc/nginx/nginx.conf:
sudo sed -i '/ root /usr/share/nginx/html;/a
index index.php index.html index.htm;
' /etc/nginx/nginx.conf
Let's add settings for the default server processing php through the php-fpm socket, disable the log for static files, increase the expire time, disable the access and error log for favicon.ico and robots.txt and deny access to .ht files for everyone:
At this stage, we will turn off the server and take a snapshot:
shutdown -h now
After starting the VDS from the snapshot, we will perform the initial setup of the MySQL server by running the script:
mysql_secure_installation
Enable the password validator:
Would you like to setup VALIDATE PASSWORD component? : y
Set the MySQL root user password:
New password:
Re-enter new password:
Remove anonymous users:
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Let's prevent root from connecting remotely:
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Let's remove the test database:
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Reload the privilege tables:
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
After that, to complete the installation, we can go to vps_ip_address
At this address we will see a page with the installation of Drupal.
Select the language to be used. For example: Russian. Click "Save and Continue"
Let's choose an installation profile (demo is used only for familiarization with the system). In our case, let it be "standard".
On the next page, give the database a name, such as "drupal". Specify the database username root and the password given to him when starting mysql_secure_installation. Click "Save and Continue".
Let's wait for the installation and updating of translations to complete (the process may take several minutes).
Specify the name of the site, set the email of the site (on whose behalf site notifications will come), login, password and email of the Drupal administrator account. We will also set the country and time zone in the regional settings. And complete the installation by clicking "Save and Continue".
After that, you can go to the control panel with the created Drupal administrator login and password.
HTTPS setting (optional)
To configure HTTPS, the VDS must have a valid DNS name, specify in
/etc/nginx/nginx.conf
in the server section the server name (for example):
server_name domainname.ru;
Restart nginx:
service nginx restart
Let's start certbot:
sudo /usr/local/bin/certbot-auto --nginx
Enter your e-mail, agree to the terms of service (A), Subscribe to the newsletter (optional) (N), select the domain names for which you want to issue a certificate (Enter for all).
If everything went without errors, we will see a message about the successful issuance of certificates and server setup:
Congratulations! You have successfully enabled ...
After that, connections on port 80 will be redirected to 443 (https).
Add to /etc/crontab to automatically renew certificates:
This setting is intended as a solution to the problem of dynamic base_url detection, and is intended to prevent HTTP HOST Header attacks (when your site thinks it is someone else).
To do this, you need to specify the trusted domain names of the site in the settings file.
In file
/usr/share/nginx/html/sites/default/settings.php uncomment or add a setting with patterns of actual site names, for example:
Drupal supports APCu - Alternative PHP User Cache, versions 8 and 9 use APCu more intensively as a short-term local cache than previous versions. The default cache size (32 MB) will suit most sites, and cannot exceed 512 MB.
To activate, install the PHP APCu module:
dnf -y install php-pecl-apcu
Restart nginx and php-fpm:
service nginx restart
service php-fpm restart
In the case of using the Russian language and APCu with the recommended cache memory size, you can see a warning in the control panel that the size of the allocated cache memory differs from the recommended one, but in fact everything works correctly, and the incorrect warning will most likely be fixed in the next updates.
We want to remind you that you can also make an image for us
There are three options for how to participate.
Prepare the image yourself and get 3000 rubles on your balance
If you are ready to immediately rush into battle and create the image that you lack yourself, we will credit you with 3000 rubles to your internal balance - you can spend it on servers.
Tell support that you are going to create and test images
We will credit you 3000 rubles and enable the ability to create snapshots
Order a virtual server with a clean operating system
Install the software on this VPS and set it up
Write instructions or script for software deployment
Create a snapshot for the configured server
Order a new virtual server by selecting the previously created snapshot in the "Server template" drop-down list
In case of successful creation of the server, transfer the materials received at step 6 to technical support
In case of an error, you can check with support for the reason and repeat the setup
For business owners: offer your software
If you are a software developer that is deployed and used on a VPS, then we can include you in the marketplace. This is how we can help you bring in new customers, traffic and visibility. Write to us
Let us know in the comments what image do you miss?