HOWTO: PostgreSQL && phpPgAdmin
First of all,
if you want to allow your users to manage their PgSQL DB in DirectAdmin, and set DB quota for them, you should consider this plugin:
DA-PgSQL - PostgreSQL plugin for DirectAdmin
========================================
Using our Auto Build Script
Our Auto Build Script allows you to install/update PostgreSQL and phpPgAdmin without any pain.
If this is your first time to use our build script, remember to run before moving to the next step:
Make sure your build script and related files are up-to-date:
To install/update PostgreSQL, run: (Redhat and Fedora ONLY)
If you are are using neither Redhat nor Fedora, you should install PostgreSQL from source.
To install/update phpPgAdmin, run:
Just make sure you have re-compile PHP with PgSQL support. Instrutions can be found in the last section of the post.
========================================
Manual Install of PostgreSQL 8.1.4
The following guides you on installing PostgreSQL 8.1.4 manually.
1.1, you can install pgsql with yum, however you may not have the latest version installed.
Alternatively
1.2 , Download the rpms from http://www.postgresql.org/ftp/binary/v8.1.4/linux/rpms/ according to your OS distro. The following are required
postgresql-libs-8.1.4-3PGDG.i686.rpm
postgresql-8.1.4-3PGDG.i686.rpm
postgresql-server-8.1.4-3PGDG.i686.rpm
postgresql-devel-8.1.4-3PGDG.i686.rpm
(choose rhel-es-4 if your are using CentOS)
Right click on the mirror link and press "T" to copy the url
2, Install the rpms
3, You have now installed PostgreSQL on your server. The installation is pretty easy. Now we should modify some settings
if you got these two lines:
change them to
and the following line to the end of the file
so the pg_hba.conf will look like
4, ok, we can start PostgreSQL Server now
5, now you need to create a "super user", like a root account for pgsql that has full privileges.
This command will initiate an user creation script.
6, Restart postgresql
========================================
Re-compiling PHP
We need to re-compile php with pgsql support.
add
after
save and exit
type
at last restart apache
now test with the following php code:
You shouldn't see any error message if everything goes well.
First of all,
if you want to allow your users to manage their PgSQL DB in DirectAdmin, and set DB quota for them, you should consider this plugin:
DA-PgSQL - PostgreSQL plugin for DirectAdmin
========================================
Using our Auto Build Script
Our Auto Build Script allows you to install/update PostgreSQL and phpPgAdmin without any pain.
If this is your first time to use our build script, remember to run before moving to the next step:
Code:
mkdir /usr/local/directadmin/customapache/daplugin.com
cd /usr/local/directadmin/customapache/daplugin.com
wget [url]http://files.daplugin.com/daplugin.build[/url]
chmod 755 daplugin.build
Make sure your build script and related files are up-to-date:
Code:
./daplugin.build update
To install/update PostgreSQL, run: (Redhat and Fedora ONLY)
Code:
./daplugin.build pgsql
To install/update phpPgAdmin, run:
Code:
./daplugin.build phppgadmin
========================================
Manual Install of PostgreSQL 8.1.4
The following guides you on installing PostgreSQL 8.1.4 manually.
1.1, you can install pgsql with yum, however you may not have the latest version installed.
Code:
yum -y install postgresql postgresql-server
Alternatively
1.2 , Download the rpms from http://www.postgresql.org/ftp/binary/v8.1.4/linux/rpms/ according to your OS distro. The following are required
postgresql-libs-8.1.4-3PGDG.i686.rpm
postgresql-8.1.4-3PGDG.i686.rpm
postgresql-server-8.1.4-3PGDG.i686.rpm
postgresql-devel-8.1.4-3PGDG.i686.rpm
(choose rhel-es-4 if your are using CentOS)
Right click on the mirror link and press "T" to copy the url
Code:
wget paste_the_url_here
wget paste_the_url_here
wget paste_the_url_here
wget paste_the_url_here
2, Install the rpms
Code:
rpm -ivh postgresql-libs-8.1.4-3PGDG.i686.rpm
rpm -ivh postgresql-8.1.4-3PGDG.i686.rpm
rpm -ivh postgresql-server-8.1.4-3PGDG.i686.rpm
rpm -ivh postgresql-devel-8.1.4-3PGDG.i686.rpm
3, You have now installed PostgreSQL on your server. The installation is pretty easy. Now we should modify some settings
Code:
nano /var/lib/pgsql/data/pg_hba.conf
Code:
host all all 127.0.0.1/32 ident sameuser
host all all ::1/128 ident sameuser
Code:
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
Code:
host all all 0.0.0.0 255.255.255.255 reject
Code:
local all all ident sameuser
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
host all all 0.0.0.0 255.255.255.255 reject
4, ok, we can start PostgreSQL Server now
Code:
service postgresql start
5, now you need to create a "super user", like a root account for pgsql that has full privileges.
Code:
su postgres
createuser -P -U postgres da_admin
Code:
Enter password for user ¡§da_admin¡¨:
Enter it again:
Shall the new user be allowed to create databases? (y/n) [b]y[/b]
Shall the new user be allowed to create more new users? (y/n) [b]y[/b]
CREATE USER
The CREATE USER statement indicates that the command was successful.
6, Restart postgresql
Code:
service postgresql restart
========================================
Re-compiling PHP
We need to re-compile php with pgsql support.
Code:
cd /usr/local/directadmin/customapache
nano configure.php
Code:
--with-pgsql=/var/lib/pgsql \
Code:
--with-mysql=/usr \
type
Code:
./build php n
Code:
service httpd restart
now test with the following php code:
Code:
<?php
$password="password";
$con=pg_connect("host=localhost dbname=template1 user=da_admin password=$password");
?>
Last edited: