顯示具有 Ubuntu 標籤的文章。 顯示所有文章
顯示具有 Ubuntu 標籤的文章。 顯示所有文章

2011年8月24日 星期三

Installing PostgreSQL 9.0 on Ubuntu (11.04) using PPA


The version of default PostgreSQL in the latest Ubuntu (11.04) is still 8.4.8.
So I decided to install 9.0 version when I found there is a PPA (Personal Package Archives) for it. (I have no previous version of PostgreSQL in this Ubuntu PC.)

1. Resources.
PostgreSQL PPA: https://launchpad.net/~pitti/+archive/postgresql

2. Add PPA repository to my Ubuntu.

$ sudo add-apt-repository ppa:pitti/postgresql


3. Install PostgreSQL 9.0

$ sudo apt-get update
$ sudo apt-get install postgresql


4. Check the installation [updated 2011-07-24]

$ locate postgresql # check the locations of postgresql files
...
/etc/init.d/postgresql # server daemon
/etc/logrotate.d/postgresql-common
/etc/postgresql/9.0
/etc/postgresql/9.0/main # directory for config files
/etc/postgresql/9.0/main/environment
/etc/postgresql/9.0/main/pg_ctl.conf
/etc/postgresql/9.0/main/pg_hba.conf
/etc/postgresql/9.0/main/pg_ident.conf
/etc/postgresql/9.0/main/postgresql.conf
/etc/postgresql/9.0/main/start.conf
...
/usr/lib/postgresql # server apps
/usr/lib/postgresql/9.0
/usr/lib/postgresql/9.0/bin
/usr/lib/postgresql/9.0/lib
...
/var/lib/postgresql # home directory for root user postgres
/var/lib/postgresql/9.0
/var/lib/postgresql/9.0/main # I will create error log directory (pg_log) here
/var/lib/update-rc.d/postgresql
/var/log/postgresql
/var/log/postgresql/postgresql-9.0-main.log
/var/log/postgresql/postgresql-9.0-main.log.1
...

$ psql -V # check psql version
psql (PostgreSQL) 9.0.4

$ finger postgres # check if user postgres is created
Login: postgres Name: PostgreSQL administrator
Directory: /var/lib/postgresql Shell: /bin/bash
Never logged in.
No mail.
No Plan.

$ su postgres # switch user to postgres
$ psql # launch psql as postgres and check the server version
psql (9.0.4)

