Hi all,
I've read a configuration of tomcat and apache (http://daydream.stanford.edu/tomcat/install_web_services.html ) over the last 4 days, and I've found much of what I need to be lacking....
After reading full documentation on the jakarta website about how the server.xml is organized for tomcat 4, I still have some
questions...
I will first explain the desired setup, then I will show what I have. If you gracious folks can help me set this up, I will GLADLY
set up a complete HOW-TO replicating the solution on my website for all the world to see. you knows you probably get a lot of questions about this. My hope is to guide the user by the hand step by step for this complex process. I have been using Tomcat 3 for a long time with mod_jk and have been very happy, but I now need the newer features of Tomcat 4.
Here's the setup (everywhere hereafter, I've replaced the actual domain names with <domainname> for privacy...just know that everytime you see that, its actually a domain name, and ignore the < > brackets
Redhat Linux 9
httpd-2.0.48 -------->/ usr/loca/apache2
Java JDK 1.4.2_03 ------->/usr/lcoal/java
Tomcat 5.0.16 Light Edition (since I have jdk 1.4.2_03) .------>/usr/local/tomcat
mod_jk -------->/usr/lcoal/src/mod_jk
my question is there is httpd in linux 9 and postgresql and i installed apache and tomcat and psotgresql i added the httpd1 and tomcat in sbin/chkconfig --add httpd1 amd tomcatd by using the configuration given in http://daydream.stanford.edu/tomcat/install_web_services.html site fully then i started the catalina_home /bin/startup.sh which was started in command line but i am not able to get test page in Browser it tells that connection refused
i start by using httpd1 and tomcatd it shows that unreconized service
please help to solve the problem as soon as possible
Thakning You
Dhayalan.G
#####################################################
Configure Environment Variables
Edit and add the lines below to "/etc/profile"
Make sure you logout and login for this to take effect. If you're in XWindow you might need to quit out of XWindow and exit primary shell. Then login again and start XWindow again (startx). It's really good to get this straight from the beginning.
JAVA_HOME=/usr/local/java/java
CATALINA_HOME=/usr/local/tomcat
PATH=$JAVA_HOME/bin:$PATH:$HOME/bin:/sbin:/usr/sbin
CLASSPATH=$CATALINA_HOME/bin/bootstrap.jar:$JAVA_HOME/lib/tools.jar:$CATALINA_HOME/common/lib/servlet.jar:/usr/local/pgsql/share/java/postgresql.jar:../lib/struts.jar:.
Now add the PATH JAVA_HOME CATALINA_HOME & CLASSPATH if any aren't in the export line
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC JAVA_HOME CATALINA_HOME CLASSPATH
This will output your environment variables
env
Install JAVA
mkdir /usr/local/java
cd /usr/local/java
sh j2sdk-1_4_2-linux-i586.bin
The jdk directory is then extracted
mv j2sdk-1.4.2 /usr/local/java
ln -s j2sdk1.4.2 java
Now the java directory will be in /usr/local/java/java. I do it like this so I can keep all my different JDKs/JREs in one directory and then just change the symbolic link to point to the current one.
Install Jakarta TOMCAT
tar xvfz jakarta-tomcat-4.1.27.tar.gz
mv jakarta-tomcat-4.1.27 /usr/local/
cd /usr/local
ln -s jakarta-tomcat-4.1.27 tomcat
Install Jakarta ANT
tar xvfz jakarta-ant-1.5.4
mv jakarta-ant-1.5.4 /usr/local
cd /usr/local
ln -s jakarta-ant-1.5.4 ant
ln -s /usr/local/ant/bin/ant /usr/local/bin/ant
Install OPENSSL
tar xvfz openssl-0.9.7c.tar.gz
mv openssl-0.9.7c /usr/local/src/
cd /usr/local/src/
ln -s /usr/local/openssl-0.9.7c openssl
cd openssl-0.9.7c
./config
make
make test
make install #This will install in /usr/local/ssl
Install APACHE
tar xvfz httpd-2.0.47.tar.Z
cd httpd-2.0.47
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite \
--enable-ssl --with-ssl=/usr/local/ssl --enable-proxy
make
make install #(places in /usr/local/apache2)
Build/Install MOD_JK Connector
Build mod_jk
cd /usr/local/src/jakarta-tomcat-connectors-jk-1.2.4-src/jk/native
./buildconf.sh
./configure --with-apxs=/usr/local/apache2/bin/apxs
make
cp apache-2.0/mod_jk.so /usr/local/apache2/modules Installs mod_jk in correct location
Configure Apache for mod_jk
I put these lines in http.conf just before NameVirtualHost
<IfModule !mod_jk.c>
LoadModule jk_module modules/mod_jk.so
</IfModule>
Configure APACHE/NON-SSL
1. mkdir /usr/local/http_nonsecure
* #Look for similar lines.
* #Make sure you have lines that say this in conf/http.conf:
* Listen myhost.mydomain:80
* #Same with this line:
* #Make sure you do this line because it will listen
* #and try to do http on the https port as well.
* ServerName myhost.mydomain:80
* #Same with this line:
* NameVirtualHost myhost.mydomain
* #I also do this to help people get to right page:
* #Make sure you have VirtualHost like this
<VirtualHost myhost.mydomain:80>
ServerAdmin me@(protected)
DocumentRoot /usr/local/http_nonsecure
ServerName myhost.mydomain:80
ErrorLog logs/webapp_public-error_log
CustomLog logs/webapp_public-access_log common
# Static files
Alias /mywebapp "/usr/local/tomcat/webapps/mywebapp"
<Directory "/usr/local/tomcat/webapps/mywebapp">
Options Indexes FollowSymLinks
DirectoryIndex index.jsp </Directory>
# Deny direct access to WEB-INF and META-INF
<Location "/mywebapp/WEB-INF/*">
AllowOverride None
deny from all </Location>
<Location "/mywebapp/META-INF/*">
AllowOverride None
deny from all </Location>
#Add these lines too
#It's likely you don't want people to access your
#secure site via plain old http. So I tell it to go
#somewhere else where I may have useful but unsecured
#site
JkMount /mywebapp_nonsecure/*.do ajp13
JkMount /mywebapp_nonsecure/*.jsp ajp13
JkMount /mywebapp_nonsecure ajp13
JkMount /mywebapp_nonsecure/* ajp13 </VirtualHost>
Make sure you add these lines too
But don't use an include for mod_jk.conf file
Because it will then be global
JkWorkersFile "/usr/local/tomcat/conf/jk/workers.properties"
JkLogFile "/usr/local/tomcat/logs/mod_jk.log"
Configure Apache/SSL
1. mkdir /usr/local/http_secure
#Now make changes in ssl.conf
#Look for similar lines and make sure it looks like this:
<VirtualHost _default_:443>
# General setup for the virtual host
DocumentRoot "/usr/local/http_secure"
#ServerName new.host.name:443
ServerName myhost.mydomain:443
ServerAdmin me@(protected)
ErrorLog logs/error_log
TransferLog logs/access_log
Redirect / https://myhost.mydomain/mywebapp
# Static files
Alias /mywebapp "/usr/local/tomcat/webapps/mywebapp"
<Directory "/usr/local/tomcat/webapps/mywebapp">
Options Indexes FollowSymLinks
DirectoryIndex index.jsp </Directory>
# Deny direct access to WEB-INF and META-INF
<Location "/mywebapp/WEB-INF/*">
AllowOverride None
deny from all </Location>
<Location "/mywebapp/META-INF/*">
AllowOverride None
deny from all </Location>
JkMount /mywebapp/*.do ajp13
JkMount /mywebapp/*.jsp ajp13
JkMount /mywebapp ajp13
JkMount /mywebapp/* ajp13
Create SSL Certificate
I didn't record my steps that well, but I think this is correct.
Someone else who outlined this in his install document and has some info on other packages such as Oracle, JFreeChart, and iText
Please see http://myweb.cableone.net/kdubuisson/Install.PDF
cd /usr/local/ssl/bin
./openssl genrsa -out myhost.mydomain.key 1024
./openssl req -new -key myhost.mydomain.key -out myhost.mydomain.csr
#Answer the questions you are prompted with
./openssl x509 -days 365 -req -in myhost.mydomain.csr \
-signkey myhost.mydomain.key -out myhost.mydomain.cert #For 1 year
cp myhost.mydomain.* /usr/local/apache2/conf #copy them over
#edit http.conf file
SSLCeritifcateFile /usr/local/apache2/conf/myhost.mydomain.cert
SSLCertificateKeyFile /usr/local/apache2/conf/myhost.mydomain.key
Configure Tomcat for mod_jk Connector
Directly below this line in "/usr/local/tomcat/conf/server.xml"
<Server port="8005" shutdown="SHUTDOWN" debug="1"\>
Add these lines:
<Listener className="
org.apache.ajp.tomcat4.config.ApacheConfig" modJk="/usr/local/apache2/modules/mod_jk.so" workersConfig="/usr/local/tomcat/conf/jk/workers.properties"/>
Directly below this line in "/usr/local/tomcat/conf/server.xml"
<Host name="localhost" debug="0" appBase="webapps">
Add this line
<Listener className="
org.apache.ajp.tomcat4.config.ApacheConfig" append="true" forwardAll="false" modJk="/usr/local/apache2/modules/mod_jk.so" />
Comment out JK2 connector, and uncomment AJP1.3 connector (jk). Will show details later
Change instances of localhost to whatever your domain name is
Create file "/usr/local/tomcat/conf/jk/workers.properties" with these contents:
# Setting Tomcat & Java Home
workers.tomcat_home=/usr/local/tomcat
workers.java_home=/usr/local/java/java
ps=/
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
Install Postgresql
WARNING! I have not gotten 7.3.4 to work with JDBC on RedHat 7.3. I had to use 7.3.2. I'm looking into this and will post instructions when I figure it out.
RedHat 9 works fine
cd /usr/local/src
tar xvfz postgresql-7.3.4.tar.gz
cd postgresql-7.3.4
./configure --with-tcl --with-java
gmake
gmake install
chown postgres.postgres /usr/local/pgsql/data
Install Pgaccess
cd /usr/local/src
tar xvfz pgaccess-0.98.8.20030520.tar.gz
cp -R pgaccess /usr/local/pgaccess
cd pgaccess
make clean
make all
Configure Postgresql
I like to keep my postgresql data in /usr/local/pgsql. The daemon scripts below point to that location
mkdir /usr/local/pgsql/data
chown postgres.postgres /usr/local/pgsql/data
chmod 0700 /usr/local/pgsql/data
/etc/rc.d/init.d/postgresql start Test it by doing this
Copying over database from old installation to new
su
su postgres You'll need switch to postgres user, so that you have access unless your user already has access
pg_dump nameOfDatabase > nameOfDatabase.psql To dump a single database
pg_dumpall > allDatabases.psql To dump all your databases
createdb -T template0 nameOfDatabase First you have to create database on new server
psql nameOfDatabase optionally create new user in psql shell
CREATE USER username;
\q
Quit out of psql
Copy .psql file over to your new server if necessary. Make sure postgres or your user has access to file
If database exist already, and you're uploading a newer version.
dropdb nameOfDatabase Get rid of old db first
psql nameOfDatabase < nameOfDatabase.psql Now, add the new one
#I'm not sure if this is the best way to get this working, but I do this
JDBC Configuration
ln -s /usr/local/pgsql/share/java/postgresql.jar /usr/local/tomcat/common/lib/postgresql.jar
I use my own connection pool, so I have a servlet that starts this up at tomcat startup
This is in /usr/local/tomcat/webapps/mywebapp/WEB-INF/web.xml
You can try using commons-pool or commons-dbcp to use a general-purpose database connection pool.
<!-- Database Initialization Servlet Configuration for mywebapp Postgres -->
<servlet>
<servlet-name>setup</servlet-name>
<servlet-class>mywebapp.SetupServlet</servlet-class>
<init-param>
<param-name>test</param-name>
<param-value>test value</param-value> </init-param>
<load-on-startup>1</load-on-startup> </servlet>
Install Struts
This is a no-brainer.
Just put the struts.jar (and other jars if there are more) and tld so your webapp can get to it. I also put it in my path, as noted above with: "../lib/struts.jar". This way I can build from /usr/local/tomcat/webapps/mywebapp/WEB-INF/classes/. You'll need a copy of these in EACH webapp you deploy.
cp *.jar /usr/local/tomcat/webapps/mywebapp/WEB-INF/lib/
cp *.tld /usr/local/tomcat/webapps/mywebapp/WEB-INF
Daemon scripts: Files in /etc/rc.d/init.d (tomcatd, postgresql, httpd)
Here's a brief explanation of unusual features in my daemon scripts
tomcatd
#You can add this line for status in tomcatd. It outputs all tomcat processes
ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}'
postgresql
Here's a brief explanation of unusual features in my daemon scripts
You can make these changes in a daemon script to allow it to connect with jdbc
Edit /etc/rc.d/init.d/postgresql. JDBC needs to connect via tcp/ip, so
add "-i" next to "-p $" so that the line contains this:
'-i -p $'
Download all the daemon scripts
Just download my scripts below. Change them if you need to, but if you've followed all my instructions above then you shouldn't have to.
/etc/rc.d/init.d/tomcatd
/etc/rc.d/init.d/postgresql This one is not the most recent. There ARE errors in this script regarding locations. I'll upload a new one soon.
/etc/rc.d/init.d/httpd
chkconfig
This installs scripts to start at startup and shutdown when system is halted
After you've copied all daemon scripts to /etc/rc.d/init.d, make sure you've changed the chkconfig line to reflect the appropriate runlevels
First make sure they are disabled, or else chkconfig sometimes gets confused
/sbin/chkconfig --del tomcatd
/sbin/chkconfig --del httpd
/sbin/chkconfig --del postgresql
Now add them
/sbin/chkconfig --add tomcatd
/sbin/chkconfig --add httpd
/sbin/chkconfig --add postgresql
################################################################################
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)