Admin... by accident!

You may have chosen to be an admin. I didn't!

  • Home
  • FreeBSD
  • GNU/Linux
  • Security
  • Network
  • Virtualization
  • Politics
  • Github
  • Donate
  • Me

How to install Drupal 8 on FreeBSD

January 13, 2018 by Albert Valbuena

NOTE: Drupal 8 will be soon oudated. A newer article to be released on October 24th on how to install Drupal 9 on FreeBSD can be found here.

This is a quick, simple yet effective tutorial on how to install Drupal 8 on FreeBSD. Drupal is a robust, complete well stablished CMS used on many important websites around the globe. Extensible with modules (some sort of plugins), customizable with themes it remains in third position behind WordPress on mainstream content management systems. At this point I guess you’ve done your own discovery about CMS in the market, their strengths, weaknesses and use.

In order to install Drupal 8 on FreeBSD (this also works on 7) we have to have a FAMP server in place. So if you haven’t done that yet, go and read this guide and use it if you like. After that it’s a simple series of steps to get Drupal 8 on FreeBSD. In the guide you are now reading we will use the latest versions of the stack components, which include Apache 2.4, MariaDB 10.2 and PHP 7.2. And instead of installing Drupal from the packages the OS provides we will pull the tarball from the main Drupal source. If you choose the default OS proposal the dependencies on de DB and PHP are MySQL 5.6 and php 5.6 respectively, losing the last performance and options improvements of more recent packages. Since the install is easy I prefer to install the latest software and get Drupal or WordPress from the original sources alike and do a “manual” install.

If you find the articles in Adminbyaccident.com useful to you, please consider making a donation.

Another notice. I tend to use FreeBSD jails to give servers different purposes at the same time I get isolation and maintainability of different stacks on one piece of hardware. For testing and demonstrations I also use jails so I can create new jails from templates in seconds and get new software working in less than one hour, and sometimes even in minutes. It’s even faster than using VM’s on any platform where you have to install the OS and other parts on top. This time won’t be different and as referenced on the FreeBSD jails article I create a new jail from a template (which is a template for a FAMP).

albert@BSDVM:~ % sudo iocage create -t famp -n drupaltest

drupaltest successfully created!

albert@BSDVM:~ %

We now give a virtual network stack to the recently created jail by:

albert@BSDVM:~ % sudo iocage set ip4_addr="em0|192.168.1.220/24" drupaltest

Property: ip4_addr has been updated to em0|192.168.1.220/24

albert@BSDVM:~ %

We boot it up.

albert@BSDVM:~ % sudo iocage start drupaltest

* Starting drupaltest

+ Started OK

+ Starting services OK

albert@BSDVM:~ %

And we log in.

albert@BSDVM:~ % sudo iocage console drupaltest

….

root@drupaltest:~

As always before installing anything just go and update your OS and applications.

root@drupaltest:~ # pkg update

Updating FreeBSD repository catalogue...

[drupaltest] Fetching meta.txz: 100% 944 B 0.9kB/s 00:01

[drupaltest] Fetching packagesite.txz: 100% 6 MiB 1.0MB/s 00:06

Processing entries: 100%

FreeBSD repository update completed. 28802 packages processed.

All repositories are up to date.

root@drupaltest:~ #

Let’s upgrade the installed programs.

root@drupaltest:~ # pkg upgrade

Updating FreeBSD repository catalogue...

FreeBSD repository is up to date.

All repositories are up to date.

New version of pkg detected; it needs to be installed first.

The following 1 package(s) will be affected (of 0 checked):

Installed packages to be UPGRADED:

pkg: 1.10.3_1 -> 1.10.4

Number of packages to be upgraded: 1

3 MiB to be downloaded.

Proceed with this action? [y/N]: y

[drupaltest] [1/1] Fetching pkg-1.10.4.txz: 100% 3 MiB 997.0kB/s 00:03

Checking integrity... done (0 conflicting)

[drupaltest] [1/1] Upgrading pkg from 1.10.3_1 to 1.10.4...

[drupaltest] Extracting pkg-1.10.4: 100%

Updating FreeBSD repository catalogue...

FreeBSD repository is up to date.

All repositories are up to date.

Checking for upgrades (4 candidates): 100%

