Install phpPgAdmin on Ubuntu
In order to use this how to you have to install apache first following this how to. Also postgresql has to be installed, therefore you can follow this how to.
First we create a new user:
useradd -g ftpuser -d /var/www/pga -s /bin/ftp -m pga
chown pga.www-data /var/www/pga
chmod 750 /var/www/pga
mkdir /var/www/pga/conf
mkdir -p /var/www/pga/domain/{cgi-bin,exec,html,log,session,temp}
chmod 770 /var/www/pga/domain/temp
chmod 777 /var/www/pga/domain/session
chmod 700 /var/www/pga/domain/exec
chown -R pga.ftpuser /var/www/pga/*
rm -rf /var/www/pga/.b*
rm -rf /var/www/pga/.p*
Then we create a vHost for the new pga user:
cd /etc/apache2/sites-available/ vim pga
We add the following configuration:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
SuexecUserGroup pga ftpuser
ServerName www.domain.tld
ServerAlias more.domains.tld
DocumentRoot /var/www/pga/domain/html
DirectoryIndex index.php index.html index.htm
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory />
Order Deny,Allow
Deny from All
</Directory>
<Directory /var/www/pga/domain/html>
FCGIWrapper /var/www/php-fcgid-scripts/pga/php-fcgid-starter .php
Options +ExecCGI
order allow,deny
allow from all
</Directory>
ErrorLog /var/www/pga/domain/log/apache_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/www/pga/domain/log/apache_access.log combined
ServerSignature On
</VirtualHost>
Now we create the fcgi configuration:
cd /var/www/php-fcgid-scripts/ mkdir pga cd pga touch php-fcgid-starter chmod +x php-fcgid-starter vim php-fcgid-starter
Now we add the configuration:
#!/bin/sh PHPRC="/var/www/pga/conf" export PHPRC PHP_FCGI_CHILDREN=15 export PHP_FCGI_CHILDREN exec /usr/bin/php5-cgi
We configure the proper rights:
chown -R pga.ftpuser /var/www/php-fcgid-scripts/pga chmod 755 /var/www/php-fcgi-scripts/pga/php-fcgi-starter chattr -V +i /var/www/php-fcgid-scripts/pga/php-fcgid-starter
We create a php.ini file for this vHost:
cd /var/www/pga/conf wget http://www.naumann.cc/wp-content/uploads/2009/10/php.ini chown root.root php.ini
Now we download the pgaPgAdmin interface:
cd /var/www/pga/domain/ su -m pga wget http://downloads.sourceforge.net/project/phppgadmin/phpPgAdmin%20%5Bstable%5D/phpPgAdmin-4.2.2/phpPgAdmin-4.2.2.tar.bz2?use_mirror=mesh tar xjvf phpPgAdmin-4.2.2.tar.bz2
Then we copy all files into the html directory:
mv phpPgAdmin-4.2.2/* html/
Now we have to configure the postgresql server for the usage of phpPgAdmin:
vim /etc/postgresql/8.3/main/postgresql.conf
Ennable the following line:
listen_addresses = 'localhost'
Create a new user for phpPgAdmin:
sudo -u postgres createuser -D -A -P myuser sudo -u postgres createdb -O myuser mydb
Change the authentication settings in the following file to allow access via phpPgAdmin via this user:
vim /etc/postgresql/8.3/main/pg_hba.conf
Add this line:
local all myuser md5
before:
local all all ident sameuser
Categories: PHP, Ubuntu, apache, postgresql