Menu Home

ubuntu下tomcat6的安装配置

Ubuntu下开发用tomcat安装配置
1.下载tomcat
http://tomcat.apache.org/index.html
2.安装tomcat

royakon@pangmei-royakon:~$ cp apache-tomcat-6.0.32.tar.gz ~/temp/
royakon@pangmei-royakon:~$ cd temp
royakon@pangmei-royakon:~/temp$ ls
apache-tomcat-6.0.32.tar.gz
royakon@pangmei-royakon:~/temp$ tar zxvf apache-tomcat-6.0.32.tar.gz
royakon@pangmei-royakon:~/temp$ ls
apache-tomcat-6.0.32  apache-tomcat-6.0.32.tar.gz
royakon@pangmei-royakon:~/temp$ mkdir ~/.tomcat6
royakon@pangmei-royakon:~/temp$ mkdir ~/tomcat6-www
royakon@pangmei-royakon:~/temp$ cp -r ./apache-tomcat-6.0.32/conf ~/.tomcat6
royakon@pangmei-royakon:~/temp$ cp -r ./apache-tomcat-6.0.32/logs ~/.tomcat6
royakon@pangmei-royakon:~/temp$ cp -r ./apache-tomcat-6.0.32/temp ~/.tomcat6
royakon@pangmei-royakon:~/temp$ cp -r ./apache-tomcat-6.0.32/work ~/.tomcat6
royakon@pangmei-royakon:~/temp$ cp -r ./apache-tomcat-6.0.32/webapps ~/tomcat6-www
royakon@pangmei-royakon:~/temp$ rm -r ./apache-tomcat-6.0.32/conf
royakon@pangmei-royakon:~/temp$ rm -r ./apache-tomcat-6.0.32/logs
royakon@pangmei-royakon:~/temp$ rm -r ./apache-tomcat-6.0.32/temp
royakon@pangmei-royakon:~/temp$ rm -r ./apache-tomcat-6.0.32/work
royakon@pangmei-royakon:~/temp$ rm -r ./apache-tomcat-6.0.32/webapps
royakon@pangmei-royakon:~/temp$ ln -s ~/.tomcat6/conf ./apache-tomcat-6.0.32/conf
royakon@pangmei-royakon:~/temp$ ln -s ~/.tomcat6/logs ./apache-tomcat-6.0.32/logs
royakon@pangmei-royakon:~/temp$ ln -s ~/.tomcat6/temp ./apache-tomcat-6.0.32/temp
royakon@pangmei-royakon:~/temp$ ln -s ~/.tomcat6/work ./apache-tomcat-6.0.32/work
royakon@pangmei-royakon:~/temp$ ln -s ~/tomcat6-www ./apache-tomcat-6.0.32/webapps
royakon@pangmei-royakon:~/temp$ sudo cp -r ./apache-tomcat-6.0.32 /opt/
royakon@pangmei-royakon:~/temp$ sudo ln -s /opt/apache-tomcat-6.0.32 /usr/local/tomcat6
royakon@pangmei-royakon:~/temp$ rm -r ./apache-tomcat-6.0.32

3.确认环境变量

royakon@pangmei-royakon:~$ gedit ~/.profile

添加以下的环境变量

# set sun jdk path
export JAVA_HOME="/usr/lib/jvm/java-6-sun"
export JRE_HOME="$JAVA_HOME/jre"
export PATH=".:$JAVA_HOME/bin:$PATH"
export CLASSPATH=".:/usr/lib/jvm/java-6-sun"

# set tomcat catalina base home
export CATALINA_HOME="/usr/local/tomcat6"

注销重新登录
4.配置tomcat-users.xml

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <!--host-manager role-->
  <role rolename="admin-gui"/>
  <role rolename="admin-script"/>
  <!--manager role-->
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <role rolename="manager-status"/>
  <role rolename="tomcat"/>
  <!--admin user-->
  <user username="admin" password="admin" roles="admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status,tomcat"/>
</tomcat-users>

5.启动tomcat

royakon@pangmei-royakon:~$ /usr/local/tomcat6/bin/startup.sh
Using CATALINA_BASE:   /usr/local/tomcat6
Using CATALINA_HOME:   /usr/local/tomcat6
Using CATALINA_TMPDIR: /usr/local/tomcat6/temp
Using JRE_HOME:        /usr/lib/jvm/java-6-sun/jre
Using CLASSPATH:       /usr/local/tomcat6/bin/bootstrap.jar

tomcat_install

royakon@pangmei-royakon:~$ /usr/local/tomcat6/bin/shutdown.sh
Using CATALINA_BASE:   /usr/local/tomcat6
Using CATALINA_HOME:   /usr/local/tomcat6
Using CATALINA_TMPDIR: /usr/local/tomcat6/temp
Using JRE_HOME:        /usr/lib/jvm/java-6-sun/jre
Using CLASSPATH:       /usr/local/tomcat6/bin/bootstrap.jar

6.关于APR警告信息

2007-07-12 19:24:32 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: ……

ubuntu下非常好解决,安装库文件即可.

royakon@pangmei-royakon:~$ sudo apt-update
royakon@pangmei-royakon:~$ sudo apt-get install libtcnative-1

Categories: ubuntu

Tagged as:

RoyAkon