DEV Community

Kofi Oghenerukevwe H.
Kofi Oghenerukevwe H.

Posted on • Updated on

Building with IBM Cloud: Setting up a Drupal 8 website

I recently learned about IBM's Cloud offering and I decided to try it out and write about it. My objective was simple. I would set up a basic Wordpress blog using any of IBM's PaaS offerings. I am familiar with Azure so I was going in with the intention of having a Wordpress blog on IBM's equivalent of Azure's App Service. The Wordpress blog would connect and communicate with a managed MySQL database service.

You've probably guessed from the title of this post that things did not go as planned. IBM does not, at this point in time, offer a Managed MySQL service. And while I could have easily provisioned a virtual server and installed MySQL on it, I don't ever like to deal with the management of databases. I prefer to use managed database offerings because they make it easier for me to handle things like replication, backups, scaling etc.

The Good Parts

Great User Experience

The user experience for IBM's Cloud offering is the best of all the cloud services I have used and tested, and at this point, I have tested all of GCP, AWS and Azure. I immediately liked how easy it was to estimate the costs of the services I was provisioning. I think IBM has done an exceptional job making a platform that is intuitive and easy to navigate. If you have any experience with cloud services, IBM cloud's UI will be easy to get into.

Alt Text

Simple Account Billing

IBM has this concept of a lite account. The lite account is what you get by default when you sign up on IBM cloud and it gives you access to certain free / lite services. These services have very limited capabilities and in fact, I could not provision the managed PostgreSQL service without upgrading my account to a pay-as-you go account.

That said, I liked how clearly distinguished both account types were from each other and how easy it was to filter out services that were available to lite accounts.

Alt Text

The Not-So-Good Parts

The fact that there was no managed MySQL offering easily meant that I was stuck with IBM's Databases for PostgreSQL offering.

At this point, I should mention that there are third-party offerings for schematics that provision MySQL on existing Kubernetes clusters within IBM's cloud environment, but the setup for these offerings required more work than I was willing to put into my test run of IBM's cloud environment for this article. If you're familiar with Kubernetes and don't mind a little hassle, you can definitely use a lot of third-party schematics in IBM Cloud's catalog to provision things like MySQL, Wordpress, Drupal etc. I am not familiar with Kubernetes so this was not an option for me.

Cloud Foundry

Since Drupal works well with PostgreSQL, and IBM has a managed PostgreSQL service, I decided to setup a Drupal site instead. IBM's equivalent of Azure's App Service is called Cloud Foundry. Cloud Foundry has pre-configured environments for running apps written in several languages like PHP, Java, Ruby etc. Some of these environments are managed by IBM, while others are managed by developer communities.

Alt Text

Pushing Drupal's code into Cloud Foundry was easy. But Drupal requires the use of some PHP extensions that are not installed by default in the Cloud Foundry PHP Configuration so I needed a way to get Cloud Foundry to install these extensions. I was happy to find that you can in fact ssh into the Cloud Foundry environment.

You can use either the UI or IBM Cloud's CLI tools to ssh into Cloud Foundry. If you plan to use the CLI tools, you would need to install the Cloud Foundry's cf plugin which is not available by default in the ibmcloud CLI for some reason.

Alt Text

Unfortunately, while I could ssh into Cloud Foundry as a regular user, the user does not have sudo access so I could not install the required PHP extensions. And I learned that there is no way to get sudo access in Cloud Foundry public. I learned that there's a deprecated Cloud Foundry for Enterprise offering that gave you the ability to get sudo access I said, deprecated.

Code Engine

So Cloud Foundry was out. IBM cloud has another PaaS offering called Code Engine which is specifically for running container images. I tried to run the Docker Hub Drupal image with Code Engine but the setup kept failing and I have no idea why it was failing. I visited the public URL that was generated for the Drupal Project I created and the URL just kept loading and loading and.... It's almost like it was stuck in some loop and I don't think the problem was with the container because I was able to run the Drupal docker container on my local machine without any hiccups.

Alt Text

Virtual Server for Classic

I ended up needing to provision a virtual server where I had all the privileges I needed to install PHP, the required PHP extensions, and finally Drupal itself. IBM has several different types of virtual and bare metal server offerings on its cloud. I tried provisioning a couple of them and ended up with the "Virtual Server for Classic" Offering because it was the least complicated to setup and ssh into.

Alt Text

After provisioning the server, I was able to ssh into the server and do whatever I wanted. I was eventually able to install Drupal 8 and Apache on it. But then the weirdest thing kept happening. After a while, say 2 hours, the server would get a disconnected status and while the public IPs and URLs were still actively showing me the Drupal site I installed, I would no longer be able to ssh into the server. I destroyed and created the server several times to try to understand what was happening but, I have not been able to figure it out at this point. The same thing happened each time. After a few hours, the server would get disconnected and I would loose ssh access.

Managed PostgreSQL

IBM Cloud's Managed PostgreSQL offering, ideally should be in the Good Parts section of this article but, that would ruin the structure of my story it is.

IBM's Managed PostgreSQL was a breeze to setup. It was easy to choose the version of PostgreSQL I wanted to install. They have versions 9.5 through 12 available. The database credentials were easy to find and change. The public and private endpoints were easy to find and it was very easy for me to connect to the offering through the public endpoint. Ideally, I should have found a way to connect to the PostgreSQL service through its private endpoint, from within the virtual server I provisioned earlier but I was lazy so...

Concluding Thoughts

I was not able to do what I set out to do when I was preparing to write this article. I ended up setting up a basic Drupal site with PostgreSQL DB instead of a Wordpress site with MySQL DB. That said, my experience of IBM Cloud was actually enjoyable, especially since I have never used it before now. They have a number of services that are still in beta and I will be checking to see how much better they get within the coming months.

Technical Notes and Links to Documentation

If you're interested in using any of the services / tools I used for this process, here are some things to keep in mind.

  • Drupal 8 will work easily with PostgreSQL 9. You need a bit more extra setup and configurations to get it to work with a higher version of PostgreSQL. I can no longer remember why I opted to use Drupal 8 instead of the latest version - Drupal 9. But I am sure there was a reason. :)

  • For a complete list of PHP extensions required to run Drupal see the ext-* items in Drupal's composer.json Click Here

  • If you are installing Drupal behind Apache on a virtual server, you would need to enable Apache's rewrite module and put some rewrite rules in your Apache site configuration file

<Directory /var/www/your_drupal_site>
     RewriteEngine On
     RewriteBase /
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Enter fullscreen mode Exit fullscreen mode
  • Documentation for installing IBM Cloud CLI tools Click Here

  • Documentation for installing the Cloud Foundry plugin for IBM Cloud CLI tools Click Here

  • Documentation for getting started with Cloud Foundry Click Here

Top comments (1)

uwefassnacht profile image
Uwe Fassnacht

Hi Kofi, I am the Product Manager for IBM Cloud Code Engine and we'd love to understand why your Drupal container failed. Could we discuss it on Stack Overflow? Please take your question with "ibm-cloud-code-engine" ... direct link here: