tomcat 설치 및 실행

# mac 에서 설치
brew install tomcat

# ubuntu 에서 설치
sudo apt-get install tomcat8 tomcat8-docs tomcat8-examples tomcat8-admin

# bin path
/usr/share/tomcat8/bin/

# conf path
/var/lib/tomcat8/conf/

# log path
/var/log/tomcat8/

# mac 에서 path
brew ls tomcat
/usr/local/Cellar/tomcat/9.0.14/bin/catalina
/usr/local/Cellar/tomcat/9.0.14/homebrew.mxcl.tomcat.plist
/usr/local/Cellar/tomcat/9.0.14/libexec/bin/ (17 files)
/usr/local/Cellar/tomcat/9.0.14/libexec/conf/ (10 files)
/usr/local/Cellar/tomcat/9.0.14/libexec/lib/ (30 files)
/usr/local/Cellar/tomcat/9.0.14/libexec/logs/ (5 files)
/usr/local/Cellar/tomcat/9.0.14/libexec/temp/safeToDelete.tmp
/usr/local/Cellar/tomcat/9.0.14/libexec/webapps/ (571 files)
/usr/local/Cellar/tomcat/9.0.14/libexec/work/ (2 files)
/usr/local/Cellar/tomcat/9.0.14/libexec/ (2 files)
/usr/local/Cellar/tomcat/9.0.14/RELEASE-NOTES
/usr/local/Cellar/tomcat/9.0.14/RUNNING.txt

# 포트 변경
sudo vi /var/lib/tomcat8/conf/server.xml
# mac 에선
sudo vi /usr/local/Cellar/tomcat/9.0.14/libexec/conf/server.xml
<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443 />


# 설정 파일 아래 내용 추가
sudo vi /var/lib/tomcat8/conf/tomcat-users.xml
# mac 에선
sudo vi /usr/local/Cellar/tomcat/9.0.14/libexec/conf/tomcat-users.xml

<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="ysoftman" password="1234" roles="manager-gui,admin-gui"/>
</tomcat-users>

# 버전 확인
sudo bash /usr/share/tomcat8/bin/version.sh

# mac 에서 버전 확인
/usr/local/bin/catalina version

# mac 에서 시작
/usr/local/bin/catalina start

# mac 에서 종료
/usr/local/bin/catalina stop

# 시작
systemctl start tomcat8

# 종료
systemctl stop tomcat8

# 재시작
systemctl restart tomcat8

# WSL(windwos subsystem for linux)환경에서는
# systemctl 을 사용하면 다음과 같이 에러가 발생한다.
# 부팅시 systemd 를 초기화 할 수 없기 때문인것 같다.
System has not been booted with systemd as init system (PID 1). Can't operate

# 이 경우 다음과 같이 service 로 실행하자.
sudo service tomcat8 start

# stop, restart 도 service 로 실행
sudo service tomcat8 stop
sudo service tomcat8 restart

# 로컬로 톰캣 동작을 확인
http://localhost:8080/ ->  manager webapp 에서 위 설정한것으로 로그인

comments:

댓글 쓰기