Difference between revisions of "PhpPgAdmin"

From ArchWiki
Jump to: navigation, search
(/usr/share/webapps/phppgadmin is the right path to include in php.ini in order to phppgadmin load properly)
m (Web servers)
 
(36 intermediate revisions by 13 users not shown)
Line 1: Line 1:
[[Category:Web Server]]
+
{{lowercase title}}
==Installation==
+
[[Category:Web server]]
To install [http://phppgadmin.sourceforge.net/doku.php?id=start phpPgAdmin], install the {{Pkg|phppgadmin}} packages with
+
[[ja:PhpPgAdmin]]
<pre>
+
{{Related articles start}}
pacman -S phppgadmin
+
{{Related|PostgreSQL}}
</pre>
+
{{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.
+
<pre>
+
rm -r /srv/http/phppgAdmin
+
</pre>
+
  
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]].
<pre>
+
cp /etc/webapps/phppgadmin/apache.example.conf /etc/httpd/conf/extra/httpd-phppgadmin.conf
+
</pre>
+
  
Add the following lines to {{ic|/etc/httpd/conf/httpd.conf}}:
+
Install the {{Pkg|phppgadmin}} package.
<pre>
+
# phpPgAdmin configuration
+
Include conf/extra/httpd-phppgadmin.conf
+
</pre>
+
  
You can type this into the terminal to produce the same effect:
+
== Configuration ==
<pre>
+
echo -e "\nInclude conf/extra/httpd-phppgadmin.conf" >> /etc/httpd/conf/httpd.conf
+
</pre>
+
  
Add the following lines to {{ic|/etc/httpd/conf/httpd.conf}}:
+
===PHP===
<pre>
+
You need to enable the {{ic|pgsql}} extension in PHP by editing {{ic|/etc/php/php.ini}} and uncommenting the following line:
# Use for PHP 5.x:
+
extension=pgsql.so
LoadModule php5_module        modules/libphp5.so
+
AddHandler php5-script php
+
</pre>
+
  
Add index.php after "DirectoryIndex index.html"
+
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:
<pre>
+
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps
# DirectoryIndex: sets the file that Apache will serve if a directory
+
# is requested.
+
#
+
<IfModule dir_module>
+
    DirectoryIndex index.html index.php
+
</IfModule>
+
</pre>
+
  
In {{ic|/usr/share/webapps/phppgadmin/.htaccess}}, comment out ''deny from all''. The line should look like this:
+
===Web server===
<pre>
+
====Apache====
#deny from all
+
Create the Apache configuration file:
</pre>
+
{{hc|/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>
 +
}}
  
Otherwise you'll get an error similar to "Error 403 - Access forbidden!" when you attempt to access your phppgadmin installation.
+
And include it in {{ic|/etc/httpd/conf/httpd.conf}}:
 +
# phpPgAdmin configuration
 +
Include conf/extra/phppgadmin.conf
  
Your {{ic|/etc/httpd/conf/extra/httpd-phppgadmin.conf}} should have the following information:
+
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}}.
<pre>
+
        Alias /phppgadmin "/usr/share/webapps/phppgadmin"
+
        <Directory "/usr/share/webapps/phppgadmin">
+
                AllowOverride All
+
                Options FollowSymlinks
+
                Order allow,deny
+
                Allow from all
+
        </Directory>
+
</pre>
+
 
+
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:
+
<pre>
+
:/usr/share/webapps/phpgadmin:/etc/webapps/
+
</pre>
+
 
+
For example, mine contains the following:
+
<pre>
+
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/phppgadmin:/etc/webapps
+
</pre>
+
 
+
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:
+
 
+
<pre>
+
# /etc/rc.d/httpd restart
+
</pre>
+
 
+
You can access your phppgadmin installation using the following url:
+
 
+
<pre>
+
http://localhost/phppgadmin/
+
or
+
http://localhost/phppgadmin/index.php
+
</pre>
+
 
+
Note: 'localhost' is the hostname in your /etc/rc.conf file.
+
 
+
If you want to access it using:
+
 
+
<pre>
+
http://localhost/phppgadmin
+
</pre>
+
 
+
in '/etc/httpd/conf/extra/httpd-phppgadmin.conf' change:
+
 
+
<pre>
+
Alias /phppgadmin/ "/usr/share/webapps/phppgadmin/"
+
</pre>
+
 
+
to
+
 
