Zhixian's Tech Blog

2014-12-31

How to Install Postgresql onto Ubuntu (Trusty Tahr)

Filed under: computing — Tags: , , , , , — Zhixian @ 00:08:12 am

This blog post describes how I install Postgresql 9.4 onto Ubuntu.

You may want to following this blog post, Installing Postgresql using installer from EnterpriseDB on Ubuntu instead.
The below blog post will install latest version of Postgresql at this time of writing (version 9.4).
Unfortunately, the graphical interface tool installed pgAdmin III that is installed with this set of instructions uses an older version of pgAdmin III (version 1.18.1 at this time of writing).
This version does not support Postgresql 9.4.

Summary

  1. Create Repository List File
  2. Import Signing Key
  3. Update apt-get
  4. Install Postgresql
  5. Install Additional Modules

Create Repository List File

Create the repository list file using the following command:

echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list

zhixian@SARA: ~_161

Import Signing Key

Import signing key for Postgresql by running the following command:

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

zhixian@SARA: ~_162

Update apt-get

Run the following command to update your apt-get.

sudo apt-get update

zhixian@SARA: ~_163

Install Postgresql

Run the following command:

sudo apt-get install postgresql-9.4

zhixian@SARA: ~_164

Install Additional Modules

The installation above is quite bare-bones. It does not provide a graphical tool or development libraries.
To add them, run the following command:

sudo apt-get install postgresql-contrib-9.4 pgadmin3 libpq-dev postgresql-server-dev-9.4

postgresql-contrib-9.4 – additional supplied modules
libpq-dev – libraries and headers for C language frontend development
postgresql-server-dev-9.4 – libraries and headers for C language backend development
pgadmin3 – pgAdmin III graphical administration utility

zhixian@SARA: ~_165

After installation have complete, you can find the graphical tool under Applications > Programming > pgAdmin III from the desktop menu.

Workspace 1_166

Reference

