Showing posts with label Apache. Show all posts
Showing posts with label Apache. Show all posts

How to install Maven on Windows

How to Install Apache Maven 3.3.9 in Windows:

  1. JDK and JAVA_HOME. Make sure JDK is installed, and “JAVA_HOME” variable is added as Windows environment variable.
  2. Download Apache Maven. Visit Maven official website, download the Maven zip file, for example : apache-maven-3.3.3-bin.zip . ...
  3. Add M2_HOME and MAVEN_HOME. ...
  4. Add To PATH. ...
  5. Verification. mvn-version
Tools Used :
  1. JDK 1.8.0_101
  2. Maven 3.3.3
  3. Windows 10
      More in Video









How To Install Apache Tomcat 7 on CentOS 6.5 by Yum


Video: clickMe

Install Tomcat
1. yum install tomcat or sudo yum install tomcat
2. /usr/share/tomcat
3. vi /usr/share/tomcat/conf/tomcat.conf
4. JAVA_OPTS > -Xmx500m -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC
Install Admin Packages
1. sudo yum install tomcat-webapps tomcat-admin-webapps
2. sudo vi /usr/share/tomcat/conf/tomcat-users.xml
3. Add
    <tomcat-users>
    <user username="tutorialbyexample" password="vinod"    roles="manager-gui,admin-gui"/>
     </tomcat-users>
or

Un comment the commented user and role

or

Replace the file content by below:

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<tomcat-users>
<!--
  NOTE:  By default, no user is included in the "manager-gui" role required
  to operate the "/manager/html" web application.  If you wish to use this app,
  you must define such a user - the username and password are arbitrary.
-->
<!--
  NOTE:  The sample user and role entries below are wrapped in a comment
  and thus are ignored when reading this file. Do not forget to remove
  <!.. ..> that surrounds them.
-->

  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>


 <role rolename="admin"/>
 <role rolename="admin-gui"/>
 <role rolename="admin-script"/>
 <role rolename="manager"/>
 <role rolename="manager-gui"/>
<role rolename="manager-script"/>
 <role rolename="manager-jmx"/>
 <role rolename="manager-status"/>
<user name="admin" password="adminadmin" roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" />
</tomcat-users>


4. Start tomcat /etc/init.d/tomcat start
5. Access the Web Interface
    http://server_IP_address:8080 or  http://127.0.0.1:8080




How to configured the Apache web server (virtual host) for using the two web server (tomcat -1 and tomcat 2)


Follow the following steps:
1. Installed the Apache httpd in Apache server.
2. Install the java or upgrade
3. Install the tomcat in web server.
4. Access the virtual host from client with domain name.
















In more details:
1. Installed the Apache httpd in Apache server.
Logging into the Apache server with root user
Note: I'm using the,Red Hat Enterprise Linux
# yum install httpd
To start/stop/restart the Apache/httpd, run:
# chkconfig httpd on
# /etc/init.d/httpd start/stop/restart

 Edit the Apache conf file, httpd.conf located under /etc/httpd/conf/httpd.conf
 #vi /etc/httpd/conf/httpd.conf

Add the below in end of file