+
<pre>
+
Alias /phppgadmin "/usr/share/webapps/phppgadmin"
+
</pre>
+
  
==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 120: 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 128: 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).
+
{{Poor writing|Grammar, punctuation, style issues, see also [[Help:Style]] and related.}}
  
 
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/
 
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/
Line 137: Line 61:
  
 
You can also setup a sub domain with a server block like so (if using php-fpm):
 
You can also setup a sub domain with a server block like so (if using php-fpm):
 +
 +
Also, you need to use at less php-fpm (you need it), you have to make it running first (if you not do it, you will have a "502 bad gateway" error instead of the phpPgadmin first page).
 +
 +
For make it running after install the package, make a "systemctl start php-fpm" (and enable it if you want to use it all the time and/or after reboot, by "systemctl enable php-fpm)
  
 
   server {
 
   server {
Line 157: Line 85:
 
   }
 
   }
  
 +
but there is an other simple way to do it running (also, if you need some other web apps, it would be easy more after):
  
== Troubleshooting Access Denied (403) ==
+
  server {
 +
      listen 80;
 +
      server_name localhost default_server;
 +
      root /srv/http/www/public_html;
 +
      index index.html index.html index.php;
 +
      location ~ \.php$ {
 +
          try_files $uri =404;
 +
          include fastcgi_params;
 +
          fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
 +
          fastcgi_index index.php;
 +
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
  
You will need to edit the {{ic|.htaccess}} file located at
 
  
  /etc/webapps/phppgsql/.htaccess
+
with this config, your phppgadmin will be accessible at http://localhost/phppgadmin directly and you will be able also to add some other web apps easy in the same way
  
to
+
(just have to paste/link them under public_html directory and find it at localhost/your_webapps)
 +
 
 +
this config make working all php file inside your localhost directly
 +
 
 +
(also it is a good idea to allow a user http http in the top of this nginx file and make directory srv/http/ under http owner/group)
 +
 
 +
the "server" serve only if you want to create some other server name designed only for this...
  
  Allow from <ip>
+
also, make a root inside the location of php is not a simple way to do and make the config file in trouble...
  
where <ip> is your current ip (or use 127.0.0.1 if you are on the same box) and then
+
===phpPgAdmin configuration===
 +
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.
  
  rc.d restart httpd
+
If your PostgreSQL server is not on the localhost, edit the following line:
 +
$conf['servers'][0]['host'] = '';
  
in order to access phppgadmin.
+
==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 {{ic|false}} once you have read the FAQ and understand how to change PostgreSQL's {{ic|pg_hba.conf}} to enable passworded local connections.
 +
 
 +
Edit {{ic|/etc/webapps/phppgadmin/config.inc.php}} and change the following line
 +
  $conf['extra_login_security'] = true;
 +
to
 +
  $conf['extra_login_security'] = false;

Latest revision as of 22:30, 28 December 2015

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

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: Grammar, punctuation, style issues, see also Help:Style and related. (Discuss in Talk:PhpPgAdmin#)

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/

 sudo ln -s /usr/share/webapps/phppgadmin /srv/http/<domain>/public_html/phppgadmin

You can also setup a sub domain with a server block like so (if using php-fpm):

Also, you need to use at less php-fpm (you need it), you have to make it running first (if you not do it, you will have a "502 bad gateway" error instead of the phpPgadmin first page).

For make it running after install the package, make a "systemctl start php-fpm" (and enable it if you want to use it all the time and/or after reboot, by "systemctl enable php-fpm)

 server {
         server_name     phppgadmin.<domain.tld>;
         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;
         }
 }

but there is an other simple way to do it running (also, if you need some other web apps, it would be easy more after):

 server {
     listen 80;
     server_name localhost default_server;
     root /srv/http/www/public_html;
     index index.html index.html index.php;
     location ~ \.php$ {
         try_files $uri =404;
         include fastcgi_params;
         fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
         fastcgi_index index.php;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }


with this config, your phppgadmin will be accessible at http://localhost/phppgadmin directly and you will be able also to add some other web apps easy in the same way

(just have to paste/link them under public_html directory and find it at localhost/your_webapps)

this config make working all php file inside your localhost directly

(also it is a good idea to allow a user http http in the top of this nginx file and make directory srv/http/ under http owner/group)

the "server" serve only if you want to create some other server name designed only for this...

also, make a root inside the location of php is not a simple way to do and make the config file in trouble...

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;