Tomcat 설치법
Vagrant.configure("2") do |config|
config.vm.define "tomcat_server" do |tomcat_server|
tomcat_server.vm.box = "generic/centos7"
tomcat_server.vm.hostname = 'tomcat-server'
tomcat_server.vm.provider "virtualbox" do |vb|
vb.name = 'tomcat_server'
vb.cpus = '2'
vb.memory = '1024'
end
tomcat_server.vm.provision :shell, :inline => "sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config; sudo systemctl restart sshd;", run: "always"
tomcat_server.vm.provision "shell", inline: <<-SHELL
yum -y update
yum install -y java-11-openjdk-devel
VAR1=$(find /usr/lib/jvm -type d -name 'java-11-openjdk-*' 2> /dev/null)
echo "export JAVA_HOME=$VAR1" | sudo tee -a /etc/profile
TOMCAT_HOME="/usr/local/tomcat9"
mkdir -p $TOMCAT_HOME
wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.82/bin/apache-tomcat-9.0.82.tar.gz
tar xzvf apache-tomcat-9.0.82.tar.gz
mv apache-tomcat-9.0.82/* $TOMCAT_HOME && rm -rf apache-tomcat-9.0.82*
chmod a+rwx -R $TOMCAT_HOME
echo "alias was-start='$TOMCAT_HOME/bin/startup.sh'" | sudo tee -a /etc/bashrc
echo "alias was-stop='$TOMCAT_HOME/bin/shutdown.sh'" | sudo tee -a /etc/bashrc
echo "alias was-log='tail -f $TOMCAT_HOME/logs/catalina.out'" | sudo tee -a /etc/bashrc
echo "alias was-app-directory='cd $TOMCAT_HOME/webapps'" | sudo tee -a /etc/bashrc
echo "alias ll='ls -alF --color=auto'" | sudo tee -a /etc/bashrc
firewall-cmd --zone=public --permanent --add-port=8080/tcp
firewall-cmd --zone=public --permanent --add-port=8009/tcp
firewall-cmd --reload
SHELL
tomcat_server.vm.network "private_network", ip: "192.168.31.11"
tomcat_server.vm.network "forwarded_port", guest: 8080, host: 18000
end
end
- vagrant ssh 를 통해서 들어간 후, tomcat 관련 명령어를
쉽게 사용하기 위해서 몇가지 alias 를 세팅했습니다.
was-start
: 톰캣 시작
was-stop
: 톰캣 정지
was-log
: 톰캣 로그 보기
was-app-directory
: 톰캣 webapps 폴더로 이동