PhpPgAdmin is a powerful web interface to manage PostgreSQL, which can be compared with the MySQL web-based administration tool: PhpMyAdmin.
Installing phpPgAdmin with apt:
$ sudo apt-get install phppgadmin
If you haven't had PHP and Apache web server installed on your Ubuntu server, above command will automatically install PHP and Apache for you.
2 Configure Apache
After installation, there's already an Apache vhost configuration file for phpPgAdmin which is located in
/etc/apache2/conf.d/phppgadmin. We will edit this file and change some configurations.
$ sudo vim /etc/apache2/conf.d/phppgadmin
In order to access from web, we'd better comment following two lines in
# deny from all # allow from 127.0.0.0/255.0.0.0 ::1/128
And uncomment or add the allow directive:
allow from all
The next step is to enable this vhost configuration. There are two optional ways.
The first method is to let apache include phpPgAdmin vhost in its configuration file.
$ sudo vim /etc/apache2/apache2.conf
Add the following line to
The second method is to create a symbol link:
$ sudo ln -s /etc/apache2/conf.d/phppgadmin /etc/apache2/sites-enabled/phppgadmin
Whatever method you choose, you should restart Apache service to reload the changes.
$ sudo service apache2 restart
3 Configure phpPgAdmin
The configuration file for phpPgAdmin is
/etc/phppgadmin/config.inc.php. Open this file in terminal:
$ sudo vim /etc/phppgadmin/config.inc.php
Because our PostgreSQL is installed on the same server, so change the
$conf['servers']['host'] = 'localhost';
then find the extra login security setting line:
$conf['extra_login_security'] = true;
Change it to
$conf['extra_login_security'] = false;
If you keep it to be
true, you can't login phpPgAdmin in the web interface even your account and password is correct. phpPgAdmin will disallow you sign in with an error message: "Login disallowed for security reasons". This is a common issue when installing phpPgAdmin.
If you want phpPgAdmin to automatically hide databases that don't belong to the current user signed in, you have to change the
owned_only setting. Find the line:
$conf['owned_only'] = false;
And change it to
$conf['owned_only'] = true;
4 Common Issues
4.1 "Login disallowed for security reasons"
As mentioned above, this error is caused by setting
/etc/phppgadmin/config.inc.php. Setting it to
false can solve the error.
4.2 Don't know the default password
The default user is
postgres after installing PostgreSQL. You can set or update its password of accessing database via command line.
Connect PostgreSQL shell:
$ sudo -u postgres psql
then you will enter the
psql shell prompt:
Set password by the command
postgres=# \password postgres
Alternatively, you can also set the password by SQL:
postgres=# ALTER USER postgres WITH PASSWORD 'your new password here'
After any changes of configuration, you'd better restart the PostgreSQL service:
$ sudo service postgresql restart