|
|
(未显示同一用户的1个中间版本) |
第1行: |
第1行: |
| 1.安装jdk6
| |
| <pre> shell>sudo apt-get install sun-java6-jdk(用新得立软件包安装)
| |
| </pre>
| |
| 2.下载tomcat6<br>
| |
| <pre> 下载地址是:http://tomcat.apache.org/
| |
|
| |
|
| 本次安装的是:apache-tomcat-6.0.18.tar.gz
| |
| </pre>
| |
| 3.安装<br>
| |
| <pre>将压缩包拷贝到 /opt 下(个人喜好,可以放在别处)
| |
| shell>sudo cp apache-tomcat-6.0.18.tar.gz /opt
| |
| </pre><pre>解压文件
| |
|
| |
| shell>cd /opt
| |
| shell>sudo tar zxvf apache-tomcat-6.0.18.tar.gz
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| </pre><pre> 解压完成后,会在 /opt 下生成文件夹 apache-tomcat-6.0.18
| |
| </pre><pre>为了操作方便,在/usr/local 下建立软链接,名字是tomcat6
| |
|
| |
| shell>cd /usr/local
| |
| shell>sudo ln -s /opt/apache-tomcat-6.0.18 tomcat6
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| </pre><pre>测试tomcat是否能够正常启动
| |
|
| |
| shell>sudo /usr/local/tomcat6/bin/startup.sh
| |
| 打开firefox,输入http://localhost:8080,如果正常访问,则表示成功。
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| </pre>
| |
| 4.设置tomcat开机自启动<br>
| |
| <pre>根据tomcat官方的document说明,linux下设置开机自启动可以使用jsvc(tomcat包里自带)
| |
| </pre><pre> 设置tomcat以独立的用户运行(防止以root运行,权限太大)
| |
|
| |
| shell>sudo useradd -d /usr/local/tomcat6 -s /usr/sbin/nologin tomcat
| |
| 上边的这个命令是添加一个系统用户tomcat,并且设置为不可登录系统。
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| </pre><pre>设置用户tomcat 对tomcat6的访问权限
| |
|
| |
| shell>sudo chown -R tomcat:tomcat /usr/local/tomcat6
| |
| shell>sudo chown -R tomcat:tomcat /opt/apache-tomcat-6.0.18
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| </pre><pre>安装jsvc,前提需要系统安装了gcc(系统一般默认安装),autoconf,libc6-dev
| |
|
| |
| shell>sudo apt-get install .....
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| </pre><pre> 解压jsvc.tar.gz
| |
|
| |
| shell>cd /usr/local/tomcat6/bin
| |
| shell>sudo tar zxvf jsvc.tar.gz
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| </pre><pre>准备编译配置文件
| |
|
| |
| shell>cd jsvc-src
| |
| shell>sudo sh support/buildconf.sh
| |
| 如果成功,命令终端会打出:
| |
| support/buildconf.sh: configure script generated successfully
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| </pre><pre>为configure添加执行权限
| |
|
| |
| shell>sudo chmod 755 configure
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| </pre><pre> 编译
| |
|
| |
| shell>sudo ./configure –with-java=/usr/lib/jvm/java-6-sun (java的安装路径)
| |
| shell>sudo make
| |
| 如果没有出现错误,jsvc就安装成功了。
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| </pre><pre>设置启动脚本
| |
|
| |
| 拷贝jsvc带的tomcat5.sh 脚本拷贝到 /etc/init.d/ 下,并改名为tomcat
| |
| shell>sudo cp /usr/local/tomcat6/bin/jsvc-src/native/Tomcat5.sh /etc/init.d/tomcat
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| </pre><pre>修改/etc/init.d/tomcat文件
| |
|
| |
| shell>sudo gedit /etc/init.d/tomcat
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| </pre><pre>文件中要修改的内容如下:
| |
| </pre><pre> JAVA_HOME=/usr/lib/jvm/java-6-sun #这个地方设置为机器的jdk的位置
| |
|
| |
| CATALINA_HOME=/usr/local/tomcat6 #tomcat的安装位置(软链接)
| |
| DAEMON_HOME=/usr/local/tomcat6/bin #tomcat启动程序的位置
| |
| TOMCAT_USER=tomcat #tomcat 的用户
| |
| CATALINA_BASE=/usr/local/tomcat6 #tomcat的安装位置
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| # 注释掉下边这句
| |
|
| |
| # CATALINA_OPTS="-Djava.library.path=/home/jfclere/jakarta-tomcat-connectors/jni/native/.libs"
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| # 添加下边这句
| |
|
| |
|
| |
| CATALINA_OPTS=
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| $DAEMON_HOME/jsvc-src/jsvc \ #设置正确的jsvc程序的位置
| |
| $DAEMON_HOME/jsvc-src/jsvc \ #设置正确的jsvc程序的位置
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| </pre><pre>设置 /etc/init.d/tomcat的可执行权限
| |
|
| |
| Shell>sudo chmod 755 /etc/init.d/tomcat
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| </pre><pre>在/etc/rc2.d/下设置一个/etc/init.d/tomcat 的软链接
| |
|
| |
| shell>cd /etc/rc2.d/
| |
| shell>sudo ln -s /etc/init.d/tomcat S16tomcat
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| </pre><pre>注:rc2.d目录下的文件要以S后就数字开头,表示启动的顺序。而rc2.d中的2,表示这个目录下文件在开机时的运行级别(runlevel)为2
| |
| </pre>
| |
| 5.结束<br>
| |
| <pre>重新启动系统 shell>sudo reboot –n, 启动后,就可以在FF中直接输入http://localhost:8080 ,如果看到首页,即表示安装成功
| |
| </pre>
| |
| <br>
| |