Zhixian's Tech Blog

2015-10-23

Setup Ubuntu (Trusty Tahr) for development

Filed under: development, ubuntu — Tags: , , , , — Zhixian @ 11:18:10 am

This blog post is on my setting up another Ubuntu Server VM.
This time I want a VM that has the common software development applications pre-installed.
As such most of the steps are similar to what I did in a previous blog post.
So on this blog post, I will start from the screen where I can select pre-packaged software.

image

Although, I was not really sure I really need the DNS server and print server, I thought “Ah well. Might as well.”
So they are included.

Setup MySql

First thing to setup is to assign a password for MySql server “root” account.
Note: You may have notice that background color have changed from purple to blue.
This was because I typed the wrong confirmation password when setting the password.

image

 

image

Setup E-mail

 

image

 

image

 

image

 

image

2015-10-15

Ubuntu Server Initial Setup

Filed under: computing, ubuntu — Tags: , , , , , — Zhixian @ 13:29:10 pm

After you have installed your Ubuntu server, you may want to do some initial setup.
Specifically, you may want to add a another account.

Adding user account

Adding users can be done using the command adduser. In the below command-line, I am creating a developer account call ‘developer’.

$ sudo adduser developer

image

After you have create the user account, it might be useful to add the account to the ‘sudo’ group so that the account can make use of the ‘sudo’ command. To do so,

$ sudo addgroup developer sudo

image

You can check which groups an account belongs to using the ‘groups’ command:

$ groups developer

image

2015-10-11

Setting up Ubuntu 14.04 Server on VirtualBox

Filed under: computing, ubuntu — Tags: , , , , — Zhixian @ 17:15:10 pm

This is a blog post that describes my setup of Ubuntu Server 14.04 (Trusty Tahr) on VirtualBox.
I intended to use this server for local software development.

Selected Software Package Description
OpenSSH server Needed for remote secure shell sessions
LAMP Linux Apache MySql PHP development stack
PostgreSQL database Best open-source database
Samba file server File sharing

Skipped Software Packages Description
DNS server Don’t really think I need it
Mail server I will describe this in a later blog post
Print server Don’t really think I need it
Tomcat Java Server Not sure if I want to use this;

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

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-09-01

Running Classic ASP on IIS in Windows 7

Filed under: web application development — Tags: , , , — Zhixian @ 00:06:09 am

This blog post describes how to enable IIS7 in WIndows 7 to run classic ASP scripts.

Assumptions

This guide assumes:

  1. You know how to go to Windows 7 Control Panel.
  2. You know how to go to Internet Information Services (IIS) Manager

Steps to enabling ASP on IIS

1. In the Control Panel, click the item labeled “Programs and Features”.

image

2. In the Programs and Features window, click on the option “Turn Windows features on or off”.

image

3. In the Windows Features dialog, scroll down until you reach the item “Internet Information Services”.
Click the plus sign next to item label to display the menu items under “Internet Information Services”.
Repeat the same steps for “World WIde Web Services” under “Internet Information Services”.
Repeat again for “Application Development Features” under “World Wide Web Services”.

In the list of items under “Application Development Features”, is “ASP”.
Checked the box next to “ASP”.
Click on the “OK” button to apply changes.

image

After you clicked on the “’OK“ button, Windows will proceed to install the classic ASP extension into IIS.

image

After installation is complete, Windows will return you back to the Programs and Features window.

image

Verify installation

If your Internet Information Services (IIS) Manager happens to be open, close it.
If you open your IIS manager, you should see a menu item labeled ASP at server node.
image

Clicking on this item will allow you to configure settings for your classic ASP runtime.

2013-06-23

How to connect to Microsoft Sql Server from Ubuntu using pyODBC

This is continuation of my previous 3-part blog post that list out the steps carried out to establish a connection to Sql Server via ODBC on Ubuntu.

Assumptions

  1. The version of Ubuntu used in this guide is Ubuntu 12.04.2 LTS (Precise Pangoline) 32-bit.
  2. unixodbc is installed on the Ubuntu system.
  3. freetds is installed on the Ubuntu system.
  4. You are trying to connect to Microsoft Sql Server 2008 or later.
  5. You know how to use a terminal session in Ubuntu.

