Apache๋?
Tomcat์ด๋?
์ฐ๋ํ๊ธฐ
๐ Apache + Tomcat ์ํ ํจํค์ง ์ค์น
sudo yum install gcc gcc-c++ httpd-devel
// gcc : c์ปดํ์ผ๋ฌ
// gcc-c++ : c++์ปดํ์ผ๋ฌ
// httpd-devel : apache์์ tomcat-connectors ์ฌ์ฉํ๊ธฐ ์ํ ์ ํธ
tomcat-connector ์ค์น ( mod_jk )
apache์ tomcat์ ์ฐ๋์์ผ์ฃผ๋ ํ๋ก๊ทธ๋จ
Apache ์๋ฒ์์ ๋ค์ด๋ฐ๊ธฐ
wget https://dlcdn.apache.org/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.48-src.tar.gz
๋ค์ด๋ฐ์ ํ์ผ ์์ถํ๊ธฐ
tar -zxvf tomcat-connectors-1.2.48-src.tar.gz
ํด๋ ์ด๋, ์ค์นํ์ผ ์คํ
// ํด๋์ด๋
cd tomcat-connectors-1.2.48-src/native
// httpd-devel์ apxs ์ ํธ ๊ฒฝ๋ก ํ์ธ
which apxs
=> /usr/bin/apxs
// apxs ์ ์ฉํด, ์ค์นํ์ผ ๋ง๋ค๊ธฐ
sudo ./configure --with-apxs=/usr/bin/apxs
// ์ค์นํ์ผ c์ธ์ด ์ปดํ์ผ
sudo make
// ๊ธฐ๊ณ์ด ํ์ผ ์ค์นํ์ผ ์คํ
sudo make install
์ค์น ํ์ธ
ls /etc/httpd/modules | grep jk
=> mod_jk.so
๐ selinux ๋ณด์ ์ค์ ๋ณ๊ฒฝ
chcon -u system_u -r object_r -t httpd_modules_t /etc/httpd/modules/mod_jk.so
// ์์ ๋ช
๋ น์ด๊ฐ ์๋ํ์ง ์์ ๊ฒฝ์ฐ,
$ vi /etc/sysconfig/selinux
disalbed๋ฅผ enforcing์ผ๋ก ๋ณ๊ฒฝํ๊ธฐ
$ reboot
์ฌ๋ถํ
$ vi /etc/httpd/conf/httpd.conf
์๋ ๋ด์ฉ ์ถ๊ฐ
ServerTokens Prod
ServerSignature Off
TraceEnable Off
๐ Apache ์๋ฒ ์ค์
workers.properties
์ฐ๋ํ tomcat ์ ๋ณด ์ค์
// vi ํธ์ง๊ธฐ๋ก ํ์ผ ์์ฑ
vim /etc/httpd/conf/workers.properties
// ํ์ผ ๋ด์ฉ ์์ฑ
worker.list=tomcat
worker.tomcat.port=8009
worker.tomcat.host=192.168.56.101
worker.tomcat.type=ajp13
worker.tomcat.lbfactor=1
// ํฌํธ, tomcat ์๋ฒ ip, ์ฌ์ฉํ ํ์
, ์์
ํ ๋น๋
httpd.conf
์ํ์น๊ฐ ์คํํ ๋ ์ฐธ์กฐํ ํ์ผ๋ค์ ์ค์
// vi ํธ์ง๊ธฐ ์ฌ์ฉ
vi /etc/httpd/conf/httpd.conf
// Include conf.modules.d/*.conf ์ฐพ์์, ๋ฐ๋ก ์๋ ์์ฑ
# mod_jk ๋ชจ๋ ๋ถ๋ฌ์ค๊ธฐ
LoadModule jk_module modules/mod_jk.so
# workers ํ์ผ ๋ถ๋ฌ์ค๊ธฐ
JkWorkersFile conf/workers.properties
# mod_jk ์ฌํ์ผ ๋ถ๋ฌ์ค๊ธฐ
JkShmFile run/mod_jk.shm
# mod_jk ๋ก๊ทธํ์ผ ๋ถ๋ฌ์ค๊ธฐ
JkLogFile logs/mod_jk.log
# ๊ฐ์ ํธ์คํธ ์ค์ ํ๊ธฐ
<VirtualHost *:80>
JkMount /*.jsp tomcat
JkMount /*.json tomcat
JkMount /*.xml tomcat
JkMount /*.do tomcat
JkMount /*.jspx tomcat
</VirtualHost>
๐ Tomcat ์ค์ ํ์ผ ์์
vi /usr/local/tomcat(ํด๋น๋ฒ์ )/conf/server.xml
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector protocol="AJP/1.3"
address="::1"
port="8009"
redirectPort="8443" />
AJP ํฌํธ ์ค์ ํ๊ธฐ
8009 ํฌํธ๋ฅผ ์ฌ์ฉํ๋ค.
Apache ์ค์ ํ์ผ ์์ฑ
vim /etc/httpd/conf.d/mod_jk.conf
LoadModule jk_module modules/mod_jk.so
<ifModule jk_module>
JkWorkersFile conf.d/workers.properties
JkShmfile logs/mod_jk.shm
JkLogfile logs/mode_jk.log
JkLogLevel error
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
</ifModule>
๋ฐ์ํ