Monday, November 10, 2008

Install Tomcat on Linux

Install Tomcat (5.0.28) on Redhat Linux 8.0
November 10, 2008

Install java

Go to http://java.sun.com/
Download and install jdk. Newest version 1.3.1_01 (during the time it is first installed).
The file name is: j2sdk-1_3_1_01-linux-i386-rpm.bin (or something like that.)

feed it into a shell:

# chmod 700 j2sdk-1_3_1_01-linux-i386-rpm.bin
# j2sdk-1_3_1_01-linux-i386-rpm.bin

scroll through the license agreement, answer yes at the bottom, and it will unpack into jdk-1.3.1_01.i386.rpm

Install the rpm file:

# rpm -ivh jdk-1.3.1_01.i386.rpm

This will install the JDK in: /usr/java/jdk1.3.1_01

You need to modify the /etc/profile to include /usr/java/jdk.x.x/bin in the path, so that the executable will run.

Usually, to make a symble link called /usr/java/jdk:
# ln –s /usr/java/jsk.x.x /usr/java/jdk
This way we don’t need to update the path in the /etc/profile every time a new version of JDK is installed.
JAVA_HOME should alos be set up in the /etc/profile
Add line:
JAVA_HOME=/usr/java/jdk; export JAVA_HOME
Into /etc/profile


Install tomcat

Download the latest stable release of tomcat, I have got: jakarta-tomcat-5.0.28.tar.gz
And then extract it into /usr/local

# cd /usr/local
# tar zxvf jakarta-tomcat-5.0.28.tar.gz
For convenience,
# ln –s Jakarta-tomcat-5.0.28 tomcat

# cd tomcat
# cd bin
# rm *.bat

To enable the Tomcat manager, you need to modify /usr/local/jakarta-tomcat-5.0.28/conf/tomcat-users.xml add a user “admin” with the role “manager”. The result should look like this:










Now the tomcat should be able to be started:

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

We should be able to connect to : http://localhost:8080/index.jsp

To stop tomcat:

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

The default permissions in the binary directory for tomcat are wrong for some silly reason.

# cd $TOMCAT_HOME/bin
# chmod 744 *.sh

Set up environment variables

In the /etc/profile, add lines:

JAVA_HOME=/usr/java/jdk; export JAVA_HOME
CLASSPATH=/usr/java/jdk/lib:usr/java/jre/lib:/usr/java/jdk/src.zip; export CLASSPATH
CATALINA_HOME=/usr/local/tomcat; export CATALINA_HOME
CATALINA_BASE=/usr/local/tomcat; export CATALINA_BASE
PATH=$PATH:$JAVA_HOME/bin

Auto-Start tomcat

To start tomcat automatically when the Linux starts:

1.
Add lines:
JAVA_HOME=/usr/java/jdk
CATALINA_HOME=/usr/local/tomcat
In the Catalina.sh file, before the line: PRGDIR=’dirname “$PRG” ‘

2.
# cd /etc/rc.d/init.d
# cp /usr/local/tomcat/bin/Catalina.sh ./
# ln –s /etc/rc.d/init.d/catalina.sh /etc/rc.d/rc5.d/S81tomcat

Linux Command

Linux Command



Linux Prectical How To


PY

Contents





  1. Linux Command
  2. Firewall
  3. environment variable
  4. customise firewall while install RedHat Linux
  5. Install Web Application on RedHat Linux
  6. 1. Install Apache Web Server
  7. 2. install JAVA 2
  8. 3. install tomcat
  9. 4.install MySQL
  10. About security of redhat linux
  11. turn on ftp server (for ever)
  12. linux command
  13. create WAR file for bustops
  14. Network Config
  15. Add a user



linux command




  1. setup the computer: prompt>setup
  2. config network interface: prompt>network config
  3. ?? chkconfig ipchains off ??
  4. service ipchains status
  5. service ipchains start
  6. service ipchains stop
  7. service ipchains restart
  8. about net work configure
  9. lsmod
  10. cd /etc/sysconfig/network-scripts
  11. ls
  12. pico ifcfg-eth0
  13. service network restart
  14. ifconfig
  15. lokkit
  16. service ipchains restart




Firewall


check firewall: service ipchains status


turn off firewall: service ipchains stops


turn off firewall from computer boot: chkconfig ipchains off




environment variable


The local environment variable is the "local" variable, it's available only for the particular instance of the shell.


The global environment variable is the shell variable which stays available ("inherited") for any program started from the current shell, including an another shell.


To set the local environment variable:


set variable_name=value (C shell)



variable_name=value (Korn or Bourne shell)



To unset the local environment variable:


unset variable_name (all shells)



To set the global environment variable:


setenv VARIABLE_NAME value (C shell)


VARIABLE_NAME=value; export VARIABLE_NAME (Korn or Bourne shell)



To unset the global environment variable:


