Further expanding the FAMP stack, today I’ll be replacing WordPress with Drupal. Drupal is a CMS that’s more advanced but less painful than WordPress.

Although you can configure apache to run multiple websites on a single server using vhosts, I’ll be keeping it simple and won’t be using vhosts.

Satisfying Dependencies

$ pkg remove php74

Now we will proceed with installing php73 and some of it’s libraries.

# install deps
$ pkg install php73 php73-mysqli php73-xml php73-hash php73-gd php73-curl php73-tokenizer php73-zlib php73-zip php73-json php73-dom php73-exif php73-fileinfo php73-mbstring php73-openssl php73-pecl-imagick php73-filter php73-iconv php73-ctype php73-intl php73-phar php73-composer php73-pdo php73-session php73-opcache php73-xmlwriter php73-xmlreader php73-simplexml php73-posix php73-sqlite3 php73-pdo_sqlite php73-extensions php73-pdo_mysql drush-php73

# create php.ini
$ cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

# restart everything 
$ service php-fpm restart
$ service apache24 restart

Editing Apache configs

Open your apache config in an editor

$ vim /usr/local/etc/apache24/httpd.conf

Uncomment (ie remove the leading #) from the lines that look like the following

#LoadModule mime_magic_module libexec/apache24/mod_mime_magic.so

Add a line within the mime_module config block

<IfModule mime_module> 
<!-- . . . many other lines . . .  -->
AddType application/x-httpd-php .php
</IfModule>

Database Time

First, we open a shell in mariadb:

$ mysql -u root

Now we add a user, a database, grant privileges, then reload the whole thing. Remember these values. You’ll need them later.

CREATE DATABASE drupal;
CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Use Composer to Install Drupal

Composer is a dependency manager for PHP. Composer makes it extremely easy to install, update, add modules, and change your themes.

# cd to your document root
$ cd /usr/local/www/apache24/data

# use composer to download all the stuff Drupal needs 
$ composer create-project drupal/recommended-project ./
# go get a cup of coffee, this might take a few minutes

# have your coffee? Now we create some files
$ cd ./web/site/downloads/
$ cp ./default.settings.php ./settings.php
$ mkdir -p files
$ chmod a+w ./files ./settings.php

Configure Drupal With It’s Web GUI

Point your web browser to your server. If you followed my directions exactly, you’ll need to go to http://your-server-ip/web/
Drupal's welcome page. Choose your language!
Drupal’s welcome page. Choose your Language!
Now we’ll choose a profile. Since this is our first time, we’ll choose the ‘Standard’ profile.
Select an installation profile: Standard, Minimal, or Demo
Select an installation profile: Standard, Minimal, or Demo
The next screen is very useful. It will help us troubleshoot our installation. As an example, I’ve included some errors you might encounter if you forget to create a settings.php file and an uploads directory. If you’re following my instructions exactly, you shouldn’t see this. If you do happen to encounter this screen though, work through each issue and refresh the page. Eventually you’ll solve all the errors.
Requirements problem: Filesystem error and Settings File error
Requirements problem: Filesystem error and Settings File error
Remember when I told you to remember what you typed into mariadb? Now we’ll use it.
Database configuration: select your Database type, Database name, Database user, and enter the database user's password
Database configuration: select your Database type, Database name, Database user, and enter the database user’s password

If everything goes well, Drupal will begin installing itself. This part might take a while so feel free to go refill your coffee cup.

If this step errors out, you might need to nuke your database and start over. Re-create your database, open FireFox, and work through the web GUI again. Drupal is friendly and won’t overwrite a database that already contains Drupal content.
Drupal Installation progress bar
Drupal Installation progress bar
The final step – configure our site. Insert your site name and site email address. In the ‘Site Maintenance Account’ section you will be creating a user. Make sure to use a strong password to prevent vandalism.
Another round of fill in the blanks
Another round of fill in the blanks

Final Configuration Steps

Before we’re ready to go, we need to ssh back into our server and modify DAC for settings.php.

$ cd /usr/local/www/apache24/data/web/sites/default
$ chmod o-w ./settings.php

Be sure to check http://your-server-ip/web/admin/reports/status for additional errors and warnings. Drupal will tell you what’s wrong with it and provide you with links documentation on possible solutions. Like during the installation process, troubleshoot each step and refresh the page until the errors are resolved.

Installing Themes and Modules

When searching for themes and modules, it’s important to select one that’s actively maintained, actively developed, works with your version of drupal, and has security advisory coverage. Visit Drupal’s download page to find themes and modules. See Drupal’s docs on installing themes and modules if you need more help.

If composer gets killed it means you need more memory. I had to add a swapfile to sucessfully run “composer require drupal/bootstrap”. See Section 11.12 of the FreeBSD handbook if you don’t know how to add swap space.

$ cd /usr/local/www/apache24/data/

# download your theme 
$ composer require drupal/bootstrap

I like to use Drush to manage themes and modules. Drush is a command line tool that makes Drupal scripting and management easier . . . But this isn’t the only way to do it. You can enable/disable modules and themes using the web GUI too.

# list modules and themes
$ drush pm-list 

# enable your theme 
$ drush pm-enable bootstrap

# set it as the default theme
$ drush config-set system.theme default bootstrap
	
And here is our new theme in action:
A dusty old Bootstrap 3 theme
A dusty old Bootstrap 3 theme

Conclusion

Drupal has been an absolute dream compared to WordPress. Although Drupal isn’t nearly as “average user friendly” as WordPress, the ease of setup makes up for it. Drupal’s “self-diagnosis” feature is incredibly useful as well because it directs users directly to a solution. But, as with the WordPress article, I’m still sticking with Jekyll. If I ever require a more copious CMS I’ll surely choose Drupal over WordPress. Next on the list? Maybe Nextcloud while the FAMP stack is still running. I also intend to try Ghost, a CMS built with NodeJS . . . but until then I want to try out more software that can sit on top of FAMP.