Monday 30 January 2017

Postgres Installation in Windows Server 2012::

Postgres 9.5.5 Installation  and Table Space creation in Windows Server 2012::
=========================================================

Download Postgres from
https://get.enterprisedb.com/postgresql/postgresql-9.5.5-1-windows-x64.exeRun the windows installer

The default installation path will  be C:\Program Files\PostgreSQL\9.5

The default database created will be 'postgres' with  port '5432'
Set Database password when prompted during the installation.

PgAdmin-3 will be  automatically installed with postgresql.

Once installation is completed try connecting to the database using pgadmin  with the default username and password

For remote connections edit the file
C:\Program Files\PostgreSQL\9.5\data\pg_hba.conf and add the ip as follows based on your network. In my case it is::

host    all             all              192.168.240.0/24                md5

To create table space create folders under D:\
fiscaud
fiscmon
fiscmon
and give all permissions for "Network Service"  for the above folders.

Goto PgAdmin and right click tablespace-->Add Table Space and enter the table space details and path.

Tuesday 24 January 2017

Connect to Apache Tomcat 9.0.0 via IIS-8 using ISAPI redirector in Windows Server 2012::

Connect to Apache Tomcat 9.0.0 via   IIS-8 using ISAPI redirector in Windows Server 2012::
===================================================================

* Download latest JDK from the url http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html and run the exe file
You can find it installed in the default path C:\Program Files\Java\jdk1.8.0
Set environment path for JAVA_HOME as C:\Program Files\Java\jdk1.8.0

 * Download latest apache tomcat  from the url https://tomcat.apache.org/download-90.cgi and install it  under C:\Program Files\Apache Software Foundation\Tomcat9.0
 Set environment path for CATALINA_HOME as C:\Program Files\Apache Software Foundation\Tomcat9.0


* Download  ISAPI redirector  and extract it in the C:\ drive as C:\Jakarta_Isapi_Redirector_64-bit-Intel

Configure the files  under  C:\Jakarta_Isapi_Redirector_64-bit-Intel\conf as follows


