Chinaunix首页 | 论坛 | 博客
  • 博客访问: 343198
  • 博文数量: 64
  • 博客积分: 2301
  • 博客等级: 大尉
  • 技术积分: 570
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-25 11:48
文章分类

全部博文(64)

文章存档

2013年(5)

2012年(6)

2011年(36)

2010年(7)

2009年(10)

分类: LINUX

2011-06-16 07:28:53


1.jdk的安装
tomcat7需要使用jdk6
wget
cd /opt
cp jdk-6u25-linux-i586.bin  ./
./jdk-6u25-linux-i586.bin
vi /etc/profile 在最后添加如下行
export JAVA_HOME=/opt/jdk1.6.0_25
export JRE_HOME=$JAVA_HOME/jre
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=./:/opt/jdk1.6.0_25/lib:/opt/jdk1.6.0_25/jre/lib
如果要是设置立刻生效运行如下命令
source /etc/profile
2.tomcat的安装设置
 wget
 tar -xzvf apache-tomcat-7.0.14-deployer.tar.gz
 mv apache-tomcat-7.0.14-deployer tomcat
 setup
Tomcat can be run as a daemon using the jsvc tool from the commons-daemon project.
cd ./bin
tar -xzvf commons-daemon-native.tar.gz
cd commons-daemon-1.0.5-native-src/unix
./configure
如果出现如下报错:
configure: error: Java Home not defined. Rerun with --with-java=... parameter
solution:
export JAVA_HOME=/opt/jdk1.6.0_25
make
cp jsvc ../..
cd ../..
Tomcat can then be run as a daemon using the following commands.
cd $CATALINA_HOME
    ./bin/jsvc -cp ./bin/bootstrap.jar:./bin/tomcat-juli.jar \
        -outfile ./logs/catalina.out -errfile ./logs/catalina.err \
        org.apache.catalina.startup.Bootstrap
#################################################################
tomcat开机自启
cd /opt/tomcat/bin/commons-daemon-1.0.5-native-src/unix/samples
cp   Tomcat7.sh /etc/init.d/tomcat.sh
vi tomcat.sh 添加如下:
JAVA_HOME=/opt/jdk1.6.0_25
TOMCAT_HOME=/opt/tomcat
JRE_HOME=$JAVA_HOME/jre
CATALINA_HOME=/opt/tomcat
CATALINA_BASE=$CATALINA_HOME
chkconfig --add tomcat
报错:tomcat 服务不支持 chkconfig
在tomat添加如下
#chkconfig: 345 80 90
#description:auto_run
#########cp  Tomcat7.sh  ./bin  可以直接使用#######
#################################################################
Once you have configured the catalina.policy file for use with a SecurityManager, Tomcat can be started with a SecurityManager in place by using the "-security" option:
$CATALINA_HOME/bin/catalina.sh start -security    (Unix)
%CATALINA_HOME%\bin\catalina start -security      (Windows)
4.代理设置
Apache 1.3 Proxy Support
确保 apache的proxy模块安装
1.Configure your copy of Apache so that it includes the mod_proxy module. If you are building from source,
the easiest way to do this is to include the --enable-module=proxy directive on the ./configure command line.
2.If not already added for you, make sure that you are loading the mod_proxy module at Apache startup time, by using the following directives in your httpd.conf file:
LoadModule proxy_module  {path-to-modules}/mod_proxy.so
AddModule  mod_proxy.c
3.Include two directives in your httpd.conf file for each web application that you wish to forward to Tomcat.
For example, to forward an application at context path /myapp:
ProxyPass         /myapp 
ProxyPassReverse  /myapp 
which tells Apache to forward URLs of the form * to the Tomcat connector listening on port 8081.
4.Configure your copy of Tomcat to include a special element, with appropriate proxy settings, for example:
              proxyName=""
              proxyPort="80"/>
which will cause servlets inside this web application to think that all proxied requests were directed to on port 80.
5.It is legal to omit the proxyName attribute from the element. If you do so, the value returned by request.getServerName()
will by the host name on which Tomcat is running. In the example above, it would be localhost.
6.If you also have a listening on port 8080 (nested within the same Service element), the requests to either port will share the same set of virtual hosts and web applications.

虚拟主机的配置
vi  server.xml 在下一行添加如下

   
   
note:绑定ip地址

"8080" address="192.168.1.123" redirectPort="8443" acceptCount="100"  disableUploadTimeout="true"/>

mkdir $CATALINA_HOME/testapps
mkdir $CATALINA_HOME/abcapps
vi /etc/hosts
添加如下:
yourserverip    
yourserverip    
修改本地host文件
在运行中输入 drivers 然后打开etc目录在hosts文件添加如下
yourserverip    
yourserverip    
注:如果在运营环境不需要修改hosts文件dns会提供解析,这里为了测试方便,作此修改。
新修改的目录下默认须建ROOT目录,原因如下: 
Contexts are normally located underneath the appBase directory. For example, to deploy the foobar context as a war file in the ren host,
use $CATALINA_HOME/renapps/foobar.war. Note that the default or ROOT context for ren would be deployed as $CATALINA_HOME/renapps/ROOT.war (WAR) or $CATALINA_HOME/renapps/ROOT (directory).
修改默认根路径:
下添加如下

一般我们用Context来覆盖Host的appBase的设定而不是直接修改appBase.
第一个Context用了path="", 如果path=""(注意不是path="/"),则相当于是这个Host的虚拟根目录,docBase则指出了物理目录的位置(可以是绝对也可以是相对于Host的appBase的位置),如果你访问 则会使用/mnt/vivimob/里的内容。
第二个Context用了path="/xyz",如果你访问 则会使用/mnt/test/里的内容。
数据库连接配置
        reloadable="true" crossContext="true">
   
   
   
   
   
   
   
                 maxActive="100" maxIdle="30" maxWait="10000"
               username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver"
               url="jdbc:mysql://localhost:3306/javatest"/>
web.xml配置
    xmlns:xsi=""
    xsi:schemaLocation="
"
    version="2.4">
  MySQL Test App
 
      DB Connection
      jdbc/TestDB
      javax.sql.DataSource
      Container
 

tomcat默认浏览的页面的修改
vi   ./conf/web.xml  在文件最后修改如下,修改默认网页。

        index.html
        index.htm
        index.jsp
   
 
 
 
 
 
 

 
阅读(2460) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~