Tuesday, December 7, 2010

apache2.2 + tomcat5.5.30 = hybrid server

I) Initial config for apache


apache22\conf\httpd.conf

.....

# Supplemental configuration

#

# The configuration files in the conf/extra/ directory can be

# included to add extra features or to modify the default configuration of

# the server, or you may simply copy their contents here and change as

# necessary

# Virtual host for Gangaa

Include conf/extra/gangaa_miba.conf

......

Above single line add httpd.conf file.


II) apache22\conf\extra\my.conf


The following is in side my.conf file's data


<VirtualHost *:80>

ServerName 127.0.0.1

ServerAdmin bhdg@mail.mn

DocumentRoot "D:/home/wwwartm/public_html"

ErrorLog logs/my_error.log


SetEnvIf Request_URI "\/you_are\/*" redirect


CustomLog logs/apache_access.log common env=!redirect


ProxyRequests Off

RedirectPermanent /you_are/welcome_to_our/ http://127.0.0.1/

ProxyPass / http://127.0.0.1:8080/

ProxyPassReverse / http://127.0.0.1:8080/

</VirtualHost>


 


1) $CATLINA_HOME/conf/server.xml


<?xml version="1.0" encoding="UTF-8"?>

<Server port="8005" shutdown="SHUTDOWN">

<Listener className="org.apache.catalina.core.AprLifecycleListener" />

<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />

<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

<Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>

<GlobalNamingResources>

   <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

   <Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase" factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />

</GlobalNamingResources>


<Service name="Catalina">

<Connector port="8080"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
proxyName="127.0.0.1" proxyPort="80"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" />



<Connector port="8081"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
proxyName="inspiron" proxyPort="80"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" />


<Connector port="8009" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />


<Engine name="Catalina" defaultHost="localhost">

    <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>


    <Host name="localhost" appBase="webapps/localhost"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false"></Host>

<Host name="inspiron" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false"></Host>


</Engine>

</Service>



</Server>


2) $CATLINA_HOME/conf/Catalina/localhost/you_are.xml


In side you_are.xml file


<?xml version="1.0" encoding="UTF-8"?>

<Context docBase="D:/home/wwwartm/public_html/you_are"></Context>


3) To make custom root folder in $CATLINA_HOME/webapps/localhost


mkdir $CATLINA_HOME/webapps/localhost/ROOT

mkdir $CATLINA_HOME/webapps/localhost/ROOT/WEB-INF

mkdir $CATLINA_HOME/webapps/localhost/ROOT/WEB-INF/classes

mkdir $CATLINA_HOME/webapps/localhost/ROOT/WEB-INF/lib


In side ROOT/WEB-INF/web.xml file


<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">


<display-name>Welcome to MIBA app</display-name>

<description>Welcome to MIBA web-app</description>


</web-app>


In side ROOT/index.html


<html>

<head>

<title>Welcome to Art MIBA site</title>

<META HTTP-EQUIV="Refresh" CONTENT="3; URL=http://127.0.0.1/you_are/welcome_to_our/webpage_mn/index.html">

</head>

<body bgcolor="#66CC99">

<center style="color:#AA0000;font-family:Arial, Helvetica, sans-serif" >Please wait a second loading page ...</center>

</body>


To check custom root:


http://127.0.0.1 loads above index file.


4) To copy ROOT/index.html to D:/home/wwwartm/public_html/you_are folder


To check custom root:


http://127.0.0.1/you_are loads above index file.


5) To configure http://127.0.0.1/you_are/welcome_to_our/index.jsp


The following is in side of index.jsp file in / folder of opencms workplace.


<%@ page session="false" import="org.opencms.jsp.util.CmsJspVfsAccessBean" %><%--

--%><%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %><%--

--%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%--

--%><c:set var="vfs" value="${cms:vfs(pageContext)}" /><%


// Scriptlet code was required for redirection, will be improved... intro.html


String target = request.getLocale().getLanguage();

if (!"mn".equals(target)) {

target = "mn";

}

target = "/webpage_" + target + "/index.html";

pageContext.setAttribute("target", target);

String link = (String)((CmsJspVfsAccessBean)pageContext.getAttribute("vfs")).getLink().get(target);

response.sendRedirect(link);


%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

<head>

<title>Please redirect to ${vfs.link[target]}</title>

<meta http-equiv="refresh" content="0; URL=${vfs.link[target]}"/>

</head>

<body>

<h1>This page has moved!</h1>

<p>Please redirect your browser to: <a href="${vfs.link[target]}">${vfs.link[target]}</a></p>

</body>

</html>


6) To set custom favicon for http://127.0.0.1


To copy favicon.ico file in to $CATLINA_HOME/webapps/localhost/ROOT


But we not did see change favicon !!!!


That is all done.