Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Rui-Nogueira
Advisor
Advisor


In previous blog posts I've already talked about the availability of the beta for the "SAP HANA Cloud Platform, starter edition for Cloud Foundry service... and SAP's strategy behind the usage of Cloud Foundry and OpenStack on SAP HANA Cloud Platform.

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.

Table of contents


Getting an account and Drupal


Step1 - Get account and Cloud Foundry tooling


First, get an account for the free beta offering "SAP HANA Cloud Platform, starter edition for Cloud Foundry services".

Just follow the instructions in the official documentation and first sign up, secondly you need to get the Cloud Foundry command line interface, and log on to your account.


Step2 - Get Drupal


Now you need to download Drupal from the Drupal download page. I've taken drupal-7.43


Prepare Drupal


Step3 - Unzip Drupal installation file


Now unzip the downloaded Drupal file in a separate directory and switch over to that directory.

We'll have to do some modifications to the Drupal files.

Those of you who are lazy and know how to use Git can take the necessary files out of a git repository I've created and simply overwrite the Drupal files with the files from the git repository.

All others please go now through step 4 - 8.

Step4 - Setup the PHP Buildpack Configuration


Now create a folder called .bp-config.

This is a standard folder to configure the PHP buildpack we'll need to run Drupal.


Switch to the .bp-config folder, create a file called options.json in that folder, copy-and-paste the content from here into that file and save it.

This file will later on tell the PHP buildpack that it needs to activate some specific PHP extensions that Drupal needs. Thi

After saving the file please switch back to the root folder of the Drupal directory!

Step5 - setup PHP.ini


Add the content from here to file php.ini and save the file. These settings will activate the extensions we've defined in step 4.

Again: this file needs to be in the root folder of the Drupal directory!

 

Step6 - Create settings-php for Drupal


Now switch to the sub folder sites/default.

Create a file called settings.php

 

Step7 - Modify settings.php for usage in HCP CF beta account


Copy and paste the code from here into the settings.php file.

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:
cf create-service postgresql v9.4-container mypostgresql

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:
cf push

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
cf apps

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
/install.php

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.


And now?


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.

Hope this helped you a bit to use the "SAP HANA Cloud Platform, starter edition for Cloud Foundry services".

Best,
Rui

10 Comments