Processing candidates (4 candidates): 100%

The following 4 package(s) will be affected (of 0 checked):

Installed packages to be UPGRADED:

php72-mysqli: 7.2.0_1 -> 7.2.1

php72: 7.2.0_1 -> 7.2.1

mod_php72: 7.2.0_1 -> 7.2.1

libargon2: 20161029_1 -> 20171227

Number of packages to be upgraded: 4

5 MiB to be downloaded.

As it shows the package repo has been updated and there were 4 updates to be made. We apply them of course.

If we now look at our installed software we’ll see PHP is installed at the bare minimum. We have to install some PHP modules which will allow Drupal to work and do nice good things. We can install the modules one by one but there is a second option, a “meta port” so we install one port containing all of those modules. Let’s go for it.

root@drupaltest:~ # pkg install php72-extensions

Updating FreeBSD repository catalogue...

FreeBSD repository is up to date.

All repositories are up to date.

The following 20 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:

php72-extensions: 1.0

php72-session: 7.2.1

php72-opcache: 7.2.1

php72-xmlwriter: 7.2.1

php72-xmlreader: 7.2.1

php72-dom: 7.2.1

php72-xml: 7.2.1

php72-simplexml: 7.2.1

php72-ctype: 7.2.1

php72-posix: 7.2.1

php72-hash: 7.2.1

php72-filter: 7.2.1

php72-tokenizer: 7.2.1

php72-json: 7.2.1

php72-sqlite3: 7.2.1

sqlite3: 3.21.0_1

php72-pdo_sqlite: 7.2.1

php72-pdo: 7.2.1

php72-iconv: 7.2.1

php72-phar: 7.2.1

Number of packages to be installed: 20

The process will require 7 MiB more space.

2 MiB to be downloaded.

Proceed with this action? [y/N]: y

Now there is still one missing part, another PHP module which allows playing with images. Let’s install it. It has a few dependencies as you can see.

root@drupaltest:~ # pkg install php72-gd

Updating FreeBSD repository catalogue...

FreeBSD repository is up to date.

All repositories are up to date.

The following 17 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:

php72-gd: 7.2.1

libXpm: 3.5.12

xproto: 7.0.31

libXext: 1.3.3_1,1

xextproto: 7.3.0

libXau: 1.0.8_3

libX11: 1.6.5,1

libxcb: 1.12_2

libXdmcp: 1.1.2

libpthread-stubs: 0.4

kbproto: 1.0.7

libXt: 1.1.5,1

libSM: 1.2.2_3,1

libICE: 1.0.9_1,1

freetype2: 2.8_1

png: 1.6.34

jpeg-turbo: 1.5.3

Number of packages to be installed: 17

The process will require 22 MiB more space.

5 MiB to be downloaded.

Proceed with this action? [y/N]: y

Lastly on the PHP chapter we will install the PHP driver for MariaDB (or any MySQL database we wish to use).

root@drupaltest:~ # pkg install php72-pdo_mysql

Updating FreeBSD repository catalogue...

FreeBSD repository is up to date.

All repositories are up to date.

The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:

php72-pdo_mysql: 7.2.1

Number of packages to be installed: 1

16 KiB to be downloaded.

Proceed with this action? [y/N]: y

After installing all the required software (except Drupal itself) the second step for the install of Drupal 8 on FreeBSD we have to configure MariaDB (or our database of choice). We will create a DB where Drupal will write its content, we will also create a user to interact this database and will give it a password and rights to the DB.

Let’s login into MariaDB.

root@drupaltest:~ # mysql -u root -p

Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 8

Server version: 10.2.11-MariaDB FreeBSD Ports

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

We will now create a database for Drupal. Remember to use some smart name and do not just type “drupal” as I do since I am just doing a demo.

MariaDB [(none)]> CREATE DATABASE drupal;

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]>

Let’s now create a user and give it a password.

MariaDB [(none)]> CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'password';

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]>

We’ll now give the user we just created rights to the database for drupal.

MariaDB [(none)]> GRANT ALL PRIVILEGES ON drupal.* TO drupaluser@localhost;

Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]>

We push the changes to the MariaDB cache so everything is in place and updated.

MariaDB [(none)]> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]>

We quit MariaDB.

