Saturday, December 18, 2004

Installing Apache on Tomcat on Mandrake 10.0

1. Install Mandrake 10.0 from CD's

If you need help, please use the following link:

Select the following groups:


· Console Tools

· Development

· KDE Workstation (or Gnome)



Additionally you need the following packages:

· Webmin

· Apache2

· PostgreSQL

PostgreSQL server is not setup on Mandrake by default (Client is, but not server), used control centre install to dowload server and jdbc.

login as root

/etc/rc.d/init.d/postgresql restart

# su - postgres
$ createuser youruser

Shall the new user be allowed to create databases? (y/n) y
Shall the new user be allowed to create more new users? (y/n) n
CREATE USER
$ createdb youruser
CREATE DATABASE

$ exit
# exit
# su youruser
$ psql
Welcome to psql 7.3.2, the PostgreSQL interactive terminal.
youruser=> create table states (state_code varchar(2) primary key, state_name varchar(30) not null);

CREATE TABLE
youruser=> insert into states(state_code, state_name) values ('VA','Virgina');
INSERT 16981 1
youruser=> insert into states(state_code, state_name) values ('MD','Maryland');
INSERT 16982 1

youruser=> select * from states;
state_code | state_name
------------+----------
VA | Virgina
MD | Maryland

(2 rows)

youruser=> \q




Please use the Mandrake Control Center to perform an update of your software. By clicking on “Mandrake Update” the system will be connected to the nearest FTP server and will get security updates, bugfixes and normal updates.




1.1 Get Webmin running



It is time to get Webmin running. Webmin is a web-based interface for system administration for UNIX. Using any browser that supports tables and forms (and Java for the File Manager module), you can setup user accounts, Apache, DNS, MySQL, file sharing and so on. Webmin consists of a simple web server, and a number of CGI programs which directly update system files like /etc/inetd.conf and /etc/passwd. The web server and all CGI programs are written in Perl version 5, and use no non-standard Perl modules. Please get more information about Webmin here:



http://www.webmin.com/



Honestly, we really do not need Webmin to get everything running, but it is a wonderful tool for a LINUX system administrator and it will help us to configure stuff. After the installation please check if Webmin is already running:

/etc/init.d/webmin status

If not, please start it like this:

/etc/init.d/webmin start

You can now use the Webmin interface with your favorite browser via the following URLs:

https://localhost:10000 or https://IP-address:10000



1.3 Configure PostgreSQL

Please edit the following configuration file:

/var/lib/pgsql/data/postgresql.conf

and make sure that the this line is anabled:

tcpip_socket = true

In the file /var/lib/pgsql/data/pg_hba.conf we need this the following:

local all all trust
host all all 127.0.0.1 255.255.255.255 trust

Please use Webmin to open PostgreSQL Database Server by clicking on Servers - PostgreSQL Database Server. In this phase just make sure that PostgresSQL starts and stops without an error.

Note: You need the perl-DBD-Pg package installed to avoid error messages.

1.4 Configuring Apache2

To configure Apache2 use Webmin – Servers – Apache Webserver and click on Module Config.

Please change the following entries:

Path to httpd executable to: /usr/sbin/httpd2

Path to httpd.conf to: /etc/httpd/2.0/conf/httpd2.conf


Configure the necessary modules (just leave it like it is) and you will find the global configuration overview. In this phase just make sure that Apache starts and stops without an error message. We will configure it later.

2.1 Java stuff

Lets go to Sun first. Download the following files and store them in your favourite installation directory: (i.e. /installations)

http://java.sun.com/j2se/1.4.2/download.html
download j2sdk-1_4_2_05-linux-i586.bin

http://java.sun.com/products/javamail/downloads/index.html
download javamail-1_3_1-upd.zip

http://java.sun.com/products/javabeans/glasgow/jaf.html
download jaf-1_0_2-upd.zip

http://java.sun.com/products/jta/
download the class files and javadocs.

http://java.sun.com/products/servlet/archive.html
download Java Servlet Development Kit 2.0 for Solaris (jsdk20-solaris2-sparc.tar.Z).

