Ubuntu 14.04下Tomcat 安装过程

Ubuntu 14.04下Tomcat 安装过程笔记

检查java的版本

linuxidc@ubuntu:~$ sudo java -version

[sudo] password for linuxidc:

java version "1.7.0_95"

OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-0ubuntu0.14.04.2)

OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)

linuxidc@ubuntu:~$

查找java目录

linuxidc@ubuntu:~$ whereis java

java: /usr/bin/java /etc/java /usr/lib/java /usr/bin/X11/java /usr/share/java /usr/share/man/man1/java.1.gz

linuxidc@ubuntu:~$ which java

/usr/bin/java

设置环境变量

linuxidc@ubuntu:~$ echo $JAVA_HOME

空行-表示没有设定该环境变量

linuxidc@ubuntu:~$ echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

linuxidc@ubuntu:~$ JAVA_HOME=/usr/bin/java;export JAVA_HOME

linuxidc@ubuntu:~$ echo $JAVA_HOME

/usr/bin/java

linuxidc@ubuntu:~$

安装Tomcat并设置环境变量

linuxidc@ubuntu:~/Downloads$ sudo cp -r apache-tomcat-8.0.33 /home/tomcat

linuxidc@ubuntu:~/Downloads$ cd /home/

linuxidc@ubuntu:/home$ ls

tomcat linuxidc

zhousp@ubuntu:/home$ cd tomcat

linuxidc@ubuntu:/home/tomcat$

linuxidc@ubuntu:/home/tomcat$ ls

bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work

linuxidc@ubuntu:/home/tomcat$ cd ~

linuxidc@ubuntu:~$ CATALINA_HOME=/home/tomcat;export CATALINA_HOME

linuxidc@ubuntu:~$ echo $CATALINA_HOME

/home/tomcat

linuxidc@ubuntu:~$

解决conf文件夹访问权限不够的问题

linuxidc@ubuntu:/home$ sudo chmod -R 755 tomcat

linuxidc@ubuntu:/home$ ll

total 16

drwxr-xr-x 4 root root 4096 4月 22 12:03 ./

drwxr-xr-x 23 root root 4096 4月 23 11:32 ../

drwxr-xr-x 9 root root 4096 4月 22 12:03 tomcat/

drwxr-xr-x 31 linuxidc zhousp 4096 4月 23 21:30 linuxidc/

zhousp@ubuntu:/home$ cd ./tomcat

linuxidc@ubuntu:/home/tomcat$ ls

bin lib logs RELEASE-NOTES temp work

conf LICENSE NOTICE RUNNING.txt webapps

linuxidc@ubuntu:/home/tomcat$ ll

total 120

drwxr-xr-x 9 root root 4096 4月 22 12:03 ./

drwxr-xr-x 4 root root 4096 4月 22 12:03 ../

drwxr-xr-x 2 root root 4096 4月 23 11:48 bin/

drwxr-xr-x 3 root root 4096 4月 22 12:14 conf/

drwxr-xr-x 2 root root 4096 4月 22 12:03 lib/

-rwxr-xr-x 1 root root 57011 4月 22 12:03 LICENSE*

drwxr-xr-x 2 root root 4096 4月 23 10:39 logs/

-rwxr-xr-x 1 root root 1444 4月 22 12:03 NOTICE*

-rwxr-xr-x 1 root root 6739 4月 22 12:03 RELEASE-NOTES*

-rwxr-xr-x 1 root root 16195 4月 22 12:03 RUNNING.txt*

drwxr-xr-x 2 root root 4096 4月 22 12:03 temp/

drwxr-xr-x 7 root root 4096 4月 22 12:03 webapps/

drwxr-xr-x 3 root root 4096 4月 22 12:14 work/

linuxidc@ubuntu:/home/tomcat$

启动Tomcat

(使用eclipse 搭建java web编程环境时,不需要启动Tomcat,eclipse运行程序时,会自己启动Tomcat。所以,作为系统服务启动Tomcat是为了讲系统作为web服务器,对外提供web服务,而不是启动之后,eclipse才能够链接到服务器。这一点和程序链接mysql服务器的概念截然不同。)

linuxidc@ubuntu:/home/tomcat/bin$ sudo su

root@ubuntu:/home/tomcat/bin# sh startup.sh

Using CATALINA_BASE: /home/tomcat

Using CATALINA_HOME: /home/tomcat

Using CATALINA_TMPDIR: /home/tomcat/temp

Using JRE_HOME: /usr

Using CLASSPATH: /home/tomcat/bin/bootstrap.jar:/home/tomcat/bin/tomcat-juli.jar

Tomcat started.

root@ubuntu:/home/tomcat/bin#

Ubuntu 14.04下Tomcat 安装过程

ubuntu下设置Tomcat服务自动启动

root@ubuntu:/home/tomcat/bin# cp catalina.sh /etc/init.d/

root@ubuntu:/home/tomcat/bin# cd /etc/init.d/

root@ubuntu:/etc/init.d# mv catalina.sh tomcat

rroot@ubuntu:/etc/init.d# ls tomcat

tomcat

root@ubuntu:/etc/init.d# vim tomcat

添加环境变量:

JAVA_HOME=/home/tomcat

CATALINA_HOME=/usr/bin/java

Ubuntu 14.04下Tomcat 安装过程

root@ubuntu:/etc/init.d# service tomcat start

Using CATALINA_BASE: /home/tomcat

Using CATALINA_HOME: /home/tomcat

Using CATALINA_TMPDIR: /home/tomcat/temp

Using JRE_HOME: /usr/bin/java

Using CLASSPATH: /home/tomcat/bin/bootstrap.jar:/home/tomcat/bin/tomcat-juli.jar

Tomcat started.

自动启动命令:

root@ubuntu:/# chmod 755 /etc/init.d/tomcat

root@ubuntu:/# update-rc.d -f tomcat defaults

update-rc.d: warning: /etc/init.d/tomcat missing LSB information

update-rc.d: see <>

Adding system startup for /etc/init.d/tomcat ...

/etc/rc0.d/K20tomcat -> ../init.d/tomcat

/etc/rc1.d/K20tomcat -> ../init.d/tomcat

/etc/rc6.d/K20tomcat -> ../init.d/tomcat

/etc/rc2.d/S20tomcat -> ../init.d/tomcat

/etc/rc3.d/S20tomcat -> ../init.d/tomcat

/etc/rc4.d/S20tomcat -> ../init.d/tomcat

/etc/rc5.d/S20tomcat -> ../init.d/tomcat

root@ubuntu:/#

(删除自动启动)

linuxidc@ubuntu:~$ update-rc.d -f tomcat remove

Removing any system startup links for /etc/init.d/tomcat ...

/etc/rc0.d/K20tomcat

update-rc.d: unlink: Permission denied

linuxidc@ubuntu:~$ sudo update-rc.d -f tomcat remove

[sudo] password for linuxidc:

Removing any system startup links for /etc/init.d/tomcat ...

/etc/rc0.d/K20tomcat

/etc/rc1.d/K20tomcat

/etc/rc2.d/S20tomcat

/etc/rc3.d/S20tomcat

/etc/rc4.d/S20tomcat

/etc/rc5.d/S20tomcat

/etc/rc6.d/K20tomcat

linuxidc@ubuntu:~$

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5fdfcf4f59304e241383f5aeb7638090.html