In this blog post I want to become a bit more hands-on and explain how you can install the free content management system Drupal on the beta of the HCP Cloud Foundry services.
Drupal runs on PHP and also needs to have a dabase underneath to persist the content you want to put on the Drupal instance. In our example we'll provide a PostgreSQL service instance that'll also run on the beta.
This change will allow the Drupal installer to automatically detect the database instance we'll be setting up in the next steps and extract the necessary details out of the environment variables of your Drupal app on your Cloud Foundry account. If you want to learn more about it have a look at the official Cloud Foundry documentation for the environmental variables.
After saving the file please switch back again to the root folder of the drupal directory!
Configure Cloud Foundry services
Step8 - Prepare your application manifest
The last preparational task will be the creation of a manifest.yml file in the Drupal root folder.
This file is not really needed as you can provide most of the parameters already via the Command Line Interface. Nevertheless it's useful to have it, as you can post there important information around the deployment of your application. You can define in the file what the name of your app should be, which buildpack(s) you want to use for it, how much memory and disk space you want to assign to the app, etc... Checkout the corresponding documentation on Cloud Foundry for more details.
Please create the manifest.yml file in the Drupal root folder.
Now copy-and-paste the code you get here into the manifest.yml file.
Adapt the name of the application if you want to have another name for the app and save the file.
We are now ready with all the preparations and will run a few commands with the Cloud Foundry command line tool.
Step9 - Create PostgreSQL instance
First we need to create a PostgreSQL service instance with the following command:
You can see, that the name of the instance mypostgresql is the same like described in the manifest.yml we've created before in step 8.
Step10 - Push app to the cloud
Now we push the Drupal installation to your account with the following command:
Be sure you are on the root folder of the Drupal root folder prior running the command.
The output will look similar to this:
Step 11 - Checkout URL of app
Once the command is ready you can get the URL with the command
The URL of the app will be provided under the urls column
Install Drupal in your account
Step12 - Call the Drupal installer
Now copy-and-paste the URL in your browser and add
at the end of the URL.
You can now go through the Drupal installation. Those of you who want to learn more around Drupal can read through the Getting-Started page of Drupal for more details.
Step13 - Configure Drupal installation
If all went all you should only have to click once on Save and Continue in the initial screen and after selecting the language you should already been on the Configure site step. As we configured the database detail already in step 7 inside the settings.php you don't have to provide the credentials of your PostgreSQL instance manually. Those settings are fetched from the VCAP_SERVICES variable of your app.
In case you need to provide the database connection details something went wrong in step 7. Did you really copy-and-paste the complete code that I've provided?
Step14 - Setup the content in your Drupal system
After having provided all the details you should be able to jump to your Drupal instance by clicking on the "Visit your new site." link.
That link is actually the URL of the app you've pushed to your beta account.
Now you can start configuring Drupal to your needs.
After Drupal is running, you can have a more detailed look at the changes we've made to the standard Drupal installation in steps 4 - 8.
You might also considering looking into the cockpit of your HCP CF services beta account to cross-check the application information and to also have a look at the environment variables we've talked about in step 7.
Also checkout the service bindings and the service provisioning, too. Most of what you have done with the Cloud Foundry Command Line Interface can also be done in your account cockpit. Just play around a bit and learn how the application management works.