Part I. JDK安装与测试
1>jdk安装:
[sense@ssn ~]$ chmod 777 jdk-6u3-linux-i586.bin
[sense@ssn ~]$ ./jdk-6u3-linux-i586.bin
[sense@ssn ~]$ mv jdk1.6.0_03/ /opt/jdk
2>环境变量设置
[root@ssn ~]# vi /etc/profile.d/java.sh
或
[root@ssn ~]# vi ~/.bashrc
------------------------------------------------------------------
export JAVA_HOME=/opt/jdk
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
------------------------------------------------------------------
[root@ssn ~]# chmod 755 /etc/profile.d/java.sh
[root@ssn ~]# . /etc/profile
[root@ssn ~]# java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
3>测试java程序
[sense@ssn ~]$ vi test.java
-------------------------------------------------
public class test {
public static void main(String args[]) {
System.out.println("Hello World!");
}
}
--------------------------------------------------
[sense@ssn ~]$ javac test.java
[sense@ssn ~]$ java test
Hello World!
Part II. Resin安装与配置
1>安装resion
[sense@ssn Desktop]$ tar xzvf resin-3.1.4.tar.gz
[sense@ssn Desktop]$ mv resin-3.1.4 /opt/resin/
[sense@ssn Desktop]$ cd /opt/resin/
[sense@ssn resin]$ ./configure --with-apache=/usr/local/apache2/
[sense@ssn resin]$ make
[sense@ssn resin]$ sudo make install
[root@ssn resin]# mv /usr/local/apache2/modules/mod_caucho /usr/local/apache2/modules/mod_caucho.so
2>配置环境变量
[sense@ssn resin]# vi /etc/profile.d/resin.sh
-------------------------------
export RESIN_HOME=/opt/resin
-------------------------------
[sense@ssn resin]# . /etc/profile
[sense@ssn resin]# echo $RESIN_HOME
/opt/resin
3>配置resin开机启动
[root@ssn resin]# cp contrib/init.resin /etc/init.d/resin
注释掉启动脚本中的关于环境变量的信息:
[root@ssn resin]# vi /etc/init.d/resin
-----------------------------------------
#JAVA_HOME=/usr
#RESIN_HOME=/opt/resin
#export JAVA_HOME RESIN_HOME
-----------------------------------------
[root@ssn resin]# chkconfig resin reset
[root@ssn resin]# chkconfig --list resin
resin 0:off 1:off 2:off 3:on 4:on 5:on 6:off
Part III. TOMCAT基本配置
1>安装tomcat
[sense@ssn Desktop]$ tar xzvf apache-tomcat-6.0.14.tar.gz
[sense@ssn Desktop]$ sudo mv apache-tomcat-6.0.14 /opt/tomcat
2>测试tomcat
[sense@ssn tomcat]$ vi webapps/ROOT/hh.jsp
-----------------------------------
<%
out.println("hello world!");
%>
-----------------------------------
[sense@ssn tomcat]$ ./bin/startup.sh
firefox:
[url]http://192.168.1.90:8080[/url]
[url]http://192.168.1.90:8080/hh.jsp[/url]
3>配置tomcat WEB管理用户
[sense@ssn tomcat]$ vi conf/tomcat-users.xml
--------------------------------------------------------------------------
--------------------------------------------------------------------------
4>配置tomcat开机启动
安装启动daemon程序:
[sense@ssn tomcat]$ cd bin/
[sense@ssn bin]$ tar xzvf jsvc.tar.gz
[sense@ssn bin]$ cd jsvc-src/
[sense@ssn jsvc-src]$ sh support/buildconf.sh
support/buildconf.sh: configure script generated successfully
[sense@ssn jsvc-src]$ chmod 777 configure
[sense@ssn jsvc-src]$ ./configure --with-java=/opt/jdk/
注:此处configure时需要加上jdk路径,否则无法使用普通用户开机自动启动tomcat。
[sense@ssn jsvc-src]$ make
[sense@ssn jsvc-src]$ vi native/Tomcat5.sh
将启动脚本修改成:
-----------------------------------------------------------------------------------
#!/bin/sh
##############################################################################
#
# Copyright 2004 The Apache Software Foundation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# [url]http://www.apache.org/licenses/LICENSE-2.0[/url]
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##############################################################################
#
# Small shell script to show how to start/stop Tomcat using jsvc
# If you want to have Tomcat running on port 80 please modify the server.xml
# file:
#
#
## port="80" minProcessors="5" maxProcessors="75"
# enableLookups="true" redirectPort="8443"
# acceptCount="10" debug="0" connectionTimeout="60000"/>
#
# That is for Tomcat-5.0.x (Apache Tomcat/5.0)
# chkconfig: 2345 85 15
# description: apache-tomcat.6
#
# Adapt the following lines to your configuration
JAVA_HOME=/opt/jdk
CATALINA_HOME=/opt/tomcat
DAEMON_HOME=/opt/tomcat/bin
TOMCAT_USER=tomcat
# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/jsvc.pid
CATALINA_BASE=/opt/tomcat
#CATALINA_OPTS="-Djava.library.path=/home/jfclere/jakarta-tomcat-connectors/jni/native/.libs"
CATALINA_OPTS=
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar
case "$1" in
start)
#
# Start Tomcat
#
$DAEMON_HOME/jsvc-src/jsvc \
-user $TOMCAT_USER \
-home $JAVA_HOME \
-Dcatalina.home=$CATALINA_HOME \
-Dcatalina.base=$CATALINA_BASE \
-Djava.io.tmpdir=$TMP_DIR \
-wait 10 \
-pidfile $PID_FILE \
-outfile $CATALINA_HOME/logs/catalina.out \
-errfile '&1' \
$CATALINA_OPTS \
-cp $CLASSPATH \
org.apache.catalina.startup.Bootstrap
#
# To get a verbose JVM
#-verbose \
# To get a debug of jsvc.
#-debug \
exit $?
;;
stop)
#
# Stop Tomcat
#
$DAEMON_HOME/jsvc-src/jsvc \
-stop \
-pidfile $PID_FILE \
org.apache.catalina.startup.Bootstrap
exit $?
;;
*)
echo "Usage tomcat.sh start/stop"
exit 1;;
esac
-----------------------------------------------------------------------------------
[sense@ssn jsvc-src]$ sudo cp native/Tomcat5.sh /etc/init.d/tomcat
[sense@ssn jsvc-src]$ sudo chmod 755 /etc/init.d/tomcat
[sense@ssn jsvc-src]$ su -
[root@ssn ~]# chkconfig tomcat reset
[root@ssn ~]# chkconfig --list tomcat
tomcat 0:off 1:off 2:on 3:on 4:on 5:on 6:off
配置tomcat开机启动用户:
[root@ssn opt]# groupadd tomcat
[root@ssn opt]# useradd -g tomcat -s /sbin/nologin -d /dev/null tomcat
[root@ssn opt]# chown -R tomcat:tomcat /opt/tomcat/
测试tomcat运行:
[root@ssn bin]# service tomcat start
[root@ssn bin]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 2233/nasd
tcp 0 0 192.168.1.90:53 0.0.0.0:* LISTEN 3586/named
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 3586/named
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 3586/named
tcp 0 0 :::8009 :::* LISTEN 3898/jsvc.exec
tcp 0 0 :::8080 :::* LISTEN 3898/jsvc.exec
tcp 0 0 :::80 :::* LISTEN 32547/httpd
udp 0 0 0.0.0.0:33447 0.0.0.0:* 3586/named
udp 0 0 192.168.1.90:53 0.0.0.0:* 3586/named
udp 0 0 127.0.0.1:53 0.0.0.0:* 3586/named
udp 0 0 :::33448 :::* 3586/named
Part IV. tomcat与apache整合
1>安装mod_jk2
jk2模块通过httpd把jsp等的web请求转发给tomcat,实现不同的文件由不同的解释器解析。
[url]http://archive.apache.org/dist/tomcat/tomcat-connectors/jk2/binaries/linux/[/url]
[root@ssn Desktop]# tar xzvf Fedora-Core-1-i386
[root@ssn Fedora-Core-1-i386]# cd Fedora-Core-1-i386
[root@ssn Fedora-Core-1-i386]# cp etc/httpd/conf/workers2.properties /usr/local/apache2/conf
[root@ssn Fedora-Core-1-i386]# cat etc/httpd/conf.d/jk2.conf
------------------------------------------------------------
#
# JK2 is the Apache/Tomcat connector
#
LoadModule jk2_module modules/mod_jk2.so
JkSet config.file /etc/httpd/conf/workers2.properties
------------------------------------------------------------
[root@ssn Fedora-Core-1-i386]# vi /usr/local/apache2/conf/httpd.conf
将jk2.conf的内容加在此文件后。
[root@ssn Fedora-Core-1-i386]# cp usr/lib/httpd/modules/* /usr/local/apache2/modules/
2>测试mod_jk2
[sense@ssn Fedora-Core-1-i386]$ cd /usr/local/apache2/
[sense@ssn apache2]$ ./bin/apachectl -t
httpd: Syntax error on line 444 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/mod_jk2.so into server: /usr/local/apache2/modules/mod_jk2.so: undefined symbol: apr_pool_get_parent
出错提示mod_jk2.so与当前的apache不兼容,所以需要手工编译mod_jk2.so模块。
3>工手编译mod_jk2模块
到[url]http://archive.apache.org/dist/tomcat/tomcat-connectors/jk2/source/[/url]下载新版本的mod_jk2.so源代码。
[sense@ssn Desktop]$ tar xzvf jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz
[sense@ssn Desktop]$ cd jakarta-tomcat-connectors-jk2-2.0.4-src
[sense@ssn jakarta-tomcat-connectors-jk2-2.0.4-src]$ cd jk/native2/
[sense@ssn native2]$ ./configure --with-apxs2=/usr/local/apache2/bin/apxs
[sense@ssn native2]$ make
[sense@ssn native2]$ cd ../build/jk2/apache2/
[sense@ssn apache2]$ sudo cp mod_jk2.so /usr/local/apache2/modules/
4>测试新的mod_jk2
[sense@ssn apache2]$ cd /usr/local/apache2/
[sense@ssn apache2]$ ./bin/apachectl -t
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Syntax OK
[sense@ssn apache2]$ sudo ./bin/apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
5>测试PHP/JSP文件
[url]http://192.168.1.90/[/url]
[url]http://192.168.1.90:8080/[/url]
1>jdk安装:
[sense@ssn ~]$ chmod 777 jdk-6u3-linux-i586.bin
[sense@ssn ~]$ ./jdk-6u3-linux-i586.bin
[sense@ssn ~]$ mv jdk1.6.0_03/ /opt/jdk
2>环境变量设置
[root@ssn ~]# vi /etc/profile.d/java.sh
或
[root@ssn ~]# vi ~/.bashrc
------------------------------------------------------------------
export JAVA_HOME=/opt/jdk
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
------------------------------------------------------------------
[root@ssn ~]# chmod 755 /etc/profile.d/java.sh
[root@ssn ~]# . /etc/profile
[root@ssn ~]# java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
3>测试java程序
[sense@ssn ~]$ vi test.java
-------------------------------------------------
public class test {
public static void main(String args[]) {
System.out.println("Hello World!");
}
}
--------------------------------------------------
[sense@ssn ~]$ javac test.java
[sense@ssn ~]$ java test
Hello World!
Part II. Resin安装与配置
1>安装resion
[sense@ssn Desktop]$ tar xzvf resin-3.1.4.tar.gz
[sense@ssn Desktop]$ mv resin-3.1.4 /opt/resin/
[sense@ssn Desktop]$ cd /opt/resin/
[sense@ssn resin]$ ./configure --with-apache=/usr/local/apache2/
[sense@ssn resin]$ make
[sense@ssn resin]$ sudo make install
[root@ssn resin]# mv /usr/local/apache2/modules/mod_caucho /usr/local/apache2/modules/mod_caucho.so
2>配置环境变量
[sense@ssn resin]# vi /etc/profile.d/resin.sh
-------------------------------
export RESIN_HOME=/opt/resin
-------------------------------
[sense@ssn resin]# . /etc/profile
[sense@ssn resin]# echo $RESIN_HOME
/opt/resin
3>配置resin开机启动
[root@ssn resin]# cp contrib/init.resin /etc/init.d/resin
注释掉启动脚本中的关于环境变量的信息:
[root@ssn resin]# vi /etc/init.d/resin
-----------------------------------------
#JAVA_HOME=/usr
#RESIN_HOME=/opt/resin
#export JAVA_HOME RESIN_HOME
-----------------------------------------
[root@ssn resin]# chkconfig resin reset
[root@ssn resin]# chkconfig --list resin
resin 0:off 1:off 2:off 3:on 4:on 5:on 6:off
Part III. TOMCAT基本配置
1>安装tomcat
[sense@ssn Desktop]$ tar xzvf apache-tomcat-6.0.14.tar.gz
[sense@ssn Desktop]$ sudo mv apache-tomcat-6.0.14 /opt/tomcat
2>测试tomcat
[sense@ssn tomcat]$ vi webapps/ROOT/hh.jsp
-----------------------------------
<%
out.println("hello world!");
%>
-----------------------------------
[sense@ssn tomcat]$ ./bin/startup.sh
firefox:
[url]http://192.168.1.90:8080[/url]
[url]http://192.168.1.90:8080/hh.jsp[/url]
3>配置tomcat WEB管理用户
[sense@ssn tomcat]$ vi conf/tomcat-users.xml
--------------------------------------------------------------------------
--------------------------------------------------------------------------
4>配置tomcat开机启动
安装启动daemon程序:
[sense@ssn tomcat]$ cd bin/
[sense@ssn bin]$ tar xzvf jsvc.tar.gz
[sense@ssn bin]$ cd jsvc-src/
[sense@ssn jsvc-src]$ sh support/buildconf.sh
support/buildconf.sh: configure script generated successfully
[sense@ssn jsvc-src]$ chmod 777 configure
[sense@ssn jsvc-src]$ ./configure --with-java=/opt/jdk/
注:此处configure时需要加上jdk路径,否则无法使用普通用户开机自动启动tomcat。
[sense@ssn jsvc-src]$ make
[sense@ssn jsvc-src]$ vi native/Tomcat5.sh
将启动脚本修改成:
-----------------------------------------------------------------------------------
#!/bin/sh
##############################################################################
#
# Copyright 2004 The Apache Software Foundation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# [url]http://www.apache.org/licenses/LICENSE-2.0[/url]
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##############################################################################
#
# Small shell script to show how to start/stop Tomcat using jsvc
# If you want to have Tomcat running on port 80 please modify the server.xml
# file:
#
#
#
# enableLookups="true" redirectPort="8443"
# acceptCount="10" debug="0" connectionTimeout="60000"/>
#
# That is for Tomcat-5.0.x (Apache Tomcat/5.0)
# chkconfig: 2345 85 15
# description: apache-tomcat.6
#
# Adapt the following lines to your configuration
JAVA_HOME=/opt/jdk
CATALINA_HOME=/opt/tomcat
DAEMON_HOME=/opt/tomcat/bin
TOMCAT_USER=tomcat
# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/jsvc.pid
CATALINA_BASE=/opt/tomcat
#CATALINA_OPTS="-Djava.library.path=/home/jfclere/jakarta-tomcat-connectors/jni/native/.libs"
CATALINA_OPTS=
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar
case "$1" in
start)
#
# Start Tomcat
#
$DAEMON_HOME/jsvc-src/jsvc \
-user $TOMCAT_USER \
-home $JAVA_HOME \
-Dcatalina.home=$CATALINA_HOME \
-Dcatalina.base=$CATALINA_BASE \
-Djava.io.tmpdir=$TMP_DIR \
-wait 10 \
-pidfile $PID_FILE \
-outfile $CATALINA_HOME/logs/catalina.out \
-errfile '&1' \
$CATALINA_OPTS \
-cp $CLASSPATH \
org.apache.catalina.startup.Bootstrap
#
# To get a verbose JVM
#-verbose \
# To get a debug of jsvc.
#-debug \
exit $?
;;
stop)
#
# Stop Tomcat
#
$DAEMON_HOME/jsvc-src/jsvc \
-stop \
-pidfile $PID_FILE \
org.apache.catalina.startup.Bootstrap
exit $?
;;
*)
echo "Usage tomcat.sh start/stop"
exit 1;;
esac
-----------------------------------------------------------------------------------
[sense@ssn jsvc-src]$ sudo cp native/Tomcat5.sh /etc/init.d/tomcat
[sense@ssn jsvc-src]$ sudo chmod 755 /etc/init.d/tomcat
[sense@ssn jsvc-src]$ su -
[root@ssn ~]# chkconfig tomcat reset
[root@ssn ~]# chkconfig --list tomcat
tomcat 0:off 1:off 2:on 3:on 4:on 5:on 6:off
配置tomcat开机启动用户:
[root@ssn opt]# groupadd tomcat
[root@ssn opt]# useradd -g tomcat -s /sbin/nologin -d /dev/null tomcat
[root@ssn opt]# chown -R tomcat:tomcat /opt/tomcat/
测试tomcat运行:
[root@ssn bin]# service tomcat start
[root@ssn bin]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 2233/nasd
tcp 0 0 192.168.1.90:53 0.0.0.0:* LISTEN 3586/named
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 3586/named
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 3586/named
tcp 0 0 :::8009 :::* LISTEN 3898/jsvc.exec
tcp 0 0 :::8080 :::* LISTEN 3898/jsvc.exec
tcp 0 0 :::80 :::* LISTEN 32547/httpd
udp 0 0 0.0.0.0:33447 0.0.0.0:* 3586/named
udp 0 0 192.168.1.90:53 0.0.0.0:* 3586/named
udp 0 0 127.0.0.1:53 0.0.0.0:* 3586/named
udp 0 0 :::33448 :::* 3586/named
Part IV. tomcat与apache整合
1>安装mod_jk2
jk2模块通过httpd把jsp等的web请求转发给tomcat,实现不同的文件由不同的解释器解析。
[url]http://archive.apache.org/dist/tomcat/tomcat-connectors/jk2/binaries/linux/[/url]
[root@ssn Desktop]# tar xzvf Fedora-Core-1-i386
[root@ssn Fedora-Core-1-i386]# cd Fedora-Core-1-i386
[root@ssn Fedora-Core-1-i386]# cp etc/httpd/conf/workers2.properties /usr/local/apache2/conf
[root@ssn Fedora-Core-1-i386]# cat etc/httpd/conf.d/jk2.conf
------------------------------------------------------------
#
# JK2 is the Apache/Tomcat connector
#
LoadModule jk2_module modules/mod_jk2.so
JkSet config.file /etc/httpd/conf/workers2.properties
------------------------------------------------------------
[root@ssn Fedora-Core-1-i386]# vi /usr/local/apache2/conf/httpd.conf
将jk2.conf的内容加在此文件后。
[root@ssn Fedora-Core-1-i386]# cp usr/lib/httpd/modules/* /usr/local/apache2/modules/
2>测试mod_jk2
[sense@ssn Fedora-Core-1-i386]$ cd /usr/local/apache2/
[sense@ssn apache2]$ ./bin/apachectl -t
httpd: Syntax error on line 444 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/mod_jk2.so into server: /usr/local/apache2/modules/mod_jk2.so: undefined symbol: apr_pool_get_parent
出错提示mod_jk2.so与当前的apache不兼容,所以需要手工编译mod_jk2.so模块。
3>工手编译mod_jk2模块
到[url]http://archive.apache.org/dist/tomcat/tomcat-connectors/jk2/source/[/url]下载新版本的mod_jk2.so源代码。
[sense@ssn Desktop]$ tar xzvf jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz
[sense@ssn Desktop]$ cd jakarta-tomcat-connectors-jk2-2.0.4-src
[sense@ssn jakarta-tomcat-connectors-jk2-2.0.4-src]$ cd jk/native2/
[sense@ssn native2]$ ./configure --with-apxs2=/usr/local/apache2/bin/apxs
[sense@ssn native2]$ make
[sense@ssn native2]$ cd ../build/jk2/apache2/
[sense@ssn apache2]$ sudo cp mod_jk2.so /usr/local/apache2/modules/
4>测试新的mod_jk2
[sense@ssn apache2]$ cd /usr/local/apache2/
[sense@ssn apache2]$ ./bin/apachectl -t
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Syntax OK
[sense@ssn apache2]$ sudo ./bin/apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
5>测试PHP/JSP文件
[url]http://192.168.1.90/[/url]
[url]http://192.168.1.90:8080/[/url]