<VirtualHost *:80>
        DocumentRoot /home/www/www.tutorialbyexample.com
        ServerName  www.tutorialbyexample.com

        ProxyPass                      /     ajp://localhost:20010/ retry=0 ttl=600
        ProxyPassReverse        /      ajp://localhost:20010/

        ProxyPass                      /*     ajp://localhost:20010/* retry=0 ttl=600
        ProxyPassReverse        /*      ajp://localhost:20010/*
</VirtualHost>

<VirtualHost *:80>
        DocumentRoot /home/www/www.apacheserverwebserver.com
        ServerName  www.apacheserverwebserver.com

        ProxyPass                      /     ajp://localhost:20020/ retry=0 ttl=600
        ProxyPassReverse        /      ajp://localhost:20020/

        ProxyPass                      /*     ajp://localhost:20020/* retry=0 ttl=600
        ProxyPassReverse        /*      ajp://localhost:20020/*

</VirtualHost>

Save it and close it.
Restart the Apache server: /etc/init.d/httpd restart
Note: # indicate i have logging with root user.

2. Install the java or upgrade
Refer the java installation.

3. Install the tomcat in web server.
Refer the tomcat install in Unix.

Assuming tomcat have installed in both web server and configure with AJP port
Web Server 1 (tomcat with AJP port 20010)
Web Server 2 (tomcat with AJP port 20020)

Just check,
/tomcate/conf/server.xml
 <Connector  protocol="AJP/1.3"  URIEncoding="UTF-8"  port="20010" />

and
<Connector  protocol="AJP/1.3"  URIEncoding="UTF-8"  port="20020" />

Restart the tomcat.

4. Access the virtual host from client with domain name. 
Access the both virtual host (vhost) from any client as mention below.

www.tutorialbyexample.com
www.apacheserverwebserver.com

Note: All about in your network accessible area, don't expect this conf for outside of world (over internet).

Reference: vhost

Apache Server Load Balancer Sticky Non Sticky Sessions


In this tutorial, we'll discuses about (Apache Server) load balancer, hardware & software.




Let's discussed about software load balancer: 
First of all we need to understand the need of load balancer, as in web application, we can used either, web server or application server for deploying the our app. Ensuring our application are working with n-number of users load without failure. That will be done with help of Load balance. See the image below for high level flow:




























  • The client opens a connection to the system such as http://localhost:80/myapp thus creating a web request.
  • The load balancer dispatches the web request onto one of the nodes, depending on the load balancing strategy.
  • The transparent HTTP session failover makes sure that the sessions are replicated across the cluster. Session replication is indicated by dotted blue both side arrow in the figure.


  • Where as app/web server are configure in Node 1 as http://localhost:9001, Node 2 as http://localhost:9002 and Node 3 as http://localhost:9003. All app/web server are connecting with Database (DB).

    Note: port 9001, 9002 and 9003 are for app/web server port where our myapp deployed.

    Need to deploy the three tomcate instance in same machine or different, I did that in same machine with as suggested port.

    Assuming jdk have been installed and JAVA_HOME set.


    /apache-tomcat-6.0.43-9001/
    /apache-tomcat-6.0.43-9002/
    /apache-tomcat-6.0.43-9003/

    Change the port number in /apache-tomcat-6.0.43-900*/conf/server.xml
    /apache-tomcat-6.0.43-9001/
    <Server port="8001" shutdown="SHUTDOWN">
     <Connector port="9001" protocol="HTTP/1.1"

    /apache-tomcat-6.0.43-9002/
    <Server port="8002" shutdown="SHUTDOWN">
     <Connector port="9002" protocol="HTTP/1.1"

    /apache-tomcat-6.0.43-9003/
    <Server port="8003" shutdown="SHUTDOWN">
     <Connector port="9003" protocol="HTTP/1.1"

    We can set up our system to use either sticky sessions or non-sticky sessions.

    Sticky Sessions
    Here, all web requests of one HTTP session are served from the same cluster node.
    If a request of a HTTP session was first dispatched to Node 1 such as http://localhost:9001, all subsequent requests will be dispatched to Node 1, such as http://localhost:9001.

    Non-Sticky Sessions
    Here, web requests are dispatched to random nodes across the cluster, depending on the load balancing strategy.
    If a request of a HTTP session was first dispatched to Node 1 such as http://localhost:9001, subsequent requests might be dispatched to any nodes, such as http://localhost:9002 or http://localhost:9003.

    Without a session replication mechanism, we need to use sticky sessions: on a non-sticky session system, every individual node which has processed the session once will have an individual copy of the session. Take a session cart, for example: on a non-sticky session system, each time the session is processed by a different node, that node holds a representation of the cart at the time.

    Transparent HTTP Session details:
    This is the single time configuration, As soon as the infrastructure for load balancing and transparent HTTP session is set up, we can use the infrastructure for any number of app.

    Configure a load balancer. 
    Typically, in production environments, a hardware load balancer is used. However, for testing or development in project use, for example, a hardware load balancer might be too expensive or not be available. Instead of a hardware load balancer, we can use software load balancers, such as:
       •Apache http Server. 

    How To Use Apache HTTP Server as Load Balancer
    Apache Server is open sour http server and is available for many common operating systems. The Apache HTTP Server can be extended in functionality by integrating modules. 

    How to Use Apache HTTP Server as a Load Balancer:
    Adding the additional functionality by using modules (also called "mods")

    mod_proxy_balancer
    Required. Provides load balancing functionality. For details, see the Apache website: http://httpd.apache.org/.

    mod_headers
    Optional. Required for sticky sessions. For details, see the Apache website: http://httpd.apache.org/.
    How to enable the mods in Appache server ${APACHE_INSTALL}/conf/httpd.conf file and uncomment/add the lines that reference mods. For example, from

    ${APACHE_INSTALL}/conf/httpd.conf

    LoadModule headers_module modules/mod_headers.so
    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
    LoadModule proxy_connect_module modules/mod_proxy_connect.so
    LoadModule proxy_http_module modules/mod_proxy_http.so

    After configuration of mods, what we need to Configure Apache HTTP Server, sticky sessions or non sticky sessions.

    Apache HTTP Server's Configuration for sticky sessions:

    ${APACHE_INSTALL}/conf/httpd.conf

    Listen 80
    Header add Set-Cookie: "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
    <Proxy balancer://myclustername >
    BalancerMember http://localhost:9001 route=node1
    BalancerMember http://localhost:9002 route=node2
    BalancerMember http://localhost:9003 route=node3
    </Proxy>
    ProxyPass /myapp balancer://myclustername/ stickysession=ROUTEID
    ProxyPassReverse /myapp balancer://myclustername/

    <Location /balancer-manager>
    SetHandler balancer-manager

    Order Deny,Allow
    Deny from all
    Allow from all
    </Location>

    Load balancer port is set to 80 and application is visible as http://localhost:80/myapp

    Apache HTTP Server's Configuration for non sticky sessions:

    ${APACHE_INSTALL}/conf/httpd.conf

    Listen 80
    <Proxy balancer://myclustername >
    BalancerMember http://localhost:9001 loadfactor=2
    BalancerMember http://localhost:9002 loadfactor=2
    BalancerMember http://localhost:9003 loadfactor=1
    </Proxy>

    ProxyPass /myapp balancer://myclustername/myapp
    ProxyPassReverse /myapp balancer://myclustername/myapp

    <Location /balancer-manager>
    SetHandler balancer-manager

    Order Deny,Allow
    Deny from all
    Allow from all
    </Location>

    Load balancer port is set to 80 and application is visible as http://localhost:80/myapp

    Note: If Node 1 will down, it will redirect to next available Node 2 or Node 3. If Node 2 is down then it will redirect to Node 1 or Node 3.  If Node 3 is down then it will redirect to Node 1 or Node 2.

    Ref: http://www.apache.org/


    /etc/httpd/conf/httpd.conf

    ################################################################
    ### Non Stickey Session
    ################################################################

    #<Proxy balancer://mycluster>
    #BalancerMember http://localhost:9001 loadfactor=2
    #BalancerMember http://localhost:9002 loadfactor=1
    #</Proxy>

    #ProxyPass /examples balancer://mycluster/examples
    #ProxyPassReverse /examples balancer://mycluster/examples

    #<Location /balancer-manager>
    #SetHandler balancer-manager

    #Order Deny,Allow
    #Deny from all
    #Allow from all
    #</Location>

    ###############################################################

    ################################################################
    ### Stickey Session
    ################################################################
    Header add Set-Cookie: "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
    <Proxy balancer://myclustername >
    BalancerMember http://localhost:9001 route=node1
    BalancerMember http://localhost:9002 route=node2
    </Proxy>
    ProxyPass /examples balancer://myclustername/examples stickysession=ROUTEID
    ProxyPassReverse /examples balancer://myclustername/examples

    <Location /balancer-manager>
    SetHandler balancer-manager

    Order Deny,Allow
    Deny from all
    Allow from all
    </Location>

    server.xml 9001
        <Connector port="9001" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   redirectPort="8442" />

    server.xml 9002
        <Connector port="9002" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   redirectPort="8442" />

    Tomcat
    Default examples refer for this located under, if you want to deploy make sure deploy the same war/ear file in all nodes/tomcat instance:
    /tomcat9001/apache-tomcat-6.0.43/webapps/examples
    /tomcat9001/apache-tomcat-6.0.43/webapps/examples

    Put your question I'll more than happy to help!!!