How to install, configure Apache, Php, Postgresql on Linux.
Summary - Installing configuring Apache, Php and Postgres.
Published - Apr 02/2006
Last Updated - Aug 02/2009
Author - Sumedh
Note - This tutorial assumes that you know how to compile and install a program from its source.
Download and install Postgres.
1) Switch to the root user.
2) Download Postgresql source from http://www.postgresql.org/download
3) Extract Postgresql to any folder of your choice.
./configure
make
make install
make
make install
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test
5) Download Apache source from https://httpd.apache.org
6) Extract Apache to any folder of your choice.
7) Configure and install Apache.
./configure --prefix=/usr/local/apache --enable-so --enable-rewrite
make
make install
make
make install
8) Download Php source from https://www.php.net/downloads.php
9) Extract Php to any folder of your choice.
10) Configure and install Php.
./configure --with-apxs2=/usr/local/apache/bin/apxs --with-pgsql
make
make install
make install
11) Copy php.ini or php.ini-dist from the folder where you extracted php to /usr/local/lib
12) Go to /usr/local/lib folder and open the php.ini-dist file in any simple text editor like emacs.
13) Find 'extension=php_pgsql.dll' in the file and remove the ' ; ' before that line.
Configure Apache.
14) Open the httpd.conf file in /usr/local/apache/conf folder in any simple text editor.
15) Make sure the following line is there in the LoadModule list, if it is not there add it.
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .php3 .phtml
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php-source .phps
User postgres
Group daemon
Group daemon
18) Start Apache, you will need sudo access.
/usr/local/apache/bin/apachectl start
20) Create a new php file called index.php
21) Copy paste the following lines in that file.
<?php
phpinfo();
?>
phpinfo();
?>
Dont tell me that you dont use firefox :)
If you see a page similar to the one given below then you have installed php correctly.
Scroll down till you see pgsql. Congrats you have configured php with postgres.
Click on the thumbnail to get a bigger image
Note - If you cannot see the php information page, try restarting apache.
Copyright © 2002 - 07 Sumedh K