์ผ๊ฒฝํ ์ธํดํ์ ํ์ง๋ง ๋ฐ๋ก ์ ๋ฌด๋ฅผ ๋ฐ์ง๋ ์์์ ๊ต์ก๋ค๋๋ฉด์ ๋ ์๊ฐ์ ๋ฐํ์ผ๋ก ํด๋ณด๊ณ ์ถ์ ๊ฑธ ๊ธฐํํด์ ๊ฐ๋จํ ์ฅ์ ํ ์คํธ๋ฅผ ํ๋ ค๊ณ ํ๋ค. ๊ทธ๋์ ํ ์คํธ ํ๊ฒฝ์ ๋ง๋ค๊ธฐ ์ํด Apache, Tomcat, PostgreSQL์ ์ฌ์ฉํ๋ ค๊ณ ํ๋ค.
โ๏ธVMware ๊ตฌ์ฑ
VMware๋ ์๋์ ๊ฐ์ด ๊ตฌ์ฑํ๋ค.
- OS: Rocky Linux 9.7
- CPU: 2 Core
- Memory: 1GB
- Disk: 20GB
๋๋ WEB, WAS, DB๋ฅผ ๊ฐ๊ฐ ๋ถ๋ฆฌํด ์ด ์ธ ๋๋ฅผ ๊ตฌ์ฑํ๋ค.
โ๐ป ํจํค์ง ์ค์น
์ด์ ๊ฐ ํ์ํ ์๋น์ค๋ฅผ ์ค์นํด์ผ ํ๋ค. ๋๋ Ansible์ ์ด์ฉํด ์ค์นํ์๋ค. Ansible playbook์ ์๋์ ๊ฐ๋ค.
- name: Install WEB - WAS - DB
hosts: localhost
tasks:
- name: Install Apache
dnf:
name: httpd
state: present
- name: Start Apache
service:
name: httpd
state: started
enabled: yes
- name: Install JDK
dnf:
name: java-17-openjdk
state: latest
- name: Install Tomcat
dnf:
name: tomcat
state: present
- name: Install Tomcat Webapps
dnf:
name: tomcat-webapps
state: present
- name: Install Tomcat Admin Webapps
dnf:
name: tomcat-admin-webapps
state: present
- name: Start Tomcat
service:
name: tomcat
state: started
enabled: yes
- name: Install PostgreSQL
dnf:
name: postgresql-server
state: present
- name: Check if PostgreSQL data directory is initialized
stat:
path: /var/lib/pgsql/data/PG_VERSION
register: pg_data_dir
- set_fact:
postgresql_data_dir_initialized: "{{ pg_data_dir.stat.exists }}"
- name: Init DB
command: postgresql-setup --initdb
when: not postgresql_data_dir_initialized
- name: Start PostgreSQL
service:
name: postgresql
state: started
enabled: yes
์ค์ ๋ก๋ host๋ณ๋ก task๋ฅผ ๋๋์์ผ๋ฉฐ ์ ์คํฌ๋ฆฝํธ๋ localhost๋ก ํ ์๋ฒ์ ๋ค ์ค์นํ๋ ๊ฒฝ์ฐ๋ฅผ ๊ฐ์ ํด์ ์์ฑํ ๊ฒ์ด๋ค. ์ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ๋ฉด ๋ค์๊ณผ ๊ฐ์ด ์ฑ๊ณตํ ๊ฒ์ ์ ์ ์๋ค.

ํ์ํ ํจํค์ง๋ฅผ ์ค์นํ์ผ๋ ์ด์ ๊ฐ ์๋น์ค๋ฅผ ๊ตฌ์ฑํด์ผ ํ๋ค.
๐ฉ๐ป๐ปApache ๊ตฌ์ฑ
๋จผ์ Apache๋ฅผ ๊ตฌ์ฑํ ๊ฒ์ด๋ค. ์ ์ ํ์ด์ง๋ ์๋์ ๊ฐ์ด /var/www/html์ ์ถ๊ฐํ๋ฉด ๋๋ค. javascript๋ css๋ ๋ง์ฐฌ๊ฐ์ง๋ก ํด๋น ๋๋ ํ ๋ฆฌ์ ์์น์ํค๋ฉด ๋๋ค. ๋๋ bootstrap์ ์ด์ฉํด์ ๋ฐ๋ก css๊ฐ ์์ง๋ ์๋ค.

