Wednesday, 23 July 2008

Installing PostgreSQL

This is a quick guide to installing PostgreSQL on a Linux based system. We need to get this up and running before we can write PHP scripts to talk to the database. We need to install PostgreSQL before we can install PHP (since we need the PostgreSQL header files).

This is a little more complicated than installing Apache.

The best bet is to install from packages since this will make things easier, both now and for upgrades.

If you decide to install from source code, you'll need to create a user and compile the source.

Create a PostgreSQL user (you'll need root access). This is who owns the system. I use the "postgres" user and group, you can use something different but it's best to keep it related to the package.

See your system documentation on how to do this (hint - man useradd). Give the user a home directory of /usr/local/pgsql as this is where PostgreSQL defaults to when it installs.

Once all that is done, untar the source:

$ tar -zxf postgresql-.tar.gz (if you got the gzipp'ed version);
$ tar -xjf postgresql-.tar.bz2

Jump into the directory:

$ cd postgresql-

(replace with the version you downloaded from the website).

Again, configure has a lot of help:

$ ./configure --help

We'll just install into /usr/local/pgsql and leave the rest as-is:

$ ./configure --prefix=/usr/local/pgsql

Next we have to make it (this will take a while, it takes longer than Apache):

$ make

You will get a line:
All of PostgreSQL successfully made. Ready to install.

when everything is finished.

You'll need to log in as root to do the rest:

$ su -

Go back to the postgresql directory and do:

# make install

PostgreSQL doesn't allow root to start up the server for security reasons, so next you'll have to change the owner of the files:

# chown -R postgres:postgres /usr/local/pgsql

Change to the postgres user:

# su - postgres

Then, change to /usr/local/pgsql:

$ cd /usr/local/pgsql

We need to initialize a database cluster:

$ bin/initdb -D ./data

This will create a /usr/local/pgsql/data directory and initialize it ready for startup and use.

As usual, you can view options by using the --help switch:

$ bin/initdb --help

Then you can start:

$ bin/pg_ctl -D ./data -l data/logfile start

Now that postgresql is started, we need to create a database and another user before we go any further.

You should use a separate database for each of our projects, it's not essential though - it just makes things a little cleaner and easier to understand.

You should also use separate users for each database. This keeps everything separate and 'project a' won't be able to modify any of 'project b's data.

To create a new user in postgresql, it's pretty simple:

$ /usr/local/pgsql/bin/createuser

and follow the prompts - pretty simple :)

The new user should not be able to create new databases or create new users.

To create a database, it's a little different.

$ /usr/local/pgsql/bin/createdb --owner=username databasename

We have to set the owner of the database when we create it, otherwise the 'postgres' user owns it and then we have to grant access to allow our new user to access it.

Now that that's all done, log out of the postgres user, so we're back as root. In the postgres directory, the contrib/start-scripts/ directory has a few system start up scripts.

Follow the instructions in the relevant one to install a start-up script so postgres will start when your system does.

More detailed installation instructions are in the INSTALL file or by going to the PostgreSQL website and going to the right version for you.

Use Notepad to Create a Log File


Microsoft Notepad is a word processing tool included with Windows and is installed by default under the Accessories program group. You can use it to create a log-type file that adds the current date and time each time the Notepad file is opened. This article describes how to create a log file with Notepad.


To create a log file in Notepad:
1.Click Start, point to Programs, point to Accessories, and then click Notepad.
2.Type .LOG on the first line, and then press ENTER to move to the next line.
3.On the File menu, click Save As, type a descriptive name for your file in the File name box, and then click OK. When you next open the file, note that the date and time have been appended to the end of the log, immediately preceding the place where new text can be added. You can use this functionality to automatically add the current date and time to each log entry.

Thursday, 17 July 2008

How to Disable Security Center Alerts

If you're running Windows XP Service Pack 2 (SP2) Windows Security Center should tell you the status of your antivirus software, firewall, and automatic updates. Security Center will alert you if your antivirus is out of date or turned off, firewall is turned off, or if Automatic Update is not turned on.

If you have received multiple alerts and would like to turn notifications off, you can disable the antivirus, firewall, or automatic update alerts.

Note You should only disable these alerts if you are an expert user. If you are in the process of updating or installing software you may also want to temporarily disable alerts, but please be sure to turn alerts back on so Windows can keep your status up to date.

To turn off Security Center alerts


Click Start and then click Control Panel.


Double-click Security Center.


In the Security Center, under Resources, click Change the way Security Center alerts me.


In the Alert Settings dialog box, clear the Firewall, Automatic Updates, or Virus Protection check boxes, and then click OK.

When you use this procedure, the Security Center still displays your status, but does not send you alerts.

Note If your computer is part of a domain (a group of computers on a network), your security settings are typically managed by your network administrator. In this case, the Security Center does not display your security status or send alerts.

Monday, 7 July 2008

Mount partition with ntfs file system


Purpose of this article is to provide to reader step by step guide, how to mount partition with NTFS file system on Linux operating system. This article consist of two parts:

  • mount NTFS file system read only access
  • mount NTFS file system with read write access

Mount NTFS file system with read only access

NTFS kernel support

Majority of current Linux distributions support NTFS file system out of the box. To be more specific, support for NTFS file system is more feature of Linux kernel modules rather then Linux distributions. Lets check if we have NTFS modules installed.

ls /lib/modules/2.6.18-5-686/kernel/fs/ | grep ntfs

root@ensit~# ls /lib/modules/2.6.18-5-686/kernel/fs/ | grep ntfs

NTFS module is presented. Lets identify NTFS partition.

Identifying partition with NTFS file system

One simple way to identify NTFS partition is:

fdisk -l | grep NTFS

root@ensit~#fdisk -l | grep NTFS
/dev/sdb1 * 1 261 210456 7 HPFS/NTFS

There it is: /dev/sdb1

Mount NTFS partition

First create mount point:

mkdir /mnt/ntfs

Then simply use mount command to mount it:

mount -t ntfs /dev/sdb1 /mnt/ntfs

root@ensit~#mkdir /mnt/ntfs
root@ensit~#mount /dev/sdb1 /mnt/ntfs
root@ensit~#cd /mnt/ntfs

Now we can access NTFS partition and its files with read write access.

Mount NTFS file system with read write access

Mounting NTFS file system with read write access permissions is a bit more complicated. This involves installation of addition software such as fuse and ntfs-3g. In both cases you probably need to use you package management tool such as yum, apt-get, synaptic etc.. and install it from your standard distribution repository. Check for packages ntfs-3g and fuse.

We take the other path which consists of manual compilation and installation fuse and ntfs-3g from source code.

Install addition software

Fuse Install

Download source code from:


Compile and install fuse source code:

Extract source file:

tar -xzvf fuse-2.7.1.tar.gz

Compile and install

cd fuse-2.7.1
./configure --exec-prefix=/; make; make install
root@ensit~#tar -xzvf fuse-2.7.1.tar.gz
root@ensit~#cd fuse-2.7.1
root@ensit~#./configure --exec-prefix=/; make; make install

ntfs-3g install

Download source code from:


Extract source file:

tar -xzvf ntfs-3g-1.1120.tgz

Compile and install ntfs-3g source code

NOTE: Make sure that you have pkg-config package installed, otherwise you get this error message:

checking for pkg-config... no
checking for FUSE_MODULE... configure: error: FUSE >= 2.6.0 was not found. Either it's not fully 
installed (e.g. fuse, fuse-utils, libfuse, libfuse2, libfuse-dev, etc packages) or files from an old
version are still present. See FUSE at
cd ntfs-3g-1.1120
./configure; make; make install
fuse-2.7.1 fuse-2.7.1.tar.gz ntfs-3g-1.1120.tar.gz
root@ensit~#tar -xzvf ntfs-3g-1.1120.tar.gz
root@ensit~#cd ntfs-3g-1.1120
root@ensit~#./configure --exec-prefix=/; make; make install

Mount ntfs partition with read write access

mount -t ntfs-3g /dev/sdb1 /mnt/ntfs/

NOTE: ntfs-3g recommends to have at least kernel version 2.6.20 and higher.

root@ensit~# mount -t ntfs-3g /dev/sdb1 /mnt/ntfs/
WARNING: Deficient Linux kernel detected. Some driver features are
         not available (swap file on NTFS, boot from NTFS by LILO), and
         unmount is not safe unless it's made sure the ntfs-3g process
         naturally terminates after calling 'umount'. If you wish this
         message to disappear then you should upgrade to at least kernel
         version 2.6.20, or request help from your distribution to fix
         the kernel problem. The below web page has more information: