How to Install PhpPgAdmin in FreeBSD

To Install PhpPgAdmin in FreeBSD

PhpPgAdmin is a web-based administration tool used for managing PostgreSQL databases. It allows the users to create databases, create tables, alter tables and query their own data. The PhpPgAdmin is suited for PostgreSQL DBAs, newbies, and hosting services. Installation of PhpPgAdmin in FreeBSD is explained in this article.


Installation of PhpPgAdmin

Run the following command to check whether the PgSQL is installed or not.

root@linuxhelp:~ # service -e
/etc/rc.d/hostid
/etc/rc.d/hostid_save
/etc/rc.d/cleanvar
/etc/rc.d/ip6addrctl
/etc/rc.d/devd
/etc/rc.d/newsyslog
/etc/rc.d/syslogd
/etc/rc.d/dmesg
/etc/rc.d/virecover
/etc/rc.d/moused
/usr/local/etc/rc.d/hald
/etc/rc.d/motd
/etc/rc.d/ntpd
/usr/local/etc/rc.d/slim
/usr/local/etc/rc.d/postgresql
/etc/rc.d/sshd
/etc/rc.d/sendmail
/etc/rc.d/cron
/etc/rc.d/mixer
/etc/rc.d/gptboot
/etc/rc.d/bgfsck

Then install the Apache with the following command.

root@linuxhelp:~ # pkg install apache24
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 3 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    apache24: 2.4.23_1
    apr: 1.5.2.1.5.4_1
    db5: 5.3.28_4

Number of packages to be installed: 3

The process will require 75 MiB more space.
17 MiB to be downloaded.

Proceed with this action? [y/N]: y
Fetching apache24-2.4.23_1.txz: 100%    5 MiB 180.1kB/s    00:27    
Fetching apr-1.5.2.1.5.4_1.txz: 100%  402 KiB 137.3kB/s    00:03    
Fetching db5-5.3.28_4.txz: 100%   12 MiB 266.0kB/s    00:48    
Checking integrity... done (0 conflicting)
[1/3] Installing db5-5.3.28_4...
[1/3] Extracting db5-5.3.28_4: 100%
[2/3] Installing apr-1.5.2.1.5.4_1...
[2/3] Extracting apr-1.5.2.1.5.4_1: 100%
[3/3] Installing apache24-2.4.23_1...
===>  Creating groups.
Using existing group ' www' .
===>  Creating users
Using existing user ' www' .
[3/3] Extracting apache24-2.4.23_1: 100%
Message from apache24-2.4.23_1:
To run apache www server from startup, add apache24_enable=" yes" 
in your /etc/rc.conf. Extra options can be found in startup script.

Your hostname must be resolvable using at least 1 mechanism in
/etc/nsswitch.conf typically DNS or /etc/hosts or apache might
have issues starting depending on the modules you are using.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

- apache24 default build changed from static MPM to modular MPM
- more modules are now enabled per default in the port
- icons and error pages moved from WWWDIR to DATADIR

   If build with modular MPM and no MPM is activated in
   httpd.conf, then mpm_prefork will be activated as default
   MPM in etc/apache24/modules.d to keep compatibility with
   existing php/perl/python modules!

Please compare the existing httpd.conf with httpd.conf.sample
and merge missing modules/instructions into httpd.conf!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Once the Apache is installed, enable the apache service on rc.conf file.

root@linuxhelp:~ # sysrc apache24_enable=" YES" 
apache24_enable:  ->  YES

Utilize the following command to start the Apache service.

root@linuxhelp:~ # service apache24 start
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.

Now its time to install the PHP and its dependency packages.

root@linuxhelp:~ # pkg install php56 mod_php56 php56-curl php56-session php56-pgsql
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 5 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    php56: 5.6.27
    mod_php56: 5.6.27
    php56-curl: 5.6.27
    php56-session: 5.6.27
    php56-pgsql: 5.6.27

Number of packages to be installed: 5

The process will require 21 MiB more space.
3 MiB to be downloaded.

Proceed with this action? [y/N]: y
Fetching php56-5.6.27.txz: 100%    2 MiB  52.1kB/s    00:39    
Fetching mod_php56-5.6.27.txz: 100%    1 MiB  61.9kB/s    00:18    
Fetching php56-curl-5.6.27.txz: 100%   27 KiB  27.2kB/s    00:01    
Fetching php56-session-5.6.27.txz: 100%   30 KiB  31.1kB/s    00:01    
Fetching php56-pgsql-5.6.27.txz: 100%   43 KiB  43.6kB/s    00:01    
Checking integrity... done (0 conflicting)
[1/5] Installing php56-5.6.27...
[1/5] Extracting php56-5.6.27: 100%
[2/5] Installing mod_php56-5.6.27...
[2/5] Extracting mod_php56-5.6.27: 100%
[activating module `php5'  in /usr/local/etc/apache24/httpd.conf]
[3/5] Installing php56-curl-5.6.27...
[3/5] Extracting php56-curl-5.6.27: 100%
[4/5] Installing php56-session-5.6.27...
[4/5] Extracting php56-session-5.6.27: 100%
[5/5] Installing php56-pgsql-5.6.27...
[5/5] Extracting php56-pgsql-5.6.27: 100%
Message from mod_php56-5.6.27:
***************************************************************

Make sure index.php is part of your DirectoryIndex.

You should add the following to your Apache configuration file:

< FilesMatch " .php$" > 
    SetHandler application/x-httpd-php

< FilesMatch " .phps$" > 
    SetHandler application/x-httpd-php-source

***************************************************************
Message from php56-curl-5.6.27:
****************************************************************************

The following line has been added to your /usr/local/etc/php/ext-20-curl.ini
configuration file to automatically load the installed extension:

extension=curl.so

****************************************************************************
Message from php56-session-5.6.27:
****************************************************************************

The following line has been added to your /usr/local/etc/php/ext-18-session.ini
configuration file to automatically load the installed extension:

extension=session.so

****************************************************************************
Message from php56-pgsql-5.6.27:
****************************************************************************

The following line has been added to your /usr/local/etc/php/ext-20-pgsql.ini
configuration file to automatically load the installed extension:

extension=pgsql.so

****************************************************************************

Next run the ' nano' command to configure the httpd.conf file.

Enter the following lines from the above displayed output and add the index.php into it.

root@linuxhelp:~ # nano -c /usr/local/etc/apache24/httpd.conf
.
.
.

    DirectoryIndex index.php index.html

.
.
.
< FilesMatch " .php$" > 
    SetHandler application/x-httpd-php

< FilesMatch " .phps$" > 
    SetHandler application/x-httpd-php-source

.
.
.
Done!

Here you need to copy the php.ini-production file into the php.ini file.

root@linuxhelp:~ # cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

Now restart the apache service as shown below,

root@linuxhelp:~ # service apache24 restart
Performing sanity check on apache24 configuration:
Syntax OK
Stopping apache24.
Waiting for PIDS: 3512.
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.

Again move to apache data directory by using the following command.

root@linuxhelp:~ # cd /usr/local/www/apache24/data/

Utilize the below command to create info.php file.

root@linuxhelp:/usr/local/www/apache24/data # echo " "  >  info.php

Now install phppgadmin by using the pkg install command.

root@linuxhelp:~ # pkg install phppgadmin
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    phppgadmin: 5.1_3

Number of packages to be installed: 1

The process will require 3 MiB more space.
546 KiB to be downloaded.

Proceed with this action? [y/N]: y
Fetching phppgadmin-5.1_3.txz: 100%  546 KiB 139.9kB/s    00:04    
Checking integrity... done (0 conflicting)
[1/1] Installing phppgadmin-5.1_3...
[1/1] Extracting phppgadmin-5.1_3: 100%

Here you need to create soft link as shown below,

root@linuxhelp:~ # ln -s /usr/local/www/phpPgAdmin/ /usr/local/www/apache24/data/

Again restart the Apache service.

root@linuxhelp:~ # service apache24 restart
Performing sanity check on apache24 configuration:
Syntax OK
Stopping apache24.
Waiting for PIDS: 3547.
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.

Enter the localhost IP with /phpPgAdmin in the web browser.

Select the language and theme as required,

Click on PostgreSQL server icon.

Enter the following credentials and click on login option.

Now you can access phpPgAdmin through the dashboard.

FAQ
Q
Why for some users I get a “Login disallowed for security” message?
A
Logins via phpPgAdmin with no password or certain usernames are denied by default. Before changing this behaviour (setting $conf['extra_login_security'] to false in the config.inc.php file) please read the PostgreSQL documentation about client authentication and understand how to change PostgreSQL's pg_hba.conf to enable passworded local connections.
Q
Why phpPgAdmin ask me to re-enter login information for every page I access?
A
You most certainly have a problem with your PHP sessions. Make sure:

your browser accept cookies if your session ID relies on them

PHP has write access to the path set in the parameter “session.save_path” of your php.ini
Q
What is the purpose of using the Phppgadmin?
A
PhpPgAdmin is a web-based administration tool used for managing PostgreSQL databases. It allows the users to create databases, create tables, alter tables and query their own data.
Q
What happened to the database dump feature in phpPgAdmin?
A
You need to configure phpPgAdmin (in the config.inc.php file) to point to the location of the pg_dump and pg_dumpall utilities on your server. Once you have done that, the database export feature will appear.
Q
When I access my phpPgAdmin installation, I only have an empty page?
A
you have a PHP error and your PHP parameter ”display_errors” is set to “off”.

Depending on your ”log_errors” and ”error_reporting PHP parameters, you should be able to find the PHP errors in your httpd errors log files.