Friday, January 7, 2011

Configuration of Apache webserver

Configuration of Apache webserver on httpd.conf
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default.
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
Listen 80
# User/Group: The name (or #number) of the user/group to run httpd as.
# . On SCO (ODT 3) use "User nouser" and "Group nogroup".
# . On HPUX you may not be able to use shared memory as nobody, and the
# suggested workaround is to create a user www and use that user.
# NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET)
# when the value of (unsigned)Group is above 60000;
# don't use Group #-1 on these systems!
#
User nobody
Group #-1
# ServerAdmin: Your address, where problems with the server should be
# e-mailed. This address appears on some server-generated pages, such
# as error documents. e.g. admin@your-domain.com
#
ServerAdmin you@example.com
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html"
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
# The index.html.var file (a type-map) is used to deliver content-
# negotiated documents. The MultiViews Option can be used for the
# same purpose, but it is much slower.
#
DirectoryIndex index.html
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
#
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#

Procedure to setup Apache Tomcat on Linux Server

Apache Tomcat Server setup
1.Files Required:
JDK (latest version) : http://java.sun.com [ TO INSTALL JAVA]
Apache Tomcat (latest version) : from http://tomcat.apache.org [ TO INSTALL TOMCAT ]
Apache HTTP server (latest version) : from http://httpd.apache.org [ TO INSTALL APACHE ]
Tomcat connector - mod_jk (latest version) : from http://tomcat.apache.org [ TO DOWNLOAD TOMCAT CONNECTOR ]
2.Preinstallation Requirements:
Before Installing the Apache HTTP server on Linux , the following package dependencies have to be installed in Linux box(while making RPM installation).
· Package: httpd-, gcc, sysstat
· Firewall configuration for port 80(default http),8080 and 22
· Hostname have to be registered in DNS
3. Information
The following order should be made for installation Apache/Tomcat on linux box
1.Java should be installed if we are configuring tomcat
2. Apache tomcat must be configured with the java and test the sample page
3.Apache HTTP server must be installed.
4.Tomcat connector must be installed
4. Installing JAVA:
Step 1: Download latest J2SE EE SDK from http://java.sun.com into the local linux box (The downloaded package will be like jdk--i586.rpm.bin)
Step 2:Execute installer (note : must be done as root)
# chmod +x jdk--i586.rpm.bin (setup execute permission to the downloaded bin file)
Step 3: Install java
# ./jdk--i586.rpm.bin
Do you agree with the above license terms? Yes
(then installation should proceed)
Step 4: Confirm packages are properly installed
# /usr/java/jdk/bin/java -version (To check the java version)
5. Installing Apache tomcat:
Step 1: Download selected version from http://tomcat.apache.org (File will be like apache-tomcat-.tar.gz)
Step 2: Untar the file
# tar xvzf apache-tomcat-.tar.gz
Step 3: Setup JAVA Home
# JAVA_HOME=/usr/java/default ./startup.sh (To Start Tomcat)
# JAVA_HOME=/usr/java/default ./shutdown.sh (To Stop Tomcat)
Step 4: To Enable headless mode:
File: /usr/local/tomcat/bin/catalina.sh (add near the top)
CATALINA_OPTS="-Djava.awt.headless=true"
Step 5 : Open testing page and check result
Open page http://IPADDRESS:8080 for test
6.Installing Apache Webserver:
Step 1: Download Apache http server from http://httpd.apache.org (File will be like httpd-.tar.gz)
Step 2: # tar zxvf httpd-.tar.gz
Step 3: # cd httpd-
Step 4: # ./configure --enable-MODULE=shared --enable-so --with-mpm=worker
Step 5: # make
Step 6: # make install
Step 7: Files to be configured for any changes are /etc/httpd/conf/httpd.conf
Step 8 : open testing page and check result
Open page http://IPADDRESS:80 for test
7. Installing tomcat connector:
Step 1: Download mod_jk from http://tomcat.apache.org (File will be like mod_jk-.so )
Step 2: # cp mod_jk-.so /apache2/modules
#[//apache2/modules/]# ln –s mod_jk-.so mod_jk.so
Step 3: Configuration:
create a new file with the name mod_jk.conf and workers.properties and add the below lines
# vi mod_jk.conf
#Specific workers.properties file
#LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
# Where to put jk logs
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
JkMount /servlet/* worker1
JkMount /*.jsp worker1
JkMount /*.do worker1
JkMount /sso/* worker1
# vi httpd.conf
Add below into httpd.conf
LoadModule jk_module modules/mod_jk.so
Include conf/mod_jk.conf
# vi workers.properties
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
Step 4: Restart Apache:
# /apache/bin
# ./apachectl start (To Start apache services)
# ./apachectl stop (To Stop apache services)