Linux downloads (Ubuntu) (http://www.postgresql.org/download/linux/ubuntu/)

Advertisements

2014-12-30

How to install MonoDevelop on Ubuntu

Filed under: computing — Tags: , , — Zhixian @ 23:33:12 pm

This blog post describes how I install MonoDevelop onto Ubuntu.

Summary

  1. Add Mono Project Signing Key
  2. Add Package Repository
  3. Install MonoDevelop
  4. Reference

Add Mono Project Signing Key

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

zhixian@SARA: ~_156

Add Package Repository

echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list

zhixian@SARA: ~_157

Install MonoDevelop

sudo apt-get install monodevelop

zhixian@SARA: ~_158

After installation have complete, you should be able to find MonoDevelop under Applications > Programming > MonoDevelop from the desktop menu.

Workspace 1_160

Reference

Install MonoDevelop on Linux (http://www.monodevelop.com/download/linux/)

How to install Mono on Ubuntu (Part 2 of 2)

Filed under: development — Tags: , , , , , — Zhixian @ 00:06:12 am

This is continuation of my previous blog post How to install Mono on Ubuntu.
This part focus on testing the installation to make sure that you have the minimal to compile C# source code and to run ASP.NET web applications.

Assumptions

  1. You have installed Apache HTTP Server
  2. You have followed the installation instructions in the previous blog post.
  3. You know how to create folder and files in Ubuntu.
  4. You know how to start a terminal session and run commands in it.
  5. You know how to navigate to other directories using terminal session.

Summary Steps

  1. Compiling and Running helloworld
  2. Create a Apache virtual host

Compiling and Running helloworld

Create a folder to hold your source code. For example, I use “dotnet”.

Projects_134

Inside this folder, create a file call helloworld.cs.

dotnet_135

Edit the contents of this file and replace it with the following:

// Hello1.cs
public class Hello1
{
   public static void Main()
   {
      System.Console.WriteLine("Hello, World!");
   }
}

After saving the file, start a new terminal session and navigate to the directory where you saved the file.

zhixian@SARA: ~-Projects-dotnet_136

The command to run the compiler for C# in Mono is mcs. Compile helloworld.cs by entering the following at the command-line:

mcs helloworld.cs

After running this command, you should see that you have a file call helloworld.exe in your project directory.

zhixian@SARA: ~-Projects-dotnet_137

To test run your application, enter the following command at the command-line.

./helloworld.exe

zhixian@SARA: ~-Projects-dotnet_138

You should see the words “Hello, World!” after you run the command.

Create a Apache virtual host

Now that we are sure the compiler for C# works, we will test if mod_mono can run ASP.NET applications.
What we are going to do at this section is to create a virtual host on Apache to host our ASP.NET application.

Steps

  1. Define ASP.NET application
  2. Configure Apache virtual host

Define ASP.NET application

We are going to create our test application in this section.

Create a folder to hold the contents of your ASP.NET web application.
In my case, I choose to put my file in a directory call zxtech.

Websites_139

Inside this folder, create a file call test.aspx.

zxtech_141

Edit test.aspx and replace the contents with the following:

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>ASP Test Page</title>
  </head>
  <body>
        <form id="form1" runat="server">
          <asp:label id="lbl1" runat="server">ASP Test Page</asp:label>
        </form>
  </body>
</html>

test.aspx (~-Yandex.Disk-Websites-zxtech) - gedit_142

Save the file.
After saving the file, note the full path to the folder (press <CTRL>-L or press the button next to the Location buttons.)

You will need this information when configuring Apache virtual host.

zxtech_140

Configure Apache virtual host

Ok. Here’s where things starts to get a little sticky.
At your terminal session, navigate to Apache HTTP server’s sites directory (its /etc/apache2/sites-available/ by default) by entering the following command at the command-line:

cd /etc/apache2/sites-available/

zhixian@SARA: -etc-apache2-sites-available_143

By default, there should be 2 files in the folder, 000-default.conf and default-ssl.conf.
Make a copy of 000-default.conf for your virtual host (I am picking dev.zxtech.web as my virtual host name) by running the following command:

sudo cp ./000-default.conf ./dev.zxtech.web.conf

zhixian@SARA: -etc-apache2-sites-available_144

After the file is copied, edit the file.
Because the file is in folder owned by the superuser, you need to run the following command to edit the file:

gksudo gedit ./dev.zxtech.web.conf &

zhixian@SARA: -etc-apache2-sites-available_145

After you opened the file, you should see the following:

dev.zxtech.web.conf (-etc-apache2-sites-available) - gedit (as superuser)_146

Things to edit on this file:

  1. ServerName
  2. ServerAdmin (optional)
  3. DocumentRoot (optional)

ServerName refers to the your virtual host name that you will be using. In the below screen shot, this will be dev.zxtech.web.

ServerAdmin refers to an e-mail address that will be used when people needs to contact the server administator.

DocumentRoot refers to the folder where you store your ASP.NET application files. This will be the location of the folder that that you have noted in the previous section. In the below screen shot, this will be /home/zhixian/Yandex.Disk/Websites/zxtech.

After update, the file should look something like the below.

-dev.zxtech.web.conf (-etc-apache2-sites-available) - gedit (as superuser)_147

Things to add on this file:

  1. DirectoryIndex
  2. MonoAutoApplication
  3. AddHandler
  4. MonoServerPath
  5. MonoDebug
  6. MonoSetEnv
  7. MonoApplications
  8. Apache directory configuration
  9. Apache location configuration

DirectoryIndex refers to the default documents that will be use if user navigate to the folder without specifying a specific filename.

MonoAutoApplication refers to using a scheme in mod_mono that allows accounts on a machine to deploy ASP.NET pages without requiring to do any configuration. I prefer to do manual configuration, and so am disabling it here.

AddHandler designates files with specified file extensions to be process by mod_mono.

MonoServerPath allows you to specify the version of Mono runtime to use.
In the below screen shot, we are using the latest mono-server 4 which is equivalent to using ASP.NET 4.0.

MonoSetEnv is use to set an environment variable for use with the Mono run time used to execute the web application.
In the screen shot below, I defined MONO_IOMAP.
MONO_IOMAP is defined to take care of case-sensitivity issues. You can read more about it here.

MonoApplications is use to tell mod_mono that the ASP.NET application exists at the root directory of the web site (/) and this root directory maps (:) to the folder /home/zhixian/Yandex.Disk/Websites/zxtech (hence “/:/home/zhixian/Yandex.Disk/Websites/zxtech”)

Aside from the above Mono configuration, you may need to add an Apache directory configuration section especially if you are are hosting the web application files outside of Apache’s default DocumentRoot location which is /var/www/

 <Directory /home/zhixian/Yandex.Disk/Websites/zxtech>
 Options Indexes FollowSymLinks
 AllowOverride None
 Require all granted
 </Directory>

You will also need to add an Apache location configuration section.

 <Location "/">
 Order allow,deny
 Allow from all
 MonoSetServerAlias dev.zxtech.web
 SetHandler mono
 SetOutputFilter DEFLATE
 SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary
 </Location>
 <IfModule mod_deflate.c>
 AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript
 </IfModule>

After you added the sections, your configuration file should look like the below.

dev.zxtech.web.conf (-etc-apache2-sites-available) - gedit (as superuser)_153

After defining the configuration file, you can enable the website.

sudo a2ensite dev.zxtech.web.conf

zhixian@SARA: -etc-apache2-sites-available_151

The last step to get our virtual name hosting working is to edit our hosts located at /etc/hosts

zhixian@SARA: ~_150

In your text editor, add a line

127.0.1.1 dev.zxtech.web

hosts (-etc) - gedit (as superuser)_154

After this is done, you can navigate to http://dev.zxtech.web/test.aspx to test your sample web application.
You should see:

ASP Test Page - Firefox Developer Edition_155

Reference

A nice tutorial to C# can be found here (http://msdn.microsoft.com/en-us/library/aa288463%28v=vs.71%29.aspx)

2014-12-28

How to install Mono on Ubuntu

Filed under: web application development — Tags: , , , , , — Zhixian @ 01:29:12 am

This blog post describes my installation steps to get Mono running on my Ubuntu.

I will write another blog post on testing this installation.

Assumptions

  1. You have Apache HTTP Server installed
  2. You know how to start a terminal session and run commands there.

Summary

  1. Add Mono Project GPG signing key
  2. Add Mono Package Repository
  3. Add mod_mono Repository
  4. Update package cache
  5. Install Mono
  6. Install mod_mono
  7. Enable mod_mono
  8. Reference

Mono Project GPG signing key

This step adds the GPG signing key to your key-ring.
This signing key is used to make sure the installed files are valid.
To add the key to your key ring, start a terminal session and run the following command:

sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

zhixian@SARA: ~_120

Add Mono Package Repository

This step add the Mono package repository into apt-get list of available package repositories.
Enter the following command at the command-line of the terminal session:

echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list

zhixian@SARA: ~_121

Add mod_mono Repository

This step adds the repository for mod_mono to apt-get list of available package repositories.
mod_mono is use by Apache HTTP server to interpret .NET web pages.
To add the repository, run the following command at the command-line:

echo “deb http://download.mono-project.com/repo/debian wheezy-apache24-compat main” | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list

zhixian@SARA: ~_124

Update package cache

To update the apt-get package cache to use the repositories that you just added, run the following command at the command-line:

apt-get update

zhixian@SARA: ~_125

Install Mono

To install the complete Mono package enter the following at the command-line:

sudo apt-get install mono-complete

zhixian@SARA: ~_126

After the initial listing of the packages that will be installed, you will be given a prompt asking if you would like to proceed install Mono. Enter “Y” to proceed with the installation process.

zhixian@SARA: ~_127

zhixian@SARA: ~_128

Install mod_mono

Run the following command to add mod_mono:

sudo apt-get install libapache2-mod-mono

zhixian@SARA: ~_129

You might see an error exit status at the end of the installation process.
This is due to some configuration issue in the installation process.
I’m not too sure what exactly is the issue but it seems fine to ignore it.

zhixian@SARA: ~_131

Enable mod_mono

mod_mono is enabled by running the following command:

sudo a2enmod mod_mono

zhixian@SARA: ~_133

Reference

http://www.mono-project.com/docs/getting-started/install/linux/

https://help.ubuntu.com/community/ModMono

2014-12-21

Google App Engine development on Ubuntu for Python (Part 2 of 2)

Filed under: web application development — Tags: , , , , , — Zhixian @ 23:46:12 pm

This blog post describes how to run Google App Engine (GAE for short) on Ubuntu.
This is the second part of a 2-part blog post.
This blog post focus on writing a simple (helloworld) application just to demonstrate that the setup works and that we can deploy our application.

Parts

  1. Setting up Google App Engine SDK
  2. Running Google App Engine (this article)

An aside related article, How to Add Google App Engine project to Google Developers Console.

Assumptions

This blog post builds on the previous blog post Setting up Google App Engine SDK and assumes that you have followed the instructions there.

This blog post also assumes you know how to register a Google App Engine project in the Google Developers Console.
If you need help with this, you can take a look at my blog post, How to Add Google App Engine project to Google Developers Console.

Part 2 Summary

  1. Create project folders (opinionated)
  2. Create request handler
  3. Create configuration file
  4. Test project
  5. Deploying project

Create Project Directory

(Opinionated) I usually store my projects in a Projects folder in my home folder.

zhixian_084

Inside this Projects folder, right-click the folder area to display the context menu.
Click Create Folder from the context menu.

zhixian@SARA: ~-Projects_085

Name the folder HelloWorld.
So your Projects folder, should look like the below.
The files (request handler and configuration) will be stored inside the HelloWorld folder that you have created.

Projects_086

Create Request Handler

Double-click the HelloWorld folder to open the folder.
Right-click in the folder area to display the context menu.
Click Empty File from the context menu.

HelloWorld_087

Name the file as

HelloWorld.py

Your HelloWorld folder should look like the below:

HelloWorld_088

Right-click the HelloWorld.py file that you just created to display its context menu.
Click Open with Text Editor from the context menu to edit the file.
This will open the file in your configured text editor. By default, this should be gedit.

HelloWorld_090

Copy and paste the below into the file.

import webapp2

class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write('Hello, World!')

application = webapp2.WSGIApplication([
    ('/', MainPage),
], debug=True)

After you paste the above content into the file, it should look like the below.
Note the amount of space used for indentation.
This is important in Python as indentation is used to indicate code blocks.

Click on Save on the toolbar to save the file.

HelloWorld.py (~-Projects-HelloWorld) - gedit_092

Create Configuration File

In your HelloWorld folder, right-click in the folder area to display the context menu.
Click Empty File from the context menu.

HelloWorld_093

Name this file

app.yaml

HelloWorld_095

Right-click the app.yaml file that you just created to display its context menu.
Click Open with Text Editor from the context menu to edit the file.

HelloWorld_096

Copy and paste the below into the file, replacing the your-app-id with the project id that you defined in your Google Developers Console.

application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: HelloWorld.application

Now, you are ready to test the project.

Test Project

To test your project, open a terminal session and go to the folder that holds your project folder.
For my example, my HelloWorld project is created in a folder call Projects in my home folder.
So I would type the following command after starting the terminal session.

cd Projects

If I list the contents of the Projects folder, it should look like the below:

zhixian@SARA: ~-Projects_105

To run the HelloWorld application,

  1. Enter the following at the command prompt:

    dev_appserver.py HelloWorld/

  2. You will be prompt to give permission for the dev_appserver script to check for updates on startup.
    Enter “n” to disallow this check. Leaving this as “Y” or blank will allow dev_appserver to check for updates.
  3. Note the url of the “default” module.
    This is the url that your application is being hosted at.
    By default it is:

    http://localhost:8080

  4. Note the url of the admin server.
    This is the url that of the local testing administration server to your application.
    By default it is:

    http://localhost:8000

zhixian@SARA: ~-Projects_104

If you open your browser and navigate to the url of the “default” module (http://localhost:8080), you should see:

Firefox Developer Edition_107

If you open your browser and navigate to the url of the admin server (http://localhost:8000), you should see:

Instances - Firefox Developer Edition_108

To stop the test server, press <Control>-<C> keys combination.

zhixian@SARA: ~-Projects_109

Deploy Project

To upload the project to Google:

  1. Enter the following command at the command prompt:

    appcfg.py update HelloWorld/

  2. Enter your Google (gmail) account.
  3. Enter the password to your account.
  4. After the update has complete, you should see “Deployment Success”, somewhere near the end.

zhixian@SARA: ~-Projects_110

After you have deployed the application, you can access it at:

http://<project-id>.appspot.com/

Firefox Developer Edition_111

Reference

  1. Hello, World! – Python – Google Cloud Platform
  2. Uploading Your Application – Python – Google Cloud Platform

How to Add Google App Engine project to Google Developers Console

This blog post describes how to create add Google App Engine project.

Assumption

You have a Google account.

Summary

  1. Log in to Google Developers Console
  2. Create Project

Log in to Google Developers Console

In your web browser, navigate to Google Developers Console (https://console.developers.google.com/)

Google Developers Console - Firefox Developer Edition_097

After you logged in, you should be redirected to your project page.

Create Project

Click Create Project to display the new project.

Google Developers Console - Firefox Developer Edition_098

On the New Project dialog, enter:

  1. A name for your project.
    For example, I am naming my hello world project as zx-helloworld.
  2. An id for your project.
    Important This id will be used for the deployment of your project.
    For example, I am naming my hello world id as zx-helloworld.
  3. Click Create to add the project.

Note

The project id needs meet the follow criteria:

  1. Starts with a lower-case letter (a-z)
  2. May contains lower-case letters, digits (0-9) or hyphen (-)

Google Developers Console - Firefox Developer Edition_099

After you clicked Create, the dialog will close.
You should see a small popup at the lower right-hand corner of the page.

Google Developers Console - Firefox Developer Edition_100

The popup should indicate that its creating the project.

Google Developers Console - Firefox Developer Edition_100

After the project is created, it should redirect you to the project dashboard.

Google Developers Console - Firefox Developer Edition_101

The popup in the lower right corner of the page, should have a green checkbox.

Google Developers Console - Firefox Developer Edition_102

With this, your Google App Engine project can be deployed using the project id that you defined.

2014-12-17

How to install Microsoft TrueType Core Fonts for the Web in Ubuntu

Microsoft had release some fonts for use with Internet web pages.
These fonts are generally designed to be legible on screen and hence theoretically suitable for anything viewed on screen.

Summary

  1. Installation
  2. Verify

Installation

These fonts can be installed via Ubuntu Software Center (search term: ttf-ms).

After you entered the search term, click on the item labeled Installer for Microsoft TyueType core fonts.
Click on the Install button to initiate the installation process.

Ubuntu Software Center_064

After you clicked on the Install button, an EULA (End User License Agreement) dialog will appear shortly.
Checked the check box to agree with the terms and click on the Forward button to proceed the installation process.

Debconf on SARA_066

After a short while, the fonts would have been installed.

Ubuntu Software Center_067

Verify

This fonts installation page will add the following fonts into your system:

  1. Andale Mono
  2. Arial
  3. Arial Black
  4. Comic Sans MS
  5. Courier New
  6. Georgia
  7. Impact
  8. Times New Roman
  9. Trebuchet MS
  10. Verdana
  11. Webdings

To check the fonts installed on your system, you can use the Font Viewer that comes with Ubuntu.
The Font Viewer can be accessed via Applications > Accessories > Font Viewer from the desktop menu.

Workspace 1_068

Note that in some cases, you may see a repeated entry as with the Andale Mono font shown below.

Font Viewer_069

This is normal.
The cause of this duplication is because in the installation folder (/usr/share/fonts/truetype/msttcorefonts by default) contains links that back point to the font file.
When using font viewer to view fonts, it read the link as a separate font. Hence the double count.

zhixian@SARA: -usr-share-fonts-truetype-msttcorefonts_070

2014-12-16

How to install and setup Yandex Disk on Ubuntu

This blog post is about installing and configuring Yandex.Disk, a cloud storage service.

Summary

  1. Assumptions
  2. Installation
  3. Configuration
  4. Launch on startup

Assumptions

This application is priced at $0.
As such, installation requires the use of an Ubuntu One account.
It is assumed that you have such an account.

It is also assumed that you have a Yandex account to use this service.
At this time of writing, the service remains free.

Installation

Yandex.Disk can be installed via Ubuntu Software Center (search term: yandex).
Click on the More Info button to view details.

Ubuntu Software Center_052

In the software description page, click on the Buy button.
At this time of writing, its priced at $0.

Ubuntu Software Center_053

After you pressed Buy, there will be a Terms of Use dialog.
Click on the Accept button to accept the terms of use.

Terms of Use_054

After you clicked on the Accept button, you need to log in to your Ubuntu One account.

Ubuntu Software Center_055

After you entered your credentials and log in to your Ubuntu One account, the installation for the application should proceed accordingly.
After the installation has complete, you should be able to access it from the desktop menu:
Applications > Internet > Yandex Disk

Workspace 1_058

After you click on the menu item, it will start a console session describing the usage of Yandex Disk command, yandex-disk.

zhixian@SARA: ~_059

Configuration

To setup your Yandex Disk, type the following command in the Yandex Disk console session:

yandex-disk setup

The setup process will prompt you for:

  1. Your proxy server information
    (I entered “N” as I do not use a proxy server)
  2. Credentials to your Yandex account
  3. Path to a folder on your local disk to store your Yandex Disk files.
    (I left this field as blank to use the default proposed path)
  4. Whether to start Yandex Disk on startup
    (I entered “Y” to start Yandex Disk on startup)

zhixian@SARA: ~_062

After setup is done, the background (daemon) process will begin to synchonize files from your Yandex Disk in the cloud to the path that you defined above in point 3 (/home/zhixian/Yandex.Disk).

When you examine the folder after a short while, you should see files in your Yandex Disk appearing in the folder.

Yandex.Disk_063

Launch on startup

When doing the setup, you might have indicated that you would like Yandex Disk to launch on startup.
As of this writing, this may not be working correctly.
To remedy this:

Go to the System > Control Center on the desktop menu.

Workspace 1_074

In the Control Center window, click on Startup Applications. to open the Startup Applications Preferences dialog.

Control Center_076

In the dialog, click Yandex.Disk in the lists of additional startup programs.
Then click on Edit button to open the Edit Startup Program dialog.

Startup Applications Preferences_082

In the Edit Startup Program dialog, change the command from:

yandex-disk start

to

/opt/yandex-disk/yandex-disk start

Edit Startup Program_081

After you click Save to close the dialog, Yandex Disk should launch on startup correctly now.

2014-12-04

Google App Engine development on Ubuntu for Python (Part 1 of 2)

Filed under: development — Tags: , , , , , , , , , , , — Zhixian @ 12:21:12 pm

This blog post describes how to run Google App Engine (GAE for short) on Ubuntu.
This is a 2-part blog post.

Parts

  1. Setting up Google App Engine SDK (this article)
  2. Running Google App Engine

An aside related article, How to Add Google App Engine project to Google Developers Console.

Part 1 Summary

  1. Introduction
  2. Assumptions
  3. Python Version
  4. Installing Google App Engine

1. Introduction

Google App Engine is a PaaS (Platform as a Service) provided by Google.
Currently, GAE supports 4 programming languages.
I will be using Python as programming language of choice for this blog post.

2. Assumptions

In following this blog post, I assume:

  1. you have a working Google account
  2. you know how to start a terminal session and enter commands into it.
  3. you know how to use a browser to download files
  4. you know how to extract files from archives

Note: It may be obvious, but any time you see my name “zhixian” in any of screen shots or commands, you can safely assume that its should be referring to your username in your context.

3. Python Version

By default, Python is installed on Ubuntu.

The version of Python that I am using for this blog post is 2.7.6.
To check which version of Python you are running, typed the following command in a terminal session:

python –version

zhixian@SARA: ~_022

4. Installing Google App Engine

2 steps:

  1. Getting Google App Engine SDK (Software Development Kit)
  2. Extracting files from Google App Engine SDK
  3. (Optional) Move extracted files out of Downloads folder
  4. (Optional) Add location of extracted files to PATH environment variable

4.1 Getting Google App Engine SDK (Software Development Kit)

You can download the Google App Engine SDK at https://cloud.google.com/appengine/downloads

Steps:

  1. Enter the url https://cloud.google.com/appengine/downloads in your browser navigation bar.
  2. On the download page, click on the button “Google App Engine SDK for Python” to display the available download options
  3. Pick the link “google_appengine_1.9.15.zip” under package column for “Linux/Other Platforms” row to download the zip file.

Download the Google App Engine SDK - Google App Engine — Google Cloud Platform - Mozilla Firefox_023

4.2 Extracting files from Google App Engine SDK

After you have download the zip file, you should see the zip file in your download folder.

Downloads_025

Right-click on the zip file to display it’s context menu.
From the context menu, select “Extract Here”.

Downloads_026

After you extracted the files, you should see:

Downloads_027

I will refer to the location of google_appengine folder as GAE home directory for the rest of this blog post.

4.3 (Optional) Move extracted files out of Downloads folder

This step is optional and is entirely opinionated. It may not be appropriate for enterprise deployment.

The files that we extracted are in the default “Download” folder.
This folder may get cluttered over time.
My preference is to create a “Apps” directory and move the extracted files into this folder.
So, my final setup is something like the below:

Apps_028

google_appengine_030

4.4 (Optional) Add location of extracted files to PATH environment variable

This step is intended to provide convenience. It is not essential.

The location of the extracted files is dependent on whether you performed the previous step.

If you performed the previous step and moved the folder to an Apps folder, the location should be:
~/Apps/google_appengine

If you did not do the step, the location should be:
~/Downloads/google_appengine

As such, type the following:

export PATH=$PATH:<location_of_google_appengine>

Before you enter the following command, to examine the contents of your current PATH environment variable:

echo $PATH

zhixian@SARA: ~_032

After you enter the export PATH command, you should see a result like the below:

zhixian@SARA: ~_033

Note: Performing this command only affects the PATH environment variable for this session.
This means that every time you start a new terminal session, you have to do the same thing.
You may want to consider putting this in your .bashrc file.

I’m kind of lazy to explain what is the .bashrc file. So I’m just going to paste the screenshots of the steps for editing the .bashrc file with annotations:

At the command-line type the following command to edit the file:

pico ~/.bashrc

zhixian@SARA: ~_044

Note: pico is an alias for nano, a text-editor.

zhixian@SARA: ~_045

After you have opened the file for editing, scroll to the end of the file using the down arrow or page down key:

zhixian@SARA: ~_046

At the end of the file, enter the export PATH command.
Then press the <CTRL>-X key combination on your keyboard to exit the editor.

zhixian@SARA: ~_047

Because we did not save changes when we exit the editor, there will be a prompt asking if you want to save changes.
Press the Y key on your keyboard to save changes.

zhixian@SARA: ~_048

After you enter Y, there will be another prompt for the file to save the changes.
Press the Enter key on your keyboard to accept the default (the name of the file you are editing).

zhixian@SARA: ~_049

After you hit the Enter key, you should be back at the command-line.

To test the changes are effective, start another terminal session.
At the command-line, enter dev_a followed by the Tab key on your keyboard:

dev_a<tab>

The terminal session should automatically auto-complete your input into dev_appserver.py.

zhixian@SARA: ~_051

I will continue on how you get your first application running on Google App Engine in my next blog-post.

2014-12-02

Extract files from rar archives in Ubuntu

Filed under: computing — Tags: , , — Zhixian @ 10:47:12 am

Rar files is another popular file format that people use to archive files.
Unfortunately, Ubuntu does not support rar files out of the box.

You need a third-party tool call “unrar” which is available in Ubuntu Software Center (search term: unrar)

Note: This package only offer file extraction. It does not allow you to create rar archive.

Ubuntu Software Center_003

After installation, you should be able to extract the files in the rar files using the context menu of your file manager or Archive Manager.

Downloads_004

rtk4.rar [read only]_005

Older Posts »

Blog at WordPress.com.