Wednesday, September 26, 2018

Installation of PostgreSQL

Install through yum:

[root@localhost ~]# yum -y install postgresql-server postgresql postgresql-libs
or
[root@localhost ~]# yum -y update postgresql-server postgresql postgresql-libs

Install through apt-get:

[root@localhost ~]# apt-get install postgresql

For manual installation:

Download the .rpm or .deb file(s) and save it to disk.
Binary Distributions: http://www.postgresql.org/download/linux

Install:

[root@localhost ~]# rpm -ivh postgresql-<version>.rpm postgresql-server-<version>.rpm postgresql-libs-<version>.i386.rpm

or

[root@localhost ~]# dpkg -i postgresql-<version>.deb
Initialization of PostgreSQL server:
[root@localhost ~]# service postgresql initdb
[root@localhost ~]# chkconfig postgresql on
or
[root@localhost ~]# postgresql-setup initdb
[root@localhost ~]# systemctl enable postgresql
Configuration:

edit the file /var/lib/pgsql/data/pg_hba.conf replase the line

host    all         all         127.0.0.1/32          ident
with this one
host    all         all         127.0.0.1/32          md5
Starting of PostgreSQL server:
[root@localhost ~]# service postgresql start
or
[root@localhost ~]# systemctl start postgresql
Logon into the PostgreSQL server:
[root@localhost ~]# su postgres
bash-4.2$ psql postgres
could not change directory to "/root"
psql (9.2.18)
Type "help" for help.

postgres=# 
Create PostgreSQL user:
postgres=# CREATE USER vpnttg SUPERUSER;
CREATE ROLE
postgres=# ALTER USER vpnttg UNENCRYPTED PASSWORD 'vpnttgpass';
ALTER ROLE
Check of PostgreSQL users:
postgres=# SELECT * FROM pg_shadow;
 usename  | usesysid | usecreatedb | usesuper | usecatupd | userepl |   passwd   | valuntil | useconfig 
----------+----------+-------------+----------+-----------+---------+------------+----------+-----------
 postgres |       10 | t           | t        | t         | t       |            |          | 
 vpnttg   |    16384 | f           | t        | t         | f       | vpnttgpass |          | 
(2 rows)

postgres=# 
Logout from the PostgreSQL server:
postgres=# \q
bash-4.2$ exit
[root@localhost ~]#
Create of VPNTTG DB:
[root@localhost ~]# export PGPASSWORD=vpnttgpass
[root@localhost ~]# createdb vpnttgdb -h 127.0.0.1 -U vpnttg
List of PostgreSQL databases:
[root@localhost ~]# psql -l -h 127.0.0.1 -U vpnttg
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 vpnttgdb  | vpnttg   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
(4 rows)

[root@localhost ~]# 
 

Installation of VPNTTG

Download:

Download the .rpm or .deb or .tgz file(s) and save it to disk.






Installation:

[root@localhost ~]# rpm -ivh vpnttg-2.3-6.<architecture>.rpm
or
[root@localhost ~]# dpkg -i vpnttg_2.3-6_<architecture>.deb
or
[root@localhost ~]# tar -C / -xzf vpnttg-2.3-6.<architecture>.tgz

optional

edit the file /stats/vpnttg/etc/vpnttg_db.conf to change vpnttg user password

don't forget to change vpnttg user password in the database too!

Initialization of vpnttgdb database:

[root@localhost ~]# export PGPASSWORD=vpnttgpass
[root@localhost ~]# psql vpnttgdb -h 127.0.0.1 -U vpnttg < /stats/vpnttg/sql/vpnttgdb.sql
   

Installation of Apache Web Server

Install through yum:

[root@localhost ~]# yum -y install httpd mod_ssl
or
[root@localhost ~]# yum -y update httpd mod_ssl

Install through apt-get:

[root@localhost ~]# apt-get install apache2
Configuration:

If your Apache web server configuration directory is not /etc/httpd/, then it is necessary to copy /stats/vpnttg/etc/vpnttg.conf file to the appropriate folder.
For example in Debian or Ubuntu Linux distribution Apache web server configuration directory is /etc/apache2/

[root@localhost ~]# cp /stats/vpnttg/etc/vpnttg.conf /etc/apache2/sites-available/vpnttg.conf
Initialization:
[root@localhost ~]# chkconfig httpd on
or
[root@localhost ~]# systemctl enable httpd
or
[root@localhost ~]# a2enmod ssl
[root@localhost ~]# a2ensite default-ssl
[root@localhost ~]# a2enmod rewrite
[root@localhost ~]# a2enmod cgi
[root@localhost ~]# a2ensite vpnttg.conf

Restart the web server:

[root@localhost ~]# service httpd restart
or
[root@localhost ~]# systemctl restart httpd
or
[root@localhost ~]# service apache2 reload
   

Change Timezone

To find list of all available time zones, run:
[root@localhost ~]# timedatectl list-timezones
The syntax is as follows to set timezone and need to run as root user:
[root@localhost ~]# timedatectl set-timezone time_zone
In this example, set timezone to America/Chicago
[root@localhost ~]# timedatectl set-timezone America/Chicago
Verify new settings by typing the following two commands:
[root@localhost ~]# date
Sun Jun 18 15:25:03 CDT 2017
[root@localhost ~]# ls -l /etc/localtime 
lrwxrwxrwx 1 root root 37 Jun 18 15:24 /etc/localtime -> ../usr/share/zoneinfo/America/Chicago
[root@localhost ~]#
Change the TimeZone setting on /var/lib/pgsql/data/postgresql.conf to the value you want:
log_timezone = 'America/Chicago'
timezone = 'America/Chicago'
After that you need to restart the service:
[root@localhost ~]# systemctl restart postgresql
   

Get a license key

use this form to request a license key and install it to the following location:

[root@localhost ~]# cp vpnttg.key /stats/vpnttg/etc/