Difference between revisions of "PhpPgAdmin"

From ArchWiki
Jump to: navigation, search
(Nginx: replace unreadable bloat with simple solution (trivial adaptation of PhpMyAdmin#Nginx))
 
(36 intermediate revisions by 12 users not shown)
Line 1: Line 1:
[[Category:Web Server]]
+
{{lowercase title}}
==Installation==
+
[[Category:Web admin interfaces]]
To install [http://phppgadmin.sourceforge.net/doku.php?id=start phpPgAdmin], install the {{Pkg|phppgadmin}} packages in [[Official Repositories]].
+
[[ja:PhpPgAdmin]]
 +
{{Related articles start}}
 +
{{Related|PostgreSQL}}
 +
{{Related articles end}}
 +
[http://phppgadmin.sourceforge.net/ phpPgAdmin] is a web-based tool to help manage PostgreSQL databases using an PHP frontend.
  
==Configuration==
+
== Installation ==
Ensure you do not have an older copy of phppgadmin.
 
rm -r /srv/http/phppgAdmin
 
  
Copy the example configuration file to your httpd configuration directory.
+
PhpPgAdmin requires a web server with PHP, such as Apache. To set it up, see [[Apache HTTP Server]] and [[Apache HTTP Server#PHP]].
cp /etc/webapps/phppgadmin/apache.example.conf /etc/httpd/conf/extra/httpd-phppgadmin.conf
 
  
Add the following lines to {{ic|/etc/httpd/conf/httpd.conf}}:
+
Install the {{Pkg|phppgadmin}} package.
# phpPgAdmin configuration
 
Include conf/extra/httpd-phppgadmin.conf
 
 
 
Add the following lines to {{ic|/etc/httpd/conf/httpd.conf}}:
 
# Use for PHP 5.x:
 
LoadModule php5_module        modules/libphp5.so
 
AddHandler php5-script php
 
  
Add index.php after "DirectoryIndex index.html"
+
== Configuration ==
{{bc|1=
 
# DirectoryIndex: sets the file that Apache will serve if a directory
 
# is requested.
 
#
 
<IfModule dir_module>
 
    DirectoryIndex index.html index.php
 
</IfModule>
 
}}
 
  
In {{ic|/usr/share/webapps/phppgadmin/.htaccess}}, comment out ''deny from all''. The line should look like this:
+
===PHP===
  #deny from all
+
You need to enable the {{ic|pgsql}} extension in PHP by editing {{ic|/etc/php/php.ini}} and uncommenting the following line:
 +
  extension=pgsql.so
  
Otherwise you'll get an error similar to "Error 403 - Access forbidden!" when you attempt to access your phppgadmin installation.
+
You need to make sure that PHP can access {{ic|/etc/webapps}}. Add it to {{ic|open_basedir}} in {{ic|/etc/php/php.ini}} if necessary:
 +
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps
  
Your {{ic|/etc/httpd/conf/extra/httpd-phppgadmin.conf}} should have the following information:
+
===Web server===
{{bc|1=
+
====Apache====
        Alias /phppgadmin "/usr/share/webapps/phppgadmin"
+
Create the Apache configuration file:
        <Directory "/usr/share/webapps/phppgadmin">
+
{{hc|/etc/httpd/conf/extra/phppgadmin.conf|
                AllowOverride All
+
Alias /phppgadmin "/usr/share/webapps/phppgadmin"
                Options FollowSymlinks
+
<Directory "/usr/share/webapps/phppgadmin">
                Order allow,deny
+
    DirectoryIndex index.php
                Allow from all
+
    AllowOverride All
        </Directory>
+
    Options FollowSymlinks
 +
    Require all granted
 +
</Directory>
 
}}
 
}}
  
Open your {{ic|/etc/php/php.ini}} and go to the line containing ''open_basedir'' and add the path(s) to your phppgAdmin installation so it has the following:
+
And include it in {{ic|/etc/httpd/conf/httpd.conf}}:
:/usr/share/webapps/phppgadmin:/etc/webapps/
+
  # phpPgAdmin configuration
 
+
  Include conf/extra/phppgadmin.conf
For example, mine contains the following:
 
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/phppgadmin:/etc/webapps
 
 
 
You need the pgsql module, so uncomment in {{ic|/etc/php/php.ini}}:
 
  ;extension=pgsql.so
 
:to
 
  extension=pgsql.so
 
 
 
==Accessing your phpPgAdmin installation==
 
 
 
Finally your phppgadmin installation is complete. Before start using it you need to restart your apache server by following command:
 
 
 
  # systemctl restart httpd.service
 
 
 
You can access your phppgadmin installation using the following url:
 
http://localhost/phppgadmin/
 
or
 
  http://localhost/phppgadmin/index.php
 
 
 
Note: 'localhost' is your hostname.
 
 
 
If you want to access it using:
 
 
 
http://localhost/phppgadmin
 
 
 
in '/etc/httpd/conf/extra/httpd-phppgadmin.conf' change:
 
  
Alias /phppgadmin/ "/usr/share/webapps/phppgadmin/"
+
By default, everyone can see the phpPgAdmin page, to change this, edit {{ic|/etc/httpd/conf/extra/phppgadmin.conf}} to your liking. For example, if you only want to be able to access it from the same machine, replace {{ic|Require all granted}} by {{ic|Require local}}.
to
 
Alias /phppgadmin "/usr/share/webapps/phppgadmin"
 
  
==Lighttpd Configuration==
+
====Lighttpd====
  
 
The php setup for lighttpd is exactly the same as for apache.
 
The php setup for lighttpd is exactly the same as for apache.
Line 85: Line 47:
 
   alias.url = ( "/phppgadmin" => "/usr/share/webapps/phppgadmin/")
 
   alias.url = ( "/phppgadmin" => "/usr/share/webapps/phppgadmin/")
 
Then enable mod_alias, mod_fastcgi and mod_cgi in your config ( server.modules section )
 
Then enable mod_alias, mod_fastcgi and mod_cgi in your config ( server.modules section )
 
Update open_basedir in /etc/php/php.ini and add "/usr/share/webapps/".
 
  open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/
 
  
 
Make sure lighttpd is setup to serve php files, [[Lighttpd#FastCGI]]
 
Make sure lighttpd is setup to serve php files, [[Lighttpd#FastCGI]]
Line 93: Line 52:
 
Restart lighttpd and browse to http://localhost/phppgadmin/index.php
 
Restart lighttpd and browse to http://localhost/phppgadmin/index.php
  
==NGINX Configuration==
+
====Nginx====
  
Also similar to apache configuration (and Lighttpd, for that matter).
+
Make sure to set up [[nginx#FastCGI]] with separate configuration file for PHP as shown in [[nginx#PHP configuration file]].
  
Create a symbolic link to the /usr/share/webapps/phppgadmin directory from whichever directory your vhost is serving files from, e.g. /srv/http/<domain>/public_html/
+
Using this method, you will access PhpPgAdmin as {{ic|phpmyadmin.<domain>}}.
  
  sudo ln -s /usr/share/webapps/phppgadmin /srv/http/<domain>/public_html/phppgadmin
+
You can setup a sub domain (or domain) with a server block such as:
  
You can also setup a sub domain with a server block like so (if using php-fpm):
+
{{bc|<nowiki>
 +
server {
 +
    server_name    phppgadmin.<domain.tld>;
 +
    root    /usr/share/webapps/phppgadmin;
 +
    index  index.php;
 +
    include php.conf;
 +
}
 +
</nowiki>}}
  
  server {
+
===phpPgAdmin configuration===
          server_name    phppgadmin.<domain.tld>;
+
phpPgAdmin's configuration file is located at {{ic|/etc/webapps/phppgadmin/config.inc.php}}. If you have a local PostgreSQL server, it should be usable without making any modifications.
          access_log      /srv/http/<domain>/logs/phppgadmin.access.log;
 
          error_log      /srv/http/<domain.tld>/logs/phppgadmin.error.log;
 
 
 
          location / {
 
                  root    /srv/http/<domain.tld>/public_html/phppgadmin;
 
                  index  index.html index.htm index.php;
 
          }
 
 
 
          location ~ \.php$ {
 
                  root            /srv/http/<domain.tld>/public_html/phppgadmin;
 
                  fastcgi_pass    unix:/var/run/php-fpm/php-fpm.sock;
 
                  fastcgi_index  index.php;
 
                  fastcgi_param  SCRIPT_FILENAME  /srv/http/<domain.tld>/public_html/phppgadmin/$fastcgi_script_name;
 
                  include        fastcgi_params;
 
          }
 
  }
 
  
== Troubleshooting Login disallowed for security reasons ==
+
If your PostgreSQL server is not on the localhost, edit the following line:
If extra login security is true, then logins via phpPgAdmin with no password or certain usernames (pgsql, postgres, root, administrator) will be denied. Only set this false once you have read the FAQ and understand how to change PostgreSQL's pg_hba.conf to enable  passworded local connections.
+
$conf['servers'][0]['host'] = '';
  
  # nano /usr/share/webapps/phppgadmin/conf/config.inc.php
+
==Accessing your phpPgAdmin installation==
 +
Your phpPgAdmin installation is now complete. Before start using it you need to restart your apache server by following command:
 +
# systemctl restart httpd.service
  
change the following line
+
You can access your phpPgAdmin installation by going to http://localhost/phppgadmin/
  
  $conf['extra_login_security'] = true;
+
== Troubleshooting ==
  
to
+
=== Login disallowed for security reasons ===
  
  $conf['extra_login_security'] = false;
+
If extra login security is true, then logins via phpPgAdmin with no password or certain usernames (''pgsql'', ''postgres'', ''root'', ''administrator'') will be denied. Only set this to {{ic|false}} once you have read the FAQ and understand how to change PostgreSQL's {{ic|pg_hba.conf}} to enable passworded local connections.
 
 
== Troubleshooting Access Denied (403) ==
 
 
 
You will need to edit the {{ic|.htaccess}} file located at
 
 
 
  /etc/webapps/phppgsql/.htaccess
 
  
 +
Edit {{ic|/etc/webapps/phppgadmin/config.inc.php}} and change the following line
 +
  $conf['extra_login_security'] = true;
 
to
 
to
 
+
  $conf['extra_login_security'] = false;
  Allow from <ip>
 
 
 
where <ip> is your current ip (or use 127.0.0.1 if you are on the same box) and then
 
 
 
# systemctl restart httpd
 
 
 
in order to access phppgadmin.
 

Latest revision as of 22:24, 10 August 2017

Related articles

phpPgAdmin is a web-based tool to help manage PostgreSQL databases using an PHP frontend.

Installation

PhpPgAdmin requires a web server with PHP, such as Apache. To set it up, see Apache HTTP Server and Apache HTTP Server#PHP.

Install the phppgadmin package.

Configuration

PHP

You need to enable the pgsql extension in PHP by editing /etc/php/php.ini and uncommenting the following line:

extension=pgsql.so

You need to make sure that PHP can access /etc/webapps. Add it to open_basedir in /etc/php/php.ini if necessary:

open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps

Web server

Apache

Create the Apache configuration file:

/etc/httpd/conf/extra/phppgadmin.conf
Alias /phppgadmin "/usr/share/webapps/phppgadmin"
<Directory "/usr/share/webapps/phppgadmin">
    DirectoryIndex index.php
    AllowOverride All
    Options FollowSymlinks
    Require all granted
</Directory>

And include it in /etc/httpd/conf/httpd.conf:

# phpPgAdmin configuration
Include conf/extra/phppgadmin.conf

By default, everyone can see the phpPgAdmin page, to change this, edit /etc/httpd/conf/extra/phppgadmin.conf to your liking. For example, if you only want to be able to access it from the same machine, replace Require all granted by Require local.

Lighttpd

The php setup for lighttpd is exactly the same as for apache. Make an alias for phppgadmin in your lighttpd config.

 alias.url = ( "/phppgadmin" => "/usr/share/webapps/phppgadmin/")

Then enable mod_alias, mod_fastcgi and mod_cgi in your config ( server.modules section )

Make sure lighttpd is setup to serve php files, Lighttpd#FastCGI

Restart lighttpd and browse to http://localhost/phppgadmin/index.php

Nginx

Make sure to set up nginx#FastCGI with separate configuration file for PHP as shown in nginx#PHP configuration file.

Using this method, you will access PhpPgAdmin as phpmyadmin.<domain>.

You can setup a sub domain (or domain) with a server block such as:

server {
    server_name     phppgadmin.<domain.tld>;
    root    /usr/share/webapps/phppgadmin;
    index   index.php;
    include php.conf;
}

phpPgAdmin configuration

phpPgAdmin's configuration file is located at /etc/webapps/phppgadmin/config.inc.php. If you have a local PostgreSQL server, it should be usable without making any modifications.

If your PostgreSQL server is not on the localhost, edit the following line:

$conf['servers'][0]['host'] = ;

Accessing your phpPgAdmin installation

Your phpPgAdmin installation is now complete. Before start using it you need to restart your apache server by following command:

# systemctl restart httpd.service

You can access your phpPgAdmin installation by going to http://localhost/phppgadmin/

Troubleshooting

Login disallowed for security reasons

If extra login security is true, then logins via phpPgAdmin with no password or certain usernames (pgsql, postgres, root, administrator) will be denied. Only set this to false once you have read the FAQ and understand how to change PostgreSQL's pg_hba.conf to enable passworded local connections.

Edit /etc/webapps/phppgadmin/config.inc.php and change the following line

 $conf['extra_login_security'] = true;

to

 $conf['extra_login_security'] = false;