MariaDB [(none)]> exit

Bye

root@drupaltest:~ #

Now that the PHP dependencies are fulfilled, MariaDB is configured, the third step on installing Drupal 8 on FreeBSD is configuring the Apache web server. To achieve this we will enable two modules, the MIME and the VirtualHost ones, and we will configure a virtualhost to host the configuration files for our website. Let’s do this.

To configure MIME we will edit the line 121 on the file httpd.conf on the path /usr/local/etc/apache24, enabling the module by removing the # symbol.

Before:

#LoadModule logio_module libexec/apache24/mod_logio.so

LoadModule env_module libexec/apache24/mod_env.so

#LoadModule mime_magic_module libexec/apache24/mod_mime_magic.so

#LoadModule cern_meta_module libexec/apache24/mod_cern_meta.so

After:

#LoadModule logio_module libexec/apache24/mod_logio.so

LoadModule env_module libexec/apache24/mod_env.so

LoadModule mime_magic_module libexec/apache24/mod_mime_magic.so

#LoadModule cern_meta_module libexec/apache24/mod_cern_meta.so

We will also have to add one line on the specific configuration statements for the MIME module. On line 398 of this same httpd file we find the first blocks of this configuration. We go to the bottom of this block (line 446) and we add our line. This is how it should look like:

#AddType text/html .shtml

#AddOutputFilter INCLUDES .shtml

# Add MIME type for PHP

AddType application/x-httpd-php .php

</IfModule>

We will now test our configuration by typing:

root@drupaltest:~ # apachectl configtest

Performing sanity check on apache24 configuration:

AH00557: httpd: apr_sockaddr_info_get() failed for drupaltest

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message

Syntax OK

root@drupaltest:~ #

If Syntax is OK we are good to go. We can forget about these errors at this time.

We have to enable the VirtualHost module now. So we will uncomment the line for its statement. On my install this is located on the line 511 of the /usr/local/etc/apache24/httpd.conf file.

Before:

# Virtual hosts

#Include etc/apache24/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual

#Include etc/apache24/extra/httpd-manual.conf

After:

# Virtual hosts

Include etc/apache24/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual

#Include etc/apache24/extra/httpd-manual.conf

We will again test the Apache configuration looking as a result “Syntax OK”.

root@drupaltest:~ # apachectl configtest

Performing sanity check on apache24 configuration:

AH00112: Warning: DocumentRoot [/usr/local/docs/dummy-host.example.com] does not exist

AH00112: Warning: DocumentRoot [/usr/local/docs/dummy-host2.example.com] does not exist

AH00557: httpd: apr_sockaddr_info_get() failed for drupaltest

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message

Syntax OK

root@drupaltest:~ #

As you’ve seen there are new error messages but still Syntax OK. Because we have just enabled the VirtualHosts module but haven’t set any virtual host yet these error messages appear. We will now enable one virtual host, so we have everything ready to install drupal and have our website and these messages just disappear.

Go to the path:

/usr/local/etc/apache24/extra

We will now edit the httpd-vhosts.conf file and add our website rules. Before doing anything we will look for the following lines to edit:

<VirtualHost *:80>

ServerAdmin webmaster@dummy-host.example.com

DocumentRoot "/usr/local/docs/dummy-host.example.com"

ServerName dummy-host.example.com

ServerAlias www.dummy-host.example.com

ErrorLog "/var/log/dummy-host.example.com-error_log"

CustomLog "/var/log/dummy-host.example.com-access_log" common

</VirtualHost>

We will change them with our editor of choice to something as:

<VirtualHost *:80>

ServerAdmin webmaster@dummy-host.example.com

DocumentRoot "/usr/local/www/apache24/data"

ServerName 192.168.1.220

#ServerAlias www.dummy-host.example.com

<Directory "/usr/local/www/apache24/data">

Options Indexes FollowSymLinks

AllowOverride All

Require all granted

</Directory>

ErrorLog "/var/log/yourwebsitenamehere"

CustomLog "/var/log/yourwebsitenamehere" common

</VirtualHost>

As a final step on the Apache configuration we will restart it to apply the recent changes.

root@drupaltest:~ # apachectl restart