uriworkermap.properties
 ===================================
 /*=wlb
 /jkmanager=jkstatus
====================================

 workers.properties
 ===================================
 worker.list=wlb, jkstatus
 worker.wlb.port=8009
 worker.wlb.host=localhost
 worker.wlb.type=ajp13
 worker.wlb.type=lb
 worker.wlb.balance_workers=ajp13w1
 worker.jkstatus.type=status
===================================

iis_redirect.reg
===================================
REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi Redirector\1.0]
"extension_uri"="\Jakarta_Isapi_Redirector_64-bit-Intel\bin\isapi_redirect.dll"
"log_file"="C:\\Jakarta_Isapi_Redirector_64-bit-Intel\\logs\\iis_redirect.log"
"log_level"="emerg"
"worker_file"="C:\\Jakarta_Isapi_Redirector_64-bit-Intel\\conf\\workers.properties"
"worker_mount_file"="C:\\Jakarta_Isapi_Redirector_64-bit-Intel\\conf\\uriworkermap.properties"
===================================

Run the file iis_redirect.reg

 * Install IIS-8 in windows server 2012  with cgi and ISAPI modules.

After the IIS installation configure ISAPI redirector in IIS-8 as follows
The roles required  for this is as follows::

Application Development Roles:
CGI, ISAPI Extensions. ISAPI Filters

Management Roles:
IIS Management Console

Goto IIS Manager and right click the "Default Website" and click "Add Virtual Directory"
Enter Alias as "Jakarta"
and Physical Path as "C:\Jakarta_Isapi_Redirector_64-bit-Intel\bin"
Click OK.

Now click "Jakarta" under "Default Website" and click Handler Mappings-->Edit Feature Permissions. Check "Read", "Script", "Execute" and click OK.


Again IIS Manager-->Default Website-->ISAPI Filters-->Add
Enter "Filter name" as "jakarta" and "Executable" as "C:\Jakarta_Isapi_Redirector_64-bit-Intel\bin\isapi_redirect.dll"

Now go back to IIS Manager and select the Windows server name.
Double click "ISAPI and CGI Restrictions"-->Add
Set "ISAPI or CGI path" as  "C:\Jakarta_Isapi_Redirector_64-bit-Intel\bin\isapi_redirect.dll" and Description as "jakarta"

Click OK.

Now restart Apache tomcat and IIS-8.
You should be able to access the  tomcat page via IIS-8
http://192.168.1.1 and http://192.168.1.1:8080 should display the tomcat page.

Monday 23 January 2017

Enabling Godmode in Windows 10 and installing SSL in IIS-8::

Enabling Godmode in Windows 10 ::
==========================

* Create a New folder on the desktop
* Rename it as GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}

Instead of Godmode you can use whatever name you would want to try. For example
GeekMode.{ED7BA470-8E54-465E-825C-99712043E01C}

It is easy as we get all the windows settings, tools  and features under a single click.



Installing SSL in IIS-8 ::
===================

Goto Windows server 2012-- IIS Manager
Click Server Name --> Server Certificates-->Create Self Signed Certificate

Give a user friendly name for the certificate and select certificate store for the new certificate.

Click Default Website and Select bindings from the right pane.

Select https and port  443 and mention the hostname and click OK.



389 Directory Server and Remote Admin console configuration:

389 Directory Server and Remote Admin console configuration:::
================================================

# Set server ipaddress in /etc/hosts
192.168.1.1

# Whitelist ports 389,9830 and 636 in the firewall

# Add the following lines at the end  of  /etc/sysctl.conf
 file.

net.ipv4.tcp_keepalive_time = 300
net.ipv4.ip_local_port_range = 1024 65000
fs.file-max = 64000
 
# Add the following lines at the end  of   /etc/security/limits.conf file 
*               soft     nofile          8192   
*               hard     nofile          8192
# Set ulimit as follows and add it in /etc/profile
 
ulimit -n 8192
 
# Create an ldapuser and set password for the user.
 
# yum install 389-ds-base openldap-clients idm-console-framework 389-adminutil 389-admin 389-admin-console 389-console 389-ds-console
 
# setup-ds-admin.pl
You will be prompted for configuration questions. Configure accordingly for your use.
 
Start the services 
#  systemctl start dirsrv.target
#  systemctl start dirsrv-admin.service
#  /httpd-2.4/bin/apachectl start  
 
#  The configuration files are under /etc/dirsrv/ directory 
and the log files at /var/log/dirsrv/
 
Now download the ldap admin client application on a remote server and try connecting to the 389 directory server
 
You can download the latest ldapbrowser from the url
http://www.ldapadministrator.com/download.htm
 
 
Install it on your windows machine 

Friday 20 January 2017

Configure multiple Postgres instances on the server and connect via PgAdmin

Configure multiple Postgres instances on the server and connect via PgAdmin::
=======================================================
Server : 192.168.1.1
Postgresuser1 : postgres1
Postgresuser2 : postgres2

login as postgres1
#wget https://ftp.postgresql.org/pub/source/v9.6.1/postgresql-9.6.1.tar.gz
#tar -zxvf postgresql-9.6.1.tar.gz
#cd  postgresql-9.6.1
#./configure   --prefix=/home/postgres1/pgsql/
#make
#make install
Now we need to create the database
# /home/postgres1/pgsql/bin/initdb  -D /home/postgres1/pgsql/data/
 
Run this command as root 
#/sbin/ldconfig /home/postgres1/pgsql/lib


You will now be able to connect to the database with the below command from the localhost shell
# /home/postgres1/pgsql/bin/psql -U postgres1 postgres
# /home/postgres1/pgsql/bin/psql -U postgres1 postgres -p 5432
psql (9.6.1)
Type "help" for help.

postgres=# alter user postgres password '123456';
postgres=# GRANT ALL ON DATABASE postgres  TO postgres1;


Check the version of postgresql installed
# /home/postgres1/pgsql/bin/psql --version

Now we need to access the database from outside network. For that we need to edit two configuration file under /home/postgres1/pgsql/data/

1.)Edit postgresql.conf
listen_addresses = '*'
port = 5432

2.)Edit  pg_hba.conf(Host Based Authentication File) based on your network ipaddress. In my case it is as folows

# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
host    all             all             192.168.200.0/24            trust

Now restart postgresql service as follows::
/home/postgres1/pgsql/bin/pg_ctl -D /home/postgres1/pgsql/data/ -l logfile start

Repeat the same steps for the second user 'postgres2'
Give another port for the second user in  postgresql.conf


Once the installation is completed. Try installing pgAdmin on your Desktop and connect to the postgres server.

Download pgadmin from https://ftp.postgresql.org/pub/pgadmin3/release/v1.22.2/win32/pgadmin3-1.22.2.zip

Install it and give the server ip  port address  and password to connect.

You should be able to connect to the server. You can use the same credentials to connect from different applications to the database server.


We can create table space via pgAdmin.
Once the table space is created, check it in the backend under the directory '/home/postgres1/pgsql/data/pg_tblspc'

[postgres1@ind pg_tblspc]$ ll
total 0
lrwxrwxrwx 1 postgres1 postgres1 23 Jan 20 17:23 16389 -> /home/postgres1/tablespace1
lrwxrwxrwx 1 postgres1 postgres1 23 Jan 20 17:23 16390 -> /home/postgres1/tablespace2
lrwxrwxrwx 1 postgres1 postgres1 23 Jan 20 17:24 16391 -> /home/postgres1/tablespace3
drwx------ 2 postgres1 postgres1  6 Jan 20 16:54 tablespace1
drwx------ 2 postgres1 postgres1  6 Jan 20 16:54 tablespace2
drwx------ 2 postgres1 postgres1  6 Jan 20 16:54 tablespace3

Wednesday 18 January 2017

Multiple Tomcat Instances connected via apache using mod-jk connector configuration::

Multiple Tomcat Instances connected via apache using mod-jk connector configuration::
================================================================
# yum install gcc

Creating the users and group::
# groupadd apache
# useradd -g apache -m -d /home/linuxgeek1 linuxgeek1

Install apache as mentioned in previous thread.

Download latest java from the url

cd /opt/ linuxgeek1/
# wget  http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz
untar it

Goto the home directory of the user  ' linuxgeek1' and edit .bash_profile as below  to set the PATH

PATH=$PATH:$HOME/.local/bin:$HOME/bin:$HOME/httpd/bin:/opt/linuxgeek1/jdk1.8.0_121/bin
#export JAVA_HOME=/opt/linuxgeek1/jdk1.8.0_121
export PATH

Check the installed java version
# java -version

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)




Download latest Apache Tomcat into the home directory and untar it
# wget http://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.11/bin/apache-tomcat-8.5.11.tar.gz
# tar -zxvf  apache-tomcat-8.5.11.tar.gz
# cd  apache-tomcat-8.5.11

Download latest mod-jk connector into the home directory and untar it.
# wget  http://www-us.apache.org/dist/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.42-src.tar.gz
#  tar -zxvf tomcat-connectors-1.2.42-src.tar.gz
#  cd  tomcat-connectors-1.2.42-src/native
#  ./configure  --with-apache=/home/linuxgeek1/httpd  –-with-apxs=/home/linuxgeek1/httpd/bin/apxs
or 
#  ./configure  --with-apxs=/home/iaas1idm/httpd/bin/apxs

Now goto apache home directory and under conf dir, create two files workers.properties and  mod_jk.conf with the contents as follows:

# vi  workers.properties
===========================
workers.tomcat_home=/home/linuxgeek1/apache-tomcat
workers.java_home=/opt/linuxgeek1/jdk1.8.0_121
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.port=8029
worker.worker1.host=localhost
worker.worker1.lbfactor=1
# Set properties
===========================

# vi mod_jk.conf
===========================
# Where to find workers.properties
JkWorkersFile /home/linuxgeek1/httpd/conf/workers.properties
# location of log file
JkLogFile /home/linuxgeek1/httpd/logs/mod_jk.log
# log level
JkLogLevel info
# Select the log format
#JkLogStampFormat “[%a %b %d %H:%M:%S %Y]”
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
#JkRequestLogFormat “%w %V %T”
#Send everything for context /test to worker ajp13
JkMount /* worker1
============================

Now edit the httpd.conf file and entries for virtual host, port and mod_jk module details

#vi httpd.conf

Listen 192.168.1.1:8010 
LoadModule jk_module modules/mod_jk.so  (add this line in the load module section)

At the bottom of the httpd.conf file add the virtual host entries as folows::


====================================
#mod_jk
Include conf/mod_jk.conf
#JkWorkersFile "conf/workers.properties"
#JkLogFile "/home/linuxgeek1/httpd/logs/mod_jk.log"
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

<VirtualHost *:80>
#ServerAdmin admin@www.mydomain1.com
DocumentRoot "/home/linuxgeek1/apache-tomcat/webapps/ROOT"
#ServerName http://www.mydomain1.com
#ErrorLog logs/www.mydomain1.com_log
#CustomLog logs/www.mydomain1.com_log combined

#JkMount /  worker1
JkMount /* worker1

</VirtualHost>
====================================


Also edit the port details in tomcat configuration file "server.xml". We need to mention different port numbers for shutdown, tomcat thread and AJP for  different users. Below mentioned configuration is for the user linuxgeek1.
====================================
<Server port="8011" shutdown="SHUTDOWN">

  <Connector port="8082" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8082" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8029" protocol="AJP/1.3" redirectPort="8443" />
===================================
Now restart apache  and tomcat and try accessing the url 192.168.1.1:8010 and 192.168.1.1:8082

Both the pages will display the apache tomcat default page.

Repeat the same steps above with different users and different ports for multiple instances

Multiple Apache 2 instances configuration in Centos7

Multiple Apache 2 instances  configuration in Centos7::
===============================================

Multiple apache instances run on the same server  under different user accounts and ports

Here for example we can install apache  for the user 'linuxgeek1'  with common group 'apache'.

For more instances add more users and repeat the same steps below:

# yum install gcc

Creating the users and group::
groupadd apache
useradd -g apache -m -d /home/linuxgeek1 linuxgeek1
useradd -g apache -m -d /home/linuxgeek2 linuxgeek2

Installing apache  for first user:

Login as  linuxgeek1
# su - linuxgeek1

Download Apache latest version, under home directory  /home/linuxgeek1

# wget  http://redrockdigimark.com/apachemirror//httpd/httpd-2.4.25.tar.gz
# tar -zxvf   httpd-2.4.25.tar.gz

untar the source file as  /home/linuxgeek1/httpd-2.4.25

The dependencies  during the installation are as follows::

Download the dependencies under /home/linuxgeek1/httpd-2.4.25/srclib/ and untar it  there before apache compilation

It will appear as
 /home/linuxgeek1/httpd-2.4.25/srclib/  # ll

 drwxr-xr-x. 28  linuxgeek1 apache 4096 Jan 18 14:00 apr
drwxr-xr-x.  20  linuxgeek1 apache 4096 Jan 18 14:00 apr-util
-rw-r--r--.      1   linuxgeek1 apache 357 Jan 18 14:00 Makefile
-rw-r--r--.      1   linuxgeek1 apache   121 Feb 11  2005 Makefile.in
drwxr-xr-x.   9   linuxgeek1 apache 8192 Jan 18 09:39 pcre

 ================
apr-devel
# ./configure --prefix=/home/linuxgeek1/httpd-2.4.25/srclib/apr/

apr-util-devel
#  ./configure --with-apr=/home/linuxgeek1/httpd-2.4.25/srclib/apr/

pcre-8.4.0

=================

Now go to /home/linuxgeek1/httpd-2.4.25


# ./configure --prefix=/home/linuxgeek1/httpd/ --enable-ssl --enable-so --with-included-apr=/home/linuxgeek1/httpd-2.4.25/srclib/apr/ --with-included-apr-util=/home/linuxgeek1/httpd-2.4.25/srclib/apr-util/ --with-pcre=/home/linuxgeek1/httpd-2.4.25/srclib/pcre/pcre-config   --with-mod_jk --enable-mpms-shared=all

# make
# make install

Once installation is done edit httpd.conf  to change the apache port.

change it as follows::
Listen 192.168.1.1:8010

Restart apache

Try it from browser as  http://192.168.1.1:8010

Repeat the same steps for different users using different ports.