器量大者,福泽必厚
全部博文(587)
分类: LINUX
2010-06-11 10:54:11
Keep in mind, however, that Apache
httpd may not be more efficient at serving your content than Tomcat standalone is. Tomcat’s web server is highly optimized, and today’s Java runtimes are very good at natively compiling Tomcat so that the resulting binary it is running is also highly optimizedfor your operating system andarchitecture.Configuring Tomcat so that all of its requests must first travel through Apache httpd may actually slow down Tomcat’s response times, and it is usually the performance of the dynamic content that web server administrators need to improve.1:下载native, 它编译时需要apr、openssl、jdk
如下:
Build tc-native requires three components to be installed:
APR library
OpenSSL libraries
Java SE Development Kit (JDK)
2:我下定apr为apr-1.3.8.tar.bz2
安装如下:
[root@localhost apr-1.3.8]# ./configure --prefix=/opt/apr
[root@localhost apr-1.3.8]# make && make install
3:openssl一般系统默认都已经安装,自己就不需要安装了。
是否已经安装可以用下面的命令来取证:
[root@localhost bin]# which openssl #测试是否安装了openssl
/usr/bin/openssl
4:安装jdk, 一般下载二进制版本,直接运行即可。我把jdk安装在/usr/local/jdk目录下,并进行java路径配置。
我的配置如下:
[root@localhost logs]# cd
[root@localhost ~]# cat .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
#红色字体为添加部分
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export CATALINA_HOME=/opt/tomcat5.5 ##我打算把tomat安装在/opt目录下
5:安装tomcat, 我下载的为apache-tomcat-5.5.26.tar.gz
直接:
[root@localhost software]#tar zxvf apache-tomcat-5.5.26.tar.gz -C /opt
[root@localhost software]#cd /opt
[root@localhost software]#ln -s apache-tomcat-5.5.26 tomcat5.5
6:安装native, 我下载的为tomcat-native-1.1.20-src.tar.gz
安装方法如下:
[root@localhost software]# tar zxvf tomcat-native-1.1.20-src.tar.gz
[root@localhost native]# ./configure --with-apr=/opt/apr/bin/apr-1-config --with-java-home=/usr/local/jdk --with-ssl=yes --prefix=/opt/tomcat5.5/
[root@localhost native]# make
[root@localhost native]# make install
make[1]: Entering directory `/home/software/tomcat-native-1.1.20-src/jni/native'
make[1]: Nothing to be done for `local-all'.
make[1]: Leaving directory `/home/software/tomcat-native-1.1.20-src/jni/native'
/opt/apr/build-1/mkdir.sh /opt/tomcat5.5//include/apr-1 /opt/tomcat5.5//lib/pkgconfig \
/opt/tomcat5.5//lib /opt/tomcat5.5//bin
mkdir /opt/tomcat5.5/include
mkdir /opt/tomcat5.5/include/apr-1
mkdir /opt/tomcat5.5/lib
mkdir /opt/tomcat5.5/lib/pkgconfig
/usr/bin/install -c -m 644 tcnative.pc /opt/tomcat5.5//lib/pkgconfig/tcnative-1.pc
list=''; for i in $list; do \
( cd $i ; make DESTDIR= install ); \
done
/bin/sh /opt/apr/build-1/libtool --mode=install /usr/bin/install -c -m 755 libtcnative-1.la /opt/tomcat5.5//lib
/usr/bin/install -c -m 755 .libs/libtcnative-1.so.0.1.20 /opt/tomcat5.5//lib/libtcnative-1.so.0.1.20
(cd /opt/tomcat5.5//lib && { ln -s -f libtcnative-1.so.0.1.20 libtcnative-1.so.0 || { rm -f libtcnative-1.so.0 && ln -s libtcnative-1.so.0.1.20 libtcnative-1.so.0; }; })
(cd /opt/tomcat5.5//lib && { ln -s -f libtcnative-1.so.0.1.20 libtcnative-1.so || { rm -f libtcnative-1.so && ln -s libtcnative-1.so.0.1.20 libtcnative-1.so; }; })
/usr/bin/install -c -m 755 .libs/libtcnative-1.lai /opt/tomcat5.5//lib/libtcnative-1.la
/usr/bin/install -c -m 755 .libs/libtcnative-1.a /opt/tomcat5.5//lib/libtcnative-1.a
chmod 644 /opt/tomcat5.5//lib/libtcnative-1.a
ranlib /opt/tomcat5.5//lib/libtcnative-1.a
PATH="$PATH:/sbin" ldconfig -n /opt/tomcat5.5//lib
----------------------------------------------------------------------
Libraries have been installed in: ##通过此信息显然native安装成功
/opt/tomcat5.5//lib
显然去/opt/tomcat5.5目录下 ,你会发现多了一个lib目录
7:仅仅这样还是不行,还需要如下配置:
文档:
Edit $CATALINA_HOME/bin/setenv.sh (creating the file if necessary) and add the path to the tc-native libraries to LD_LIBRARY_PATH. Something like:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_HOME/lib
export LD_LIBRARY_PATH