Required materiels

  1. pyODBC (latest version is 3.0.6 as of writing)
    (downloadable from http://code.google.com/p/pyodbc/downloads/list)

Download source vs apt-get

The apt-get utility in Ubuntu does have a version of pyODBC. (version 2.1.7)
However, it is badly out-of-date (2.1.7 vs 3.0.6) and may not work well with the newer versions of unixODBC and freetds.
This is especially important if you are trying to connect to later versions of Microsoft Sql Server (2008 onwards).
It is recommended that you use the latest versions of unixODBC, freetds and pyODBC when working with the latest Microsoft Sql Server instead of relying on packages in apt-get.

PyODBC Installation Overview

The steps for installing pyODBC are as follows:

  1. Download the source zip file. (I’m assuming you know how to do this)
  2. Extract the contents of the package.
  3. Install the contents of the package.
  4. Configure your system environment variables.

Extracting contents from pyODBC zip file

1) Assuming you downloaded the pyODBC zip into the Downloads folder of your Home directory, you should see a screen like the below on your file browser.

image_thumb[1]

2) To extract the contents of the package, right-click on it. A popup menu should appear.
Select the menu item “Extract Here”.

image_thumb[3]

3) After you extracted the contents, your file browser should look like the below:

image_thumb[5]

 

Installing pyODBC

1) Start a new terminal session.
Navigate to the location where you extracted the pyODBC source files by typing cd ~/Downloads/pyODBC-3.0.6/ at the command line.

image

2a) Proceed to install pyODBC by typing python ./setup.py install on the command line.

image

If you received a screen like the below, it means that your user account do not have the necessary permissions to install pyODBC onto the system.
Type sudo python ./setup.py install on the command line to use a superuser account to perform the installation.

image

3) If the installation succeed, you should see a screen like the below:

image

 

Configure system environment variables

pyODBC has a dependency on the file libodbc.so.
This is the library of functions that pyODBC use to perform ODBC operations.
If pyODBC cannot find this file, you may see the following message:

ImportError: <libodbc.so name> cannot open shared object file: No such file or directory

The actual name <libodbc.so name> may varied from system to system. A sample screen is as follows:

image

To help pyODBC find the library, we need to declare an environment variable LD_LIBRARY_PATH and specify the location of the libodbc.so in this variable.

Assuming my libodbc.so is located at  the directory /usr/local/lib

1) Type the following at the command line, to set the variable:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

image

2) Type the following to set the variable as a global variable so that the executing environment can access this variable.
export LD_LIBRARY_PATH

image

 

[Optional]

The changes made in the previous step are not persistent.
This means you need to carry out the same steps every time you start a new terminal session.

To make this change persistent, I recommend you put these 2 commands in your shell’s startup file.
If you are using the default bash shell, this would be your ~/.bashrc file.
Put the following 2 lines at the bottom of the file and save the file.

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH

 

Testing pyODBC

For testing pyODBC, I have the following python script:

import pyodbc

database = pyodbc.connect('DRIVER=FreeTDS;SERVER=SARA\\SQLEXPRESS;UID=dbadmin;PWD=password;DATABASE=Arbalest;TDS_Version=8.0;',unicode_results=True)
cursor = database.cursor() encoding = 'utf-8' sql = "SELECT * FROM Arbalest.dbo.test;" cursor.execute(sql) for row in cursor:     print row

image

This python script assumes:

  1. I am trying to connect to the “SQLEXPRESS” Sql Server instance on a machine with the hostname of SARA
  2. The user account that I am using to log into the database is “dbadmin”
  3. The password to my user account is “password”
  4. The database that I am connecting to is “Arbalest”

For Sql Server later than 2005, having the parameter TDS Version=8.0 is recommended.

If this parameter is not defined in the connection string, the pyODBC may work correctly.

Assuming I save this script to a file call “test.py”, I would be able to run the script by typing the following on the command line:

python test.py

image

Note that the connection string that I used above in the pyodbc.connect statement is what is referred to as DSN-less connection string.

With this you should be able to connect to Sql Server from python using pyODBC.

2013-06-22

How to install FreeTDS on Ubuntu

Filed under: computing — Tags: , , , , , , , — Zhixian @ 17:47:06 pm

This post describes the steps carried out to build freetds from source files.
It then go on to describe the steps carried out to install freetds.

This is part of my “How to connect to Sql Server from Ubuntu” series of blog post.

Assumptions

  1. The version of Ubuntu used in this guide is Ubuntu 12.04.2 LTS (Precise Pangoline) 32-bit.
  2. You are trying to connect to Microsoft Sql Server 2008 or later.
  3. You know how to use a terminal session in Ubuntu.
  4. You have installed unixodbc.