Install j2sdk like this:

cd /installations

chmod 700 j2sdk-1_4_2_05-linux-i586.bin

./j2sdk-1_4_2_05-linux-i586.bin

(need to add create java_home and add to path

create /etc/profile.d/java.sh

JAVA_HOME=/download/j2sdk1.4.2_05
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH

chmod 755 /etc/profile.d/java.sh
)




Install javamail like this:



cd /installations

unzip javamail-1_3_1-upd.zip

cd javamail-1.3.1/

cp mail.jar /usr/share/java





Install jaf like this:



cd /installations

unzip jaf-1_0_2-upd.zip

cd jaf-1.0.2

cp –R * /usr/share/java





Install Jta like this:



Unzip the following files and copy the content to /usr/share/java:

jta-1_0_1B-classes.zip

jta-1_0_1B-doc.zip


Install jsdk20



cd /installations

tar xzf jsdk20-solaris2-sparc.tar.Z

chown –R root:root JSDK2.0/

cp -R JSDK2.0 /usr/local/





2.2 Install additional RPM packages from Installation CD



Please use RPMDrake in Mandrake Control Center to install the following files:



jdom-1.0.0.b8.2jpp
ant-1.5.4-2jpp
postgresql-jdbc-7.3.4-2mdk
apache2-devel-2.0.47-6.6.92mdk

Note: If RPMDrake asks to install depended files, please do it.

2.4 Installing Jakarta Tomcat 5

Please download jakarta-tomcat-5.0.28.tar.gz from here and store it in you installation directory:

http://jakarta.apache.org/site/binindex.cgi

Install Tomcat like this:

cd /installation

tar xzf jakarta-tomcat-5.0.28.tar.gz

cd jakarta-tomcat-5.0.28

mkdir /usr/local/tomcat

cp –R * /usr/local/tomcat

/usr/local/tomcat/bin/startup.sh

Use your favourite browser to check if tomcat is installed properly.

http://yourserver:8080


At the end do not forget to restart Tomcat 5 like this:

/usr/local/tomcat/bin/shutdown.sh
/usr/local/tomcat/bin/startup.sh


2.6 Install Apache Module Mod_jk

I couldn’t find this Apache Module on the CDs. So I searched for files I can download out of the net. Here is my solution:

I downloaded jakarta-tomcat-connectors-jk2-2.0.4-src.zip
from here:

http://www.apache.de/dist/jakarta/tomcat-connectors/jk2/source/


To compile the source we need to do the following steps:

cd /installation
unzip jakarta-tomcat-connectors-jk2-2.0.4-src.zip

This will create a folder called jakarta-tomcat-connectors-jk2-2.0.4-src. Rename it to jakarta-tomcat-connector.

Move this folder to wherever you store source files on your system. I used /usr/src.

copy –R jakarta-tomcat-connector /usr/src

Then run the buildconf script to create the configuration file.

cd /usr/src/jakarta-tomcat-connector/jk/native2
./buildconf.sh
Run the configure script with the path to the apxs file on your system and the options below:

./configure --with-apxs2=/usr/sbin/apxs2
Note: You need to install rpm package apache2-devel-2.0.47 first!

Build mod_jk2 with the following command:

make

If all went well, the mod_jk2.so file was successfully created. Manually copy it to Apache's shared object files directory:



cp /usr/src/jakarta-tomcat-connector/jk/build/jk2/apache2/mod_jk2.so /etc/httpd/2.0/modules

cp /usr/src/jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2/server/apache2/mod_jk2.c /etc/httpd/2.0/modules

cp /usr/src/jakarta-tomcat-connector/jk/native2/server/apache2/mod_jk2.c /etc/httpd/2.0/modules

Add the following line to the file /etc/httpd/2.0/conf/httpd2.conf:

LoadModule jk2_module modules/mod_jk2.so

Copy the file workers2.properties to /etc/httpd/conf

Restart Apache like this:

service httpd restart

No comments:

Post a Comment