Thursday 21 May 2015

Openshift users have this major disadvantage. They have to choose between scaleability and phpMyAdmin. Once you make your app scalable, you won't be able to install phpMyAdmin cartridge and and once you install phpMyAdmin, you won't be able to make the app scalable.

But what developers have at their advantage is that phpMyAdmin is opensource and free to download. So installing phpMyAdmin on a scalable OpenShift app is now a matter of a few steps : downloading, extracting, configuring and uploading.

Pre-Requisites:

Before starting, I assume the following:

  1. that you have created an app at openshift.
  2. that you have installed all required tools ie. GIT-SCM, Ruby 1.8.7 or higher, rhc tools, etc as described here. 
  3. that you know how to modify an openshift app.


Step 1:

Clone your app source code to a local folder
$ git clone <git_url> <directory to create>

Step 2:

If you are a fan of phpMyAdmin, I don't have to tell you that you can download it here.

Step 3:

Now extract it to the root of your local code repository. If you want to be a little possessive about your phpMyAdmin URL, change the name of the folder from "phpmyadmin" to something else, say "mypma". Remember this folder name.

Step 4:

  1. Just open the folder you just copied and look for the file config.sample.inc.php. Make a copy of the file and rename it to config.inc.php. 
  2. Just before the first configuration option you find, add the following lines:
define('DB_HOST',getenv('OPENSHIFT_MYSQL_DB_HOST')); define('DB_PORT',getenv('OPENSHIFT_MYSQL_DB_PORT'));  define('DB_NAME',getenv('OPENSHIFT_GEAR_NAME'));
  1. Look for the line that contains $cfg['blowfish_secret'] = ''; and change the value to some random text.
  2. Make sure the lines that contain the following are either absent or commented out.
    1.  $cfg['Servers'][$i]['user']
    2.  $cfg['Servers'][$i]['password']
  3. Make sure $cfg['Servers'][$i]['AllowNoPassword'] is set to false.
  4. For added security, force SSL on phpMyAdmin.
  5. $cfg['ForceSSL'] = true;
  6. If you want to make more customizations, see here.
  7. Save config.inc.php.


Step 5:

You can now push the code to your openshift gear using the following commands after making changes to the code in rest of your app/project if you want.
$ git add .
$ git commit -m "Added phpMyAdmin"
$ git push

That's all folks, You just have to log on to https://<app_name>-<domain>.rhcloud.com/<pma_folder_name>, enter your database login username and password (provided by openshift at the time of creating your app) and once again a treasure lies before you.

I'll sign off here. Please add your feedback below if you liked what you read. 
Categories: , , ,

3 comments:

  1. i cant seem to coonect to MySQL even after suppling the MySQL usename and password

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. this is just the opinion i'm locating anywhere. thanks on your weblog, I just subscribe your weblog. this is a affectionate weblog.. app cloner

    ReplyDelete

Subscribe to RSS Feed Follow me on Twitter!