Flask Biography Tutorial Part I : Preparing Your Local Environment

Preparing local environment
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 :

  1. Ruby and Ruby Gems
  2. Git
  3. 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 

Done. 

All tools are setup and installed in the correct location, ready to serve your need... Cool 

But, if you are on Windows, these are what you have to do :

  1. 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.
  2. Download and install latest Git for WindowsGit 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. 
  3. 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
  4. 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, ...

Done 

 .. done. 

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. 

Stay tuned! 




Leave comments

authimage
  • If you're on Windows (Windows 10 in my case) you might have some trouble following the instructions on OpenShift for installing rhc. I found I must install Ruby 1.9.3. When using Ruby 2.2.2 "gem nistall rhc" does not install dependencies. Then running "rhc setup" results in many errors.

    • Davers
  • On the other hand, I haven't tried to use Appengine before. I will try when I got the chance! Thanks for mentioning. Making me curious ;)

  • Thanks for explaining this. I never heard of openshift before. It sounds like a good alternative for the appengine.

    • Joe

Copyright(c) 2014 - PythonBlogs.com
By using this website, you signify your acceptance of Terms and Conditions and Privacy Policy
All rights reserved