Tuesday, February 8, 2011

Installing and configuring Apache2, Tomcat and mod_jk

Installing tomcat

Installing Apache2 

Create username and group for Apache:

#groupadd apache 
#useradd apache -c "Apache" -d /dev/null -g apache -s /bin/false

Download Apache

Compile and install: depend on your needs, choose which modules to install but make sure you can understand the security risk when enable these modules:

#tar zxvf httpd-2.2.14.tar.gz 
#cd httpd-2.2.14 
#./configure --prefix=/usr/local/apache2 --with-mpm=prefork --disable-charset-lite --disable-include --disable-env --disable-setenvif --disable-status --disable-autoindex --disable-asis --disable-cgi --disable-negotiation --disable-imap --disable-actions --disable-userdir --disable-alias --disable-so --enable-alias --enable-status --enable-rewrite 
#make
#su
#umask 022
#make install 

#chown -R root:sys /usr/local/apache2

Installing mod_jk 

Download mod_jk

Compile and install: some binaries may required during the compiling mod_jk

#tar xzvf tomcat-connectors-1.2.28-src.tar.gz 
#cd tomcat-connectors-1.2.28-src/native 
#./buildconf.sh 
#./configure --with-apxs=/usr/local/apache2/bin/apxs 
#make 
#make install 

Configuring 

Create file worker.properties at /usr/local/apache2/conf/workers.properties

worker.list=ajp13 
workers.tomcat_home=/opt/tomcat 
workers.java_home=/usr/java/jdk1.6.0_17 
worker.ajp13.type=ajp13 
worker.ajp13.host=localhost 
worker.ajp13.port=8009 

Edit httpd.conf

LoadModule jk_module modules/mod_jk.so 
JkWorkersFile conf/workers.properties 
JkLogFile logs/mod_jk.log 
JkLogLevel info 
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " 
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories 
JkRequestLogFormat "%w %V %T" 
JkMount /manager/* ajp13 
JkMount /manager/*.jsp ajp13 

JkMount /ROOT/* ajp13 
JkMount /ROOT/*.jsp ajp13 
Alias /pebble "/opt/tomcat/webapps/pebble" 

<Directory "/opt/tomcat/webapps/manager"> 
     Options Indexes FollowSymLinks 
     DirectoryIndex index.html index.htm index.jsp 
     AllowOverride None 
     Order allow,deny 
     Allow from all 
</Directory> 

Alias /rootadmin "/opt/tomcat/webapps/ROOT" 

<Directory "/opt/tomcat/webapps/ROOT"> 
     Options Indexes FollowSymLinks 
     DirectoryIndex index.html index.htm index.jsp 
     AllowOverride None 
     Order allow,deny 
     Allow from all 
</Directory>

No comments:

Post a Comment