Now we can end up our install of Drupal 8 on FreeBSD by downloading Drupal from its original source, configuring it and performing the final install steps on the browser.

First go to the /tmp directory or any other directory you have rights to write into. From there we will pull the Drupal source, unpack it, make the necessary configuration changes and then move it to its final location under /usr/local/www/apache24/data

root@drupaltest:~ # cd /tmp

root@drupaltest:/tmp #

We now pull from the main Drupal source. Since fetching it properly fails because of the SSL certificate we will make no checks. If this is a concern to you get the source from other means.

root@drupaltest:/tmp # fetch --no-verify-peer https://ftp.drupal.org/files/projects/drupal- 8.4.4.tar.gz

drupal-8.4.4.tar.gz 100% of 12 MB 1202 kBps 00m11s

root@drupaltest:/tmp #

Let’s now unpack the tarball.

root@drupaltest:/tmp # tar -zxvf drupal-8.4.4.tar.gz

Now we have a newly created folder called “drupal-8.4.4”. Get into it. We will now make the necessary configuration changes in Drupal. This is the content of the folder.

root@drupaltest:/tmp/drupal-8.4.4 # ll

total 139

-rw-r--r-- 1 root wheel 1025 Jan 3 20:27 .csslintrc

-rw-r--r-- 1 root wheel 357 Jan 3 20:27 .editorconfig

-rw-r--r-- 1 root wheel 151 Jan 3 20:27 .eslintignore

-rw-r--r-- 1 root wheel 41 Jan 3 20:27 .eslintrc.json

-rw-r--r-- 1 root wheel 3858 Jan 3 20:27 .gitattributes

-rw-r--r-- 1 root wheel 7866 Jan 3 20:27 .htaccess

-rw-r--r-- 1 root wheel 18092 Nov 17 2016 LICENSE.txt

-rw-r--r-- 1 root wheel 5889 Jan 3 20:27 README.txt

-rw-r--r-- 1 root wheel 262 Jan 3 20:27 autoload.php

-rw-r--r-- 1 root wheel 2247 Jan 3 20:27 composer.json

-rw-r--r-- 1 root wheel 150618 Jan 3 20:27 composer.lock

drwxr-xr-x 12 root wheel 39 Jan 3 20:27 core/

-rw-r--r-- 1 root wheel 1272 Jan 3 20:27 example.gitignore

-rw-r--r-- 1 root wheel 549 Jan 3 20:27 index.php

drwxr-xr-x 2 root wheel 3 Jan 3 20:27 modules/

drwxr-xr-x 2 root wheel 3 Jan 3 20:27 profiles/

-rw-r--r-- 1 root wheel 1596 Jan 3 20:27 robots.txt

drwxr-xr-x 3 root wheel 7 Jan 3 20:27 sites/

drwxr-xr-x 2 root wheel 3 Jan 3 20:27 themes/

-rw-r--r-- 1 root wheel 848 Jan 3 20:27 update.php

drwxr-xr-x 17 root wheel 20 Jan 4 00:13 vendor/

-rw-r--r-- 1 root wheel 4555 Jan 3 20:27 web.config

root@drupaltest:/tmp/drupal-8.4.4 #

We have to change directory again into the following path:

/tmp/drupal-8.4.4/sites/defa

On it we will find two files:

-rw-r--r-- 1 root wheel 6762 Jan 3 20:27 default.services.yml

-rw-r--r-- 1 root wheel 31530 Jan 3 20:27 default.settings.php

We have to copy the defaults to the main settings file. We do this by typing:

root@drupaltest:/tmp/drupal-8.4.4/sites/default # cp default.settings.php settings.php

root@drupaltest:/tmp/drupal-8.4.4/sites/default #

After this step we will configure the main settings file and will add the database name we created in the beginning of the article, we’ll also change the username and password with the ones we arranged in our first steps.

Before:

* @code

* $databases['default']['default'] = array (

* 'database' => 'databasename',

* 'username' => 'sqlusername',

* 'password' => 'sqlpassword',

* 'host' => 'localhost',

* 'port' => '3306',

* 'driver' => 'mysql',

* 'prefix' => '',

* 'collation' => 'utf8mb4_general_ci',

* );

* @endcode

After:

* @code

