1. tomcat 다운로드
tomcat.apache.org로 이동하여 좌측의 Download에서 적당한 버전을 선택하고 Binary Distributions에서 Core: tar.gz를 다운로드 받는다.
2. 다운로드한 파일을 압축해제한 후 /opt밑으로 이동한다.
$ tar xvfz apache-tomcat-8.0.14.tar.gz
$ sudo mv apache-tomcat-8.0.14 /opt/tomcat8
3. tomcat의 버전정보와 시스템 정보를 확인해보자
$ cd /opt/tomcat8/bin
$ ./version.sh
Using CATALINA_BASE: /opt/tomcat8 Using CATALINA_HOME: /opt/tomcat8 Using CATALINA_TMPDIR: /opt/tomcat8/temp Using JRE_HOME: /usr/lib/jvm/jdk1.8.0/jre Using CLASSPATH: /opt/tomcat8/bin/bootstrap.jar:/opt/tomcat8/bin/tomcat-juli.jar Server version: Apache Tomcat/8.0.14 Server built: Sep 24 2014 09:01:51 Server number: 8.0.14.0 OS Name: Linux OS Version: 3.16.0-24-generic Architecture: amd64 JVM Version: 1.8.0_25-b17 JVM Vendor: Oracle Corporation |
4. 시스템 설정을 검토해 보자
$ ./configtest.sh
◎ 만약 tomcat을 이미 실행했다면 종료를 한 후에 test를 진행해야 한다.
5. 사용자를 추가해봅시다.
$ sudo vi /opt/tomcat8/bin/tomcat-users.xml
... <role rolename="manager-gui"/> <role rolename="admin-gui"/> <user username="username" password="password" roles="manager-gui,admin-gui"/> </tomcat-users> |
username/password를 알맞게 설정해주세요.
6. 실행 및 종료
$ ./startup.sh # 실행
$ ./shutdown.sh # 종료
7. 실행/종료를 위한 스크립트를 init.d에 생성하자.
$ sudo vi /etc/init.d/tomcat8
#!/bin/sh
### BEGIN INIT INFO
# Provides: tomcat8
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Should-Start: $named
# Should-Stop: $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start Tomcat.
# Description: Start the Tomcat servlet engine. ### END INIT INFO if [ `id -u` -ne 0 ]; then echo "You need root privileges to run this script" exit 1 fi # Make sure tomcat is started with system locale if [ -r /etc/default/locale ]; then . /etc/default/locale export LANG fi if [ -r /etc/default/rcS ]; then . /etc/default/rcS fi . /lib/lsb/init-functions
export CATALINA_HOME=/opt/tomcat8 PATH=/sbin:/bin:/usr/sbin:/usr/bin start() { sh $CATALINA_HOME/bin/startup.sh } stop() { sh $CATALINA_HOME/bin/shutdown.sh } case $1 in start|stop) $1;; restart) stop; start;; *) echo "Run as $0 <start|stop|restart>"; exit 1;; esac |
$ sudo chmod 755 /etc/init.d/tomcat8
8. tomcat이 부팅시 자동 실행될 수 있도록 등록해줍시다.
$ sudo update-rc.d tomcat8 defaults
자동 실행을 해제
$ sudo update-rc.d tomcat8 remove
OSX의 Terminal에서 ssh로 로그인을 해서 작업중이라면 Perl locale error가 발생할 수 있다. [해결방법]
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8”).
9. tomcat을 실행하고 Server Status를 확인해봅시다.
$ sudo /etc/init.d/tomcat8 start
http://localhost:8080을 오픈하여 보세요.
"Server Status" 버튼을 눌러서 5.에서 설정한 username과 password를 입력하여 Server Status를 확인해보세요.


참고) Apache + Tomcat + MySQL 설치 (우분투)