傻子一個

          一路走來~~

           

          ubuntu8.04 下安裝tomcat6,并開機自啟動

          整合網(wǎng)絡(luò)上的各種零散的資料,并經(jīng)過本人的實踐操作,整理,轉(zhuǎn)載請注明出處。

          1.安裝jdk6

                 shell>sudo apt-get install sun-java6-jdk(用新得立軟件包安裝)

          2.下載tomcat6

                 下載地址是:http://tomcat.apache.org/

                 本次安裝的是:apache-tomcat-6.0.18.tar.gz

          3.安裝

                 將壓縮包拷貝到 /opt 下(個人喜好,可以放在別處)

                        shell>sudo cp apache-tomcat-6.0.18.tar.gz /opt

                 解壓文件

                        shell>cd /opt

                        shell>sudo tar zxvf apache-tomcat-6.0.18.tar.gz

                 解壓完成后,會在 /opt 下生文件夾 apache-tomcat-6.0.18

                 為了操作方便,在/usr/local 下建立軟鏈接,名字是tomcat6

                        shell>cd /usr/local

          shell>sudo ln -s /opt/apache-tomcat-6.0.18 tomcat6

                 測試tomcat是否能夠正常啟動

                        shell>sudo /usr/local/tomcat6/bin/startup.sh

                        打開firefox,輸入http://localhost:8080,如果正常訪問,則表示成功。

          4.設(shè)置tomcat開機自啟動

                 根據(jù)tomcat官方的document說明,linux下設(shè)置開機自啟動可以使用jsvctomcat包里自帶)

                 設(shè)置tomcat以獨立的用戶運行(防止以root運行,權(quán)限太大)

                        shell>sudo useradd -d /usr/local/tomcat6 -s /usr/sbin/nologin tomcat

                        上邊的這個命令是添加一個系統(tǒng)用戶tomcat,并且設(shè)置為不可登錄系統(tǒng)。

                 設(shè)置用戶tomcat tomcat6的訪問權(quán)限

                        shell>sudo chown -R tomcat:tomcat /usr/local/tomcat6

                        shell>sudo chown -R tomcat:tomcat /opt/apache-tomcat-6.0.18

                 安裝jsvc

                        前提需要系統(tǒng)安裝了gcc(系統(tǒng)一般默認安裝)autoconflibc6-dev

                               shell>sudo apt-get install .....

                        解壓jsvc.tar.gz,并準備編譯

                               shell>cd /usr/local/tomcat6/bin

                               shell>sudo tar zxvf jsvc.tar.gz

                               shell>cd jsvc-src

                               shell>sudo sh support/buildconf.sh

                               如果成功,命令終端會打出:

                                      support/buildconf.sh: configure script generated successfully

                        configure添加執(zhí)行權(quán)限

                               shell>sudo chmod 755 configure

                        編譯     

                               shell>sudo ./configure –with-java=/usr/lib/jvm/java-6-sun (java的安裝路徑)

                               shell>sudo make

                                如果沒有出現(xiàn)錯誤,jsvc就安裝成功了。

                        設(shè)置啟動腳本

                               拷貝jsvc帶的tomcat5.sh 腳本拷貝到 /etc/init.d/ 下,并改名為tomcat

                               shell>sudo cp /usr/local/tomcat6/bin/jsvc-src/native/Tomcat5.sh /etc/init.d/tomcat

                         修改/etc/init.d/tomcat文件

                               shell>sudo gedit /etc/init.d/tomcat

           

                        文件內(nèi)容如下(修改的地方有顏色和注釋說明):

          #!/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

          #

          #       http://www.apache.org/licenses/LICENSE-2.0

          #

          #   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:

          #

          #    <!-- Define a non-SSL HTTP/1.1 Connector on port 80 -->

          #    <Connector className="org.apache.catalina.connector.http.HttpConnector"

          #               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)

          #

          # Adapt the following lines to your configuration

          JAVA_HOME=/usr/lib/jvm/java-6-sun               #這個地方設(shè)置為機器的jdk的位置

          CATALINA_HOME=/usr/local/tomcat6            #tomcat的安裝位置(軟鏈接)

          DAEMON_HOME=/usr/local/tomcat6/bin       #tomcat啟動程序的位置

          TOMCAT_USER=tomcat                                  #tomcat 的用戶

           

           

          # for multi instances adapt those lines.

          TMP_DIR=/var/tmp

          PID_FILE=/var/run/jsvc.pid

          CATALINA_BASE=/usr/local/tomcat6             #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:\

          $CATALINA_HOME/bin/bootstrap.jar

           

           

          case "$1" in

            start)

              #

              # Start Tomcat

              #

              $DAEMON_HOME/jsvc-src/jsvc \                #設(shè)置正確的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 \                      #設(shè)置正確的jsvc程序的位置

              -stop \

              -pidfile $PID_FILE \

              org.apache.catalina.startup.Bootstrap

              exit $?

              ;;

           

           

            *)

              echo "Usage tomcat.sh start/stop"

              exit 1;;

          esac

           

                 設(shè)置 /etc/init.d/tomcat的可執(zhí)行權(quán)限

                        Shell>sudo chmod 755 /etc/init.d/tomcat

          /etc/rc2.d/下設(shè)置一個/etc/init.d/tomcat 的軟鏈接

                        shell>cd /etc/rc2.d/

                        shell>sudo ln -s /etc/init.d/tomcat S16tomcat

                        [:rc2.d目錄下的文件要以S后就數(shù)字開頭,表示啟動的順序。而rc2.d中的2,表示這個目錄下文件在開機時的運行級別(runlevel)2]

           

          5.結(jié)束

                 重新啟動系統(tǒng) shell>sudo reboot –n, 啟動后,就可以在FF中直接輸入http://localhost:8080 ,如果看到首頁,即表示安裝成功

                       

                

          posted on 2008-08-13 08:20 老文 閱讀(1640) 評論(0)  編輯  收藏 所屬分類: ubuntu(linux)上應(yīng)用程序相關(guān)


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           

          導(dǎo)航

          常用鏈接

          留言簿(2)

          隨筆分類(29)

          收藏夾(1)

          My Work

          學(xué)習文章

          軟件使用

          最新隨筆

          最新評論

          主站蜘蛛池模板: 南充市| 贵南县| 平舆县| 七台河市| 巴塘县| 定安县| 淮北市| 谢通门县| 平舆县| 肇源县| 柳河县| 石河子市| 尼勒克县| 石柱| 鲁山县| 东乌| 遂川县| 克东县| 城市| 义马市| 松桃| 丹阳市| 阜康市| 乌海市| 双柏县| 东安县| 宜春市| 乌恰县| 法库县| 通道| 新野县| 江陵县| 海口市| 定兴县| 独山县| 中江县| 石狮市| 威信县| 南溪县| 星座| 阆中市|