Let's connect your local environment to the Openshift's cloud
After freely registering yourself to the Openshift cloud and before starting to develop your application, the next logical step is to install Openshift RHC Client Tools. This will making your life easier in creating, managing and monitoring your application in Openshift by using just a single command line action. Of course you can do it using Openshift Web Console, but a concise command line operation is actually all that you need.
Currently I am working on OSX running VirtualBox which in turn runs Linux Ubuntu and Windows 7. Both three OSes has their RHC Client Tools, and in my opinion, the easiest and most natural environment to work with Openshift is Linux. After all, Openshift indeed runs on Linux environment. But of course you are not limited to using Linux box as your only development environment of choice. Here, I will also shows you how to properly setup your Windows environment to start working with Openshift.
To start working with Openshift, you will need :
- Ruby and Ruby Gems
- Openshift RHC Client Tools
If you are in Linux Ubuntu, those three requirements can easily installed by issuing these three commands :
$ sudo apt-get install ruby-full rubygems git-core $ sudo gem install rhc $ rhc setup
All tools are setup and installed in the correct location, ready to serve your need...
But, if you are on Windows, these are what you have to do :
- Download and install Ruby Installer 1.9.x. Make sure to choose "Add Ruby executables to your PATH" so that you can issue ruby command from anywhere in Command Prompt.
- Download and install latest Git for Windows. Git is the cornerstone when working with Openshift. Beside for source code control management, when you push your code to Openshift, it will automatically restart your server and run the latest code for your application.
- Open a command prompt. I recommend you use Git Bash, which is already included with Git for Windows. It's a bash shell, so you will have a near compatible *nix bash shell environment to work with. And type : gem install rhc. It will install Openshift RHC Client Tool for Windows environment
- Run rch setup, and follow the instructions.
If this is the first time you work with git, chances are that you don't have a ssh key, which will be use by git command to push/pull your code to/from Openshift. To create a valid ssh key, just issue command : ssh-keygen, whether you are on Windows/*nix. It will create id_rsa (private ssh key), id_rsa.pub (public ssh key) and known_hosts (all remote host that you have already work with git).
To test that you have a working local environment, try to issue this command (whether you are on Windows/*nix), which will create application named bio :
$ rhc app-create bio python-2.7 postgresql-9.2
Wait for a moment, ...
Now you can access your application in the url http://bio-<YOUR DOMAIN NAME>.rhcloud.com. Later on you can customize this url to point to your more informative domain name. Beside creating your application online, it also cloned your application code to your current directory inside a folder named bio (or any other name that your choose for your application).
Part II of this article series, will discuss more on what application we are about to develop and what technologies will be used.