postgres=# select version();
-----------------------------------------------------------------------------------------------------
PostgreSQL 9.0.4 on i686-pc-linux-gnu, compiled by GCC gcc-4.5.real (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2, 32-bit


5. Setup Root User 'posrgres'
The installer has created a unix user postgres without a password. So first I give a (unix) password to this special user. The user postgress is a root user (database administrator) of PostgreSQL Server but without a (PostgreSQL) password. So I give it one here as well.

$ sudo passwd postgres # give the postgres user a (unix) password
$ su postgres # switch to the user postgres
$ psql # launch psql to give postgres PostgreSQL passord
postgres=# alter user postgres with password 'secret'; # new password for postgres
ALTER ROLE
postgres=# \q # quit psql
$ exit # exit from user 'postgres'
exit


6.Configure PostgreSQL Server
I want to make some changes to server config.

Make backup copies of config files.

$ su postgres # switch to the user postgres
$ cd /etc/postgresql/9.0/main
$ ls -la
...
-rw-r----- 1 postgres postgres 4108 2011-07-02 19:54 pg_hba.conf
-rw-r--r-- 1 postgres postgres 18064 2011-07-02 19:54 postgresql.conf
...

postgres@ubuntu-pc:/etc/postgresql/9.0/main$ cp pg_hba.conf pg_hba.conf.bak.original
postgres@ubuntu-pc:/etc/postgresql/9.0/main$ cp postgresql.conf postgresql.conf.bak.original

postgres@ubuntu-pc:/etc/postgresql/9.0/main$ ls -la
...
-rw-r----- 1 postgres postgres 4108 2011-07-02 19:54 pg_hba.conf
-r-r----- 1 postgres postgres 4108 2011-07-03 18:33 pg_hba.conf.bak.original
-rw-r--r-- 1 postgres postgres 18064 2011-07-02 19:54 postgresql.conf
-rw-r--r-- 1 postgres postgres 18064 2011-07-03 18:33 postgresql.conf.bak.original
...


Make changes to pg_hba.config (authetification methods).
host all all 127.0.0.1/32 trust # md5 -> trust

Make changes to postgresql.conf for error log.

#------------------------------------------------------------------------------
# ERROR REPORTING AND LOGGING
#------------------------------------------------------------------------------
log_destination = 'stderr' # 2011.07.04 - enabled
logging_collector = on # 2011.07.04 - enabled and turned on
log_directory = 'pg_log' # 2011.07.04 - enabled. I will create this folder (see below).
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # 2011.07.04 - enabled
log_truncate_on_rotation = off # 2011.07.04 - enabled and keep it off
log_rotation_age = 1d # 2011.07.04 - enabled
log_rotation_size = 10MB # 2011.07.04 - enabled


Create a log directory as specified in the config above.[updated on 2011-07-24]

$ su postgres # switch to postgres user
$ cd ~/9.0/main/ # /var/postgresql/9.0/main
$ mkdir pg_log # create a new log directory as specified in the config file above
$ ls -F # confirm the new directory 'pg_log'
PG_VERSION pg_log/ ...
$ exit


7. Restart the server [new]
I have to restart the server to use new configurations.

$ sudo /etc/init.d/postgresql restart
* Restarting PostgreSQL 9.0 database server
$ sudo /etc/init.d/postgresql status
Running clusters: 9.0/main


8. Check the new log. [new]
Now I should have a new log generated.

$ sudo ls /var/lib/postgresql/9.0/main/pg_log
postgresql-2011-07-23_135126.log


9. Finally Install pgAdmin III (GUI tool for PostgreSQL) [new]
Since the same PPA repository (ppa:pitti/postgresql) also contains the latest pgAdmin III, I can install it with a simple apt-get command.

$ sudo apt-get install pgadmin3 # install the latest pgAdminIII
$ pgadmin3 # launch it


It is version 1.12.2.


Reference To:http://socrateos.blogspot.com/2011/07/installing-postgresql-90-on-ubuntu-1104.html

Install GUI in Ubuntu Server

If you are a new user and not familiar with command prompt you can install GUI for your ubuntu LAMP server using the 2 options

1) Install desktop Environment
2) Install Webmin

1) Install desktop Environment
First you nee to make sure you have enabled Universe and multiverse repositories in /etc/apt/sources.list file once you have enable you need to use the following command to install GUI
sudo apt-get update
sudo apt-get install ubuntu-desktop
The above command will install GNOME desktop
If you wan to install a graphical desktop manager without some of the desktop addons like Evolution and OpenOffice, but continue to use the server flavor kernel use the following command
sudo aptitude install --without-recommends ubuntu-desktop
If you want to install light weight desktop install xfce using the following command
sudo apt-get install xubuntu-desktop
If you want to install KDE desktop use the following command
sudo apt-get install kubuntu-desktop
2) Install Webmin in Ubuntu
Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely.Currently There is no Webmin package in the Ubuntu repositories.This tutorial will explain how to Install Webmin in Ubuntu Jaunty
You can install webmin for your server web interface to configure apache2,mysql,FTp servers and many more.Now we will see how to install webmin in Ubuntu 9.04
Preparing your system
First you need to install the following packages
sudo aptitude install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl
Now download the latest webmin using the following command or from here
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.470_all.deb
Now we have webmin_1.470_all.deb package install this package using the following command
sudo dpkg -i webmin_1.470_all.deb
This will complete the installation.
Using the Webmin APT repository
If you like to install and update Webmin via APT, edit the /etc/apt/sources.list file on your system
sudo vi /etc/apt/sources.list
add the line
deb http://download.webmin.com/download/repository sarge contrib
Save and exit the file
You should also fetch and install my GPG key with which the repository is signed, with the commands : cd /root
wget http://www.webmin.com/jcameron-key.asc
sudo apt-key add jcameron-key.asc
You will now be able to install with the commands
sudo apt-get update
sudo apt-get install webmin
All dependencies should be resolved automatically.
Ubuntu in particular don’t allow logins by the root user by default. However, the user created at system installation time can use sudo to switch to root. Webmin will allow any user who has this sudo capability to login with full root privileges.
Now you need to open your web browser and enter the following
https://your-server-ip:10000/
Now you should see similar to the following Screen
After login if you want to configure Apache,Mysql server you need to click on Servers on your lefthand side you should many servers are ready to configure
This is very Easy to configure most of the servers and Enjoy your new Ubuntu Jaunty LAMP Server.
Reference To:http://www.ubuntugeek.com/install-gui-in-ubuntu-server.html