unsetenv VARIABLE_NAME value (C shell)


unset VARIABLE_NAME (Korn or Bourne shell)



To list all environmnet variables:


env


To check a single environment variable:


echo $VARIABLE_NAME










customise firewall while install RedHat Linux



1.install


2.lokkit [enter]---customise


3.netconfig[enter]?


4.rhn_rgister[enter]


5.up2date










Install Web Application on RedHat Linux





1. Install Apache Web Server




cd /usr/local

cp /mnt/cdrom/apache_1.3.24.tar.gz ./

tar -zxf apache_1.3.24.tar.gz

mkdir apache

cd apache

cp -rf /usr/local/apache_1.3.24/* ./

cd ..

rm -rf apache_1.3.24

cd apache

./config

make

make install

/usr/local/apache/bin/apachectl start



stop apache


/usr/local/apache/bin/apachectl stop


restart apache


/usr/local/apache/bin/apachectl restart






2. install JAVA 2




RedHat Application CD

cd IBM

rpm -ivh IBMJava2-SDK-1.3-9.0.i386.rpm


cd /root

vi .bash_profile


add follow two lines:


JAVA_HOME=/opt/IBMJava2-13; export JAVA_HOME

PATH=$PATH:/opt/IBMJava2-13; export PATH


set PATH and JAVA_HOME for tomcat





3. install tomcat



tomcat 3.3.2



cd /usr/local

cp -rf /mnt/cdrom/jakarta-tomcat-3.3.2-dev.tar.gz ./

tar -zxf jakarta-tomcat-3.3.2-dev.tar.gz

mkdir tomcat

cd tomcat

cp -rf /usr/local/jakarta-3.3.2-dev/* ./

cd ..

rm -rf /usr/local/jakarta-tomcat-3.3.2-dev

cd tomca

cd bin

chmod 755 startup

chmod 755 tomcat

chmod 755 shutdown


./startup to start tomcat

./shutdown to stop tomcat



to open port 8080


prompt> ipchains -I input -j ACCEPT -p tcp -s 64.119.96.78 -d 64.119.96.77 8080

this command will not work

you must do:


prompt> setup


select firewall or prompt> lokkit[enter]

go to customize, on the line of "Other ports" put "webcache:tcp"

then type:

prompt> service ipchains restart




4.install MySQL



rpm -ivf /mnt/cdrom/MySQL-3.22.32-1.i386.rpm

rpm -ivf /mnt/cdrom/MySQL-client-3.22.32-1.i386.rpm


add password to root user:


/usr/bin/mysqladmin -u root password 'susan';



let 64.119.96.78 access MySQL on linux server as MySQL client


prompt> ipchains -I input -j ACCEPT -p tcp -s 64.119.96.78 -d 64.119.96.77 3306



3306 mysql's default tcp port number




About security of redhat linux





1. install



2. lokkit

3. netconfig[enter]?

4. rhn_register

5. up2date




?????????????????????????
after change the security rules:

ipchain restart
?????????????????????????



turn on ftp server (for ever)


  1. prompt>chkconfig wu-ftpd on
  2. check : prompt>ftp localhost


create WAR file for bustops




JAR -cvf ../deploy/emstops0.war *.*


Network Config

  • list all exist network interface: ifconfig
  • change IP: ifconfig eth0 664.119.96.78
  • assign nstmask: ifconfig eth0 netmask 255.255.255.248
  • stop network interface: ifconfig eth0 down
  • start network interface: ifconfig eth0 up
  • add default gateway: route add default gw 64.119.96.73





Add a User



  • add user on Linux Server: take nina as a example
  • add nina to www group password: ninatang
  • useradd -g www nina
  • vi ninapas
  • nina:ninatang
  • chpasswd < ninapas
  • change group the user belong to: usermod -g newgroup nina





latest update : July 22, 2002

Linux Command

I kept writing frequently used Linux command in files, and save them somewhere.
Then I found it dificult to find out them later.

Now I am starting to find them and put them here.


Linux Command
written by: YLast updated: Monday Oct. 27, 2008

find Linux kernel version
uname -mrsn

Uninstall MySQL 4.0.12
1.rpm -qagrep -i mysql
display:
MySQL-server-4.0.12-0MySQl-client-4.0.12-0
2.rpm -e MySQL-server-4.0.12-0
3.
rpm -e MySQL-client-4.0.12-0

usermod: enables the user to modify the information contained in the system account files
Example: To change user Ajita's home directory to /home/chemdept. enter
shell>usermod -d /home/chemdept ajita

Find the number of files in a Listing(directory)
$ls wc -l
49
$

Make a symbolic link to a file

# ln -s /etc/rc.d/init.d/catalina.sh /etc/rc.d/rc5.d/S81tomcat

delete the symbolic link

# unlink /etc/rc.d/rc5.d/S81tomcat

Find out run level
# runlevel