우선 우분투 업데이트 확인
sudo apt update
ubuntu@tokyoaj:~$ sudo apt update
아파치 설치
sudo apt-get install -y apache2
ubuntu@tokyoaj:~$ sudo apt-get install -y apache2
자버설치
sudo apt install -y openjdk-11-jre-headless
ubuntu@tokyoaj:~$ java
Command 'java' not found, but can be installed with:
sudo apt install openjdk-11-jre-headless # version 11.0.11+9-0ubuntu2~20.04, or
sudo apt install default-jre # version 2:1.11-72
sudo apt install openjdk-13-jre-headless # version 13.0.7+5-0ubuntu1~20.04
sudo apt install openjdk-16-jre-headless # version 16.0.1+9-1~20.04
sudo apt install openjdk-17-jre-headless # version 17+35-1~20.04
sudo apt install openjdk-8-jre-headless # version 8u292-b10-0ubuntu1~20.04
ubuntu@tokyoaj:~$ sudo apt install -y openjdk-11-jre-headless
Tomcat9 설치위치로 이동
ubuntu@tokyoaj:~$ cd /usr/share
Tomcat9 다운로드
sudo wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.55/bin/apache-tomcat-9.0.55.tar.gz
ubuntu@tokyoaj:/usr/share$ sudo wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.55/bin/apache-tomcat-9.0.55.tar.gz
--2021-12-01 00:49:08-- https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.55/bin/apache-tomcat-9.0.55.tar.gz
Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11579748 (11M) [application/x-gzip]
Saving to: ‘apache-tomcat-9.0.55.tar.gz’
apache-tomcat-9.0.55.tar.gz 100%[=================================================>] 11.04M 10.3MB/s in 1.1s
2021-12-01 00:49:09 (10.3 MB/s) - ‘apache-tomcat-9.0.55.tar.gz’ saved [11579748/11579748]
다운받은 Tomcat파일 압축풀기 -> 압축푼 폴더명변경 -> 다운로드파일 삭제
sudo tar -zxvf apache-tomcat-9.0.55.tar.gz
sudo mv apache-tomcat-9.0.55 /usr/share/tomcat9
sudo rm apache-tomcat-9.0.55.tar.gz
ubuntu@tokyoaj:/usr/share$ sudo tar -zxvf apache-tomcat-9.0.55.tar.gz
ubuntu@tokyoaj:/usr/share$ sudo mv apache-tomcat-9.0.55 /usr/share/tomcat9
ubuntu@tokyoaj:/usr/share$ sudo rm apache-tomcat-9.0.55.tar.gz
mod-jk 설치
sudo apt-get install -y libapache2-mod-jk
ubuntu@tokyoaj:/usr/share$ sudo apt-get install -y libapache2-mod-jk
/etc/libapache2-mod-jk/workers.properties 수정을위한 기본정보확인
ubuntu@tokyoaj:/usr/share$ which java
/usr/bin/java
ubuntu@tokyoaj:/usr/share$ readlink /usr/bin/java
/etc/alternatives/java
ubuntu@tokyoaj:/usr/share$ readlink /etc/alternatives/java
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
/etc/libapache2-mod-jk/workers.properties 파일수정
workers.tomcat_home=/usr/share/tomcat9
workers.java_home=/usr/lib/jvm/java-11-openjdk-amd64
ubuntu@tokyoaj:/usr/share$ sudo nano /etc/libapache2-mod-jk/workers.properties
생략
#
# workers.tomcat_home should point to the location where you
# installed tomcat. This is where you have your conf, webapps and lib
# directories.
#
workers.tomcat_home=/usr/share/tomcat9
#
# workers.java_home should point to your Java installation. Normally
# you should have a bin and lib directories beneath it.
#
workers.java_home=/usr/lib/jvm/java-11-openjdk-amd64
#
# You should configure your environment slash... ps=\ on NT and / on UNIX
# and maybe something different elsewhere.
#
ps=/
#
#------ ADVANCED MODE ------------------------------------------------
#---------------------------------------------------------------------
톰켓설정
sudo nano /usr/share/tomcat9/conf/server.xml
ubuntu@tokyoaj:/usr/share$ sudo nano /usr/share/tomcat9/conf/server.xml
server.xml 파일내부
<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector protocol="AJP/1.3"
address="::1"
port="8009"
redirectPort="8443" />
-->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" secretRequired="false" URIEncoding="UTF-8" address="0.0.0.0" />
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" jvmRoute="ajp13_worker" defaultHost="localhost">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
Tomcat 실행
sudo sh /usr/share/tomcat9/bin/startup.sh
sudo sh /usr/share/tomcat9/bin/shutdown.sh
ubuntu@tokyoaj:/usr/share$ sudo sh /usr/share/tomcat9/bin/startup.sh
Using CATALINA_BASE: /usr/share/tomcat9
Using CATALINA_HOME: /usr/share/tomcat9
Using CATALINA_TMPDIR: /usr/share/tomcat9/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/share/tomcat9/bin/bootstrap.jar:/usr/share/tomcat9/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
ubuntu@tokyoaj:/usr/share$ sudo sh /usr/share/tomcat9/bin/shutdown.sh
Using CATALINA_BASE: /usr/share/tomcat9
Using CATALINA_HOME: /usr/share/tomcat9
Using CATALINA_TMPDIR: /usr/share/tomcat9/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/share/tomcat9/bin/bootstrap.jar:/usr/share/tomcat9/bin/tomcat-juli.jar
Using CATALINA_OPTS:
NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
ubuntu@tokyoaj:/usr/share$
apache2 의 VirtualHost 수정
sudo nano /etc/apache2/sites-enabled/000-default.conf
ubuntu@tokyoaj:/usr/share$ sudo nano /etc/apache2/sites-enabled/000-default.conf
파일내부 복사해서 사용가능
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /usr/share/tomcat9/webapps/ROOT/
JkMount /* ajp13_worker
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/usr/share/tomcat9/webapps/ROOT">
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
방화벽 포트 오픈
sudo iptables -I INPUT 5 -i ens3 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
sudo iptables -I INPUT 5 -i ens3 -p tcp --dport 8080 -m state --state NEW,ESTABLISHED -j ACCEPT
ubuntu@tokyoaj:/usr/share$ sudo iptables -I INPUT 5 -i ens3 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
ubuntu@tokyoaj:/usr/share$ sudo iptables -I INPUT 5 -i ens3 -p tcp --dport 8080 -m state --state NEW,ESTABLISHED -j ACCEPT
mod-jk 정보 apache2와 Tomcat 연결을위한 작업
sudo nano /etc/apache2/apache2.conf
ubuntu@tokyoaj:/usr/share$ sudo nano /etc/apache2/apache2.conf
추가내용 아래 붙여넣기 사용가능
JkWorkersFile /etc/apache2/workers.properties
# Where to put jk shared memory
JkShmFile /var/log/apache2/mod_jk.shm
# Where to put jk logs
JkLogFile /var/log/apache2/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the timestamp log format
JkLogStampFormat "[ %a %b %d %H:%M:%S %Y ] "
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
#추가내용
JkWorkersFile /etc/libapache2-mod-jk/workers.properties
# Where to put jk shared memory
JkShmFile /var/log/apache2/mod_jk.shm
# Where to put jk logs
JkLogFile /var/log/apache2/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the timestamp log format
JkLogStampFormat "[ %a %b %d %H:%M:%S %Y ] "
톰켓 유저생성, 소유자설정, 권한설정
sudo useradd -m -d /opt/tomcat -U -s /bin/false tomcat
sudo chown -R tomcat:tomcat /usr/share/tomcat9
sudo chmod -R u+x /usr/share/tomcat9/bin
ubuntu@tokyoaj:/usr/share$ sudo useradd -m -d /opt/tomcat -U -s /bin/false tomcat
ubuntu@tokyoaj:/usr/share$ sudo chown -R tomcat:tomcat /usr/share/tomcat9
ubuntu@tokyoaj:/usr/share$ sudo chmod -R u+x /usr/share/tomcat9/bin
Tomcat 재실행
sudo sh /usr/share/tomcat9/bin/shutdown.sh
sudo sh /usr/share/tomcat9/bin/startup.sh
아파치 재시작하면 80포트 Tomcat 화면 접속가능
sudo service apache2 restart
'Server > Ubuntu' 카테고리의 다른 글
[Ubuntu] 사용자 생성 / ssh접속권한 / ftp권한부여 스크립트 (0) | 2023.02.08 |
---|---|
MySQL Replication 설정 (Master Slave) (0) | 2023.02.08 |
MySQL 5.7.33 계정생성 / 스키마생성 (0) | 2021.03.23 |
Ubuntu 20.10 x64 + MySQL 5.7.33 외부접속 설정 (0) | 2021.03.23 |
Ubuntu 20.10 x64 + MySQL 5.7.33 (0) | 2021.03.23 |