* $databases['default']['default'] = array (

* 'database' => 'drupal',

* 'username' => 'drupaluser',

* 'password' => 'password',

* 'host' => 'localhost',

* 'port' => '3306',

* 'driver' => 'mysql',

* 'prefix' => '',

* 'collation' => 'utf8mb4_general_ci',

* );

* @endcode

Now that we have configured Drupal we have to move this files to their proper location to function. Remember that path we set on the Apache virtual host? That’s the place.

root@drupaltest:~ # mv /tmp/drupal-8.4.4/* /usr/local/www/apache24/data/

Don’t forget to pass the hidden files!

root@drupaltest:~ # cp -r /tmp/drupal-8.4.4/. /usr/local/www/apache24/data/

We go now to that path to make the last move until we get into the browser and make the final graphical steps of the install of Drupal 8 on FreeBSD. We will have to set the right ownership to the files we just moved.

root@drupaltest:~ # sudo chown -R www:www /usr/local/www/apache24/data

root@drupaltest:~ #

We can now head to the browser, point to our IP or domain we acquired and finish the install steps there.

http://192.168.1.220/core/install.php

Choose your language as indicated.

Now choose the profile of the install. After all the requirements have been fulfilled (it should be right and go to the database set up straight).

Choose MySQL, MariaDB, Percona Server, or equivalent. And fill the requested fields with the same options you set at the creation of the database, user for the database and password, which in turn are the same you put into the settings.php file.

Let’s now install the site!

To configure the site you must fill some fields which I believe you are very capable to write into. After that you will be prompted to the main Drupal page.

So we now have our install of Drupal 8 on FreeBSD and we can build our website using this great tool. It may not have the popularity WordPress has got in the recent years but it is quality product you can do great things with. If everyone uses the same software life is a little bit boring, isn’t it?

This same setup can be built in DigitalOcean. Use this link to get 100 $ credit at DOcean and support Adminbyaccident.com hosting costs.

 

Filed Under: FreeBSD, How To's

Recent Posts

  • How to install Mate on FreeBSD 12/13
  • How to install Nessus 10 on FreeBSD 12
  • How to enable TLS traffic from the origin server on Cloudflare Argo Tunnel
  • How to use Cloudflare’s Argo Tunnel service to publish a website on FreeBSD 12/13
  • How to setup MariaDB master-slave replication on FreeBSD
  • How to upload a FreeBSD custom image on DigitalOcean
  • How to install Drupal 9 on FreeBSD 13.0
  • How to manage site visitors based on IP Geolocation
  • How to enable Geolocation in AWStats on FreeBSD 13.0
  • How to install AWStats on FreeBSD 13.0
  • How to configure Modsecurity 3 for WordPress on FreeBSD
  • How to configure Apache HTTP with a TLS reverse proxy backend on FreeBSD
  • How to detect a WAF – Web Application Firewall
  • How to install Matomo 4 on FreeBSD
  • How to test SSL/TLS configurations
  • How to configure Apache HTTP as a reverse proxy on FreeBSD
  • How to install Nextcloud on FreeBSD 12
  • How to install ModSecurity 3 on FreeBSD
  • How to replace a disk on a ZFS mirror pool
  • How to install Webmin on FreeBSD 12

Archives

  • February 2023
  • January 2023
  • December 2022
  • April 2022
  • March 2022
  • October 2021
  • September 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • September 2018
  • June 2018
  • May 2018
  • April 2018
  • February 2018
  • January 2018
  • November 2017
  • April 2017

RSS Admin… by accident!

  • How to install Mate on FreeBSD 12/13
  • How to install Nessus 10 on FreeBSD 12
  • How to enable TLS traffic from the origin server on Cloudflare Argo Tunnel
  • How to use Cloudflare’s Argo Tunnel service to publish a website on FreeBSD 12/13
  • How to setup MariaDB master-slave replication on FreeBSD
  • How to upload a FreeBSD custom image on DigitalOcean
  • How to install Drupal 9 on FreeBSD 13.0
  • How to manage site visitors based on IP Geolocation
  • How to enable Geolocation in AWStats on FreeBSD 13.0
  • How to install AWStats on FreeBSD 13.0

Copyright © 2023 · Magazine Pro Theme on Genesis Framework · WordPress · Log in