Required materials

  1. freetds (as of this writing, latest version is 0.91.89)
    Database driver that would allow us to connect to Sybase/Sql Server database servers.
    (download from
    ftp://ftp.freetds.org/pub/freetds/stable/)

freetds installation steps overview

  1. Download source code for freetds. I assume you know how to do this.
  2. Extract source code out of freetds gzipped package
  3. Compile and install freetds . This involves the following steps:
    1. ./configure
    2. make
    3. make install

Extract source code out of freetds gzipped package

1) Assuming you downloaded the freetds gzip file to a directory call Downloads in your home directory, you should see something like the below in your file manager:

image

2)  Right-click on the package.
A popup menu should appear.
Select the menu item “Extract Here” to extract the contents of the package.

image

3) After the contents are extracted, you should now see a screen like the below in the file manager:

image

 

Compile freetds

1) Start a terminal session.
Navigate to the directory where you extract the freetds source files.

image

2) Configure the compilation process by typing ./configure on the command line.

image

This step checks to make sure that the system has all the required components needed to build freetds.

3) If there are no error messages in the configuration, proceed to build freetds by typing make on the command line.

image

4) Assuming the compilation succeed, you can proceed to install freetds onto your system.
You do this by typing make install on the command line.

image

If for some reason your user account do not have sufficient persmissions to install freetds, you will probably see error messages in the terminal .
This means you need to use a superuser account to install freetds.
In which case you would type sudo make install on the command line instead.

image

5. After installation, you should get a screen like the below:

image

With this, you have installed freetds into your Ubuntu system.

How to install unixODBC on Ubuntu

Filed under: computing — Tags: , , , , , , — Zhixian @ 14:04:06 pm

This post describes the steps carried out to build unixODBC from source files.
It then go on to describe the steps carried out to install unixODBC.

This is part of my “How to connect to Sql Server from Ubuntu” series of blog post.

Assumptions

  1. The version of Ubuntu used in this guide is Ubuntu 12.04.2 LTS (Precise Pangoline) 32-bit.
  2. You are trying to connect to Microsoft Sql Server 2008 or later.
  3. You know how to use a terminal session in Ubuntu.

Required materials

  1. unixodbc (as of this writing, latest version is 2.3.1)
    Allows unix/linux platforms to use ODBC to connect to databases
    (downloadable from http://www.unixodbc.org/download.html)

Download source vs apt-get

The apt-get utility in Ubuntu do have a version of unixODBC.
However, it is out-of-date and may not work well with later versions of Microsoft Sql Server and their corresponding database drivers.
This is especially important if you are trying to connect to later versions of Microsoft Sql Server (2005 onwards).
It is recommended that you get the the latest versions of unixODBC when working with the latest Microsoft Sql Server instead of relying on packages in apt-get.

unixodbc installation steps overview

  1. Download source code for unixodbc. (I assume you know how to do this.)
  2. Extract source code out of unixodbc gzipped package.
  3. Compile unixodbc. This involves the following steps:
    1. ./configure
    2. make
    3. make install

Extracting sourcecode out of unixodbc package

1) Assuming you download the unixodbc gzip file to a directory call Downloads in your home directory, you should see something like the below in your file manager:

image

2)  Right-click on the package.
A popup menu should appear.
Select the menu item “Extract Here” to extract the contents of the package.

image

3) After the contents of the file were extracted, you should now see something like the below in your file manager:

image

 

Compile unixodbc

1) Start a terminal session.
Navigate to the directory where you extract the unixodbc source files.

image

2) In the folder. configure the compilation process by typing ./configure on the command line.

image

The system will then check through if the system has all the required components build unixodbc.

3) If you do no see any error messages in the configuration step, you can proceed to build the unixodbc by typing make on the command line.

image

This is the step that takes the source code and compile them to make unixodbc.

4)  Assuming the compilation succeed, you can now install unixodbc into your system.
This is done by typing make install on the command line.

image

If you do not have sufficient permissions to install unixodbc into your system, you may see permission denied and error messages.
If that is the case, type sudo make install on the command line instead.

image

5)  Your final result screen should look like the below.
It would also be useful to note down the directories highlighted below.
These are folders where you will be placing your ODBC configuration.

image

 

With this, you have installed unixodbc into your Ubuntu system.

Create a free website or blog at WordPress.com.