๊ทธ๋ฆฌ๊ณ /etc/httpd/conf/httpd.conf์์ Include conf.modules.d/*.conf ๋ฐ์ ๋ค์๊ณผ ๊ฐ์ด ์ถ๊ฐํ๋ค.

was์ ์ฐ๋ํ๊ธฐ ์ํด apache์ /etc/httpd/conf.d/ ํ์์ ํ๋ก์๋ฅผ ์ค์ ํ .conf ํ์ผ์ ๋ง๋ ๋ค. ์๋ ํ์ผ์ httpd.conf์ IncludeOptional conf.d/*.conf๊ฐ ๋ช ์๋์ด์์ด์ conf.d์ ๋ง๋ค์ด๋๋ฉด ์์์ ์ฐธ์กฐํ ๊ฒ์ด๋ค.
<VirtualHost *:80> # *:80 โก๏ธ80ํฌํธ ์์ฒญ ์ฒ๋ฆฌ
ServerName test.com # ๋๋ฉ์ธ ๊ธฐ์ค ๊ฐ์ ํธ์คํธ
DocumentRoot /var/www/html # ์ ์ ํ์ผ(HTML ๋ฑ) ์์น
ProxyPreserveHost On
# ์์ฒญ์ WAS๋ก ์ ๋ฌ
ProxyPass {๋งคํ ๊ฒฝ๋ก} http://{WAS-IP:ํฌํธ}/{jsp ํ์ผ ์๋ ํด๋}
# WAS ์๋ต ํค๋(URL)์ ๋ค์ WEB ๊ธฐ์ค์ผ๋ก ๋ณํ
ProxyPassReverse {๋งคํ ๊ฒฝ๋ก} http://{WAS-IP:ํฌํธ}/{jsp ํ์ผ ์๋ ํด๋}
</VirtualHost>
๐ฉ๐ป๐ปTomcat ๊ตฌ์ฑ
Apache ๊ตฌ์ฑ์ด ๋๋ฌ์ผ๋ ์ด๋ฒ์๋ Tomcat์ ๊ตฌ์ฑํ๊ฒ ๋ค. ์ฌ์ค tomcat์ ๋ฐ๋ก ๊ตฌ์ฑํ ๊ฒ์ด ์๋ค. ์ฌ์ฉํ๋ ค๋ mod_proxy๋ mod_jk์ ๋ฌ๋ฆฌ ๋ณ ๋ค๋ฅธ Connector๊ฐ ํ์ํ์ง ์๋ค๊ณ ํ๋ค. mod_jk์์ผ๋ฉด server.xml์์ service ๋ช ์ด Catalina๋ผ๊ณ ๋์ด์๋ ๊ฒ์ Connector๋ฅผ ์์ ํด์ผ ํ๋ค.
Tomcat์์ ์ค์ ํ ๊ฒ์ DB ๊ด๋ จ ์ค์ ๋ง ํ๋ฉด ๋๋ค. ์ฐ์ ๊ทธ ์ ์ ๋์ ์ฒ๋ฆฌ๋ฅผ ์ํ jsp ํ์ผ์ webapps์ ํ์ ๋๋ ํ ๋ฆฌ๋ฅผ ๋ง๋ค์ด์ ์์น์ํจ๋ค.

๊ทธ๋ฆฌ๊ณ postgresql jdbc connector๊ด๋ จ jar๋ฅผ ๋ค์ด๋ฐ์ ๋ค์ ์ด๋ฏธ์ง์ ๊ฐ์ด /tomcat/lib ๋๋ ํ ๋ฆฌ์ ์์น์ํจ๋ค.
# postgresql connector ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์น
curl -LO https://jdbc.postgresql.org/download/posgresql-42.7.9.jar

๊ทธ๋ฆฌ๊ณ DB ์ ๋ณด๋ฅผ ์์ฑํ๋ค. ์๋ web.xml๊ณผ context.xml์ conf ๋๋ ํ ๋ฆฌ์ ์๋๋ฐ ๋ด๊ฐ ๋ง๋ ํ๋ก์ ํธ์๋ง ์ ์ฉํ๊ธฐ ์ํด์ /usr/share/tomcat/webapps/board ํ์์ WEB-INF์ META-INF ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํด์ ๋ ํ์ผ์ ๋ง๋ค์ด์ ์ด ํ์ผ์ ์์ฑํ๋ค.


๋ postgresql์ ์ฌ์ฉํ ๊ฑฐ๋ผ ์์ ๊ฐ์ด ์ ํ๋ค. ๋ค๋ฅธ DB๋ฅผ ์ฌ์ฉํ๋ค๋ฉด ์๋ ์ฌ์ดํธ๋ฅผ ์ฐธ๊ณ ํ๋ฉด ๋๋ค.
Apache Tomcat 9 (9.0.115) - JNDI Datasource How-To
JNDI Datasource configuration is covered extensively in the JNDI-Resources-HOWTO. However, feedback from tomcat-user has shown that specifics for individual configurations can be rather tricky. Here then are some example configurations that have been poste
tomcat.apache.org
์ด๋ ๊ฒ WEB, WAS, DB ์ฐ๋์ ๋ง์น๊ฒ ๋ค. SSL์ ์ถํ ์ค์ ํ๊ฒ ๋๋ฉด ์ฌ๋ฆฌ๊ฒ ๋ค.
์ฐธ๊ณ ์ฌ์ดํธ
- https://httpd.apache.org/docs/2.2/mod/mod_proxy_ajp.html
- https://httpd.apache.org/docs/2.2/mod/core.html#virtualhost
- https://httpd.apache.org/docs/2.2/vhosts/examples.html
- https://tomcat.apache.org/tomcat-9.0-doc/proxy-howto.html
- https://tomcat.apache.org/tomcat-9.0-doc/jndi-resources-howto.html
- https://tomcat.apache.org/tomcat-9.0-doc/config/context.html#Context_Parameters
'OS&Server > WEB | WAS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| [WEB/WAS] NGINX๋? (2) | 2025.07.03 |
|---|