remark :
WAS (톱켓) 8080 포트 대신 80 포트로 변환기하 위해 Tomcat Connectors 인 mod_jk를 세팅해 보자.
1. Download Site link : https://tomcat.apache.org/download-connectors.cgi
2. Download /tmp
1 2 3 4 |
# cd /tmp # wget http://mirror.apache-kr.org/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.48-src.tar.gz |
3. tar 풀기
1 2 3 |
# tar xvfz tomcat-connectors-1.2.48-src.tar.gz |
4. configure 명령어를 이용해서 make 파일 생성
1 2 3 4 5 6 7 8 9 10 11 12 |
# cd /tmp # cd tomcat-connectors-1.2.48-src # cd native # ./buildconf.sh # ./configure --with-apxs=/usr/bin/apxs # make # make install |
4.1 Error solution
1 2 3 4 5 6 |
configure: error: Invalid location for apxs: '/usr/bin/apxs' # yum install httpd-devel |
4.2 mod_jk.so file check
1 2 3 4 5 |
# ls -1 /etc/httpd/modules/mod_jk.so /etc/httpd/modules/mod_jk.so |
5. mod_jk.conf configuration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# vi /etc/httpd/conf.modules.d/mod_jk.conf LoadModule proxy_module modules/mod_proxy.so LoadModule rewrite_module modules/mod_rewrite.so LoadModule jk_module /etc/httpd/modules/mod_jk.so JkWorkersFile /etc/httpd/conf/workers.properties JkShmFile /var/run/httpd/mod_jk.shm JkLogFile /var/log/httpd/mod_jk.log JkLogLevel info JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " JkRequestLogFormat "%w %V %T" |
6. workers.properties configuration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# vi /etc/httpd/conf/workers.properties workers.tomcat_home=/opt/tomcat workers.java_home=/usr/lib/jvm/java-1.8.0-openjdk ps=/ #worker.apache_log=/var/log/httpd worker.list=ajp13_worker worker.ajp13_worker.port=8009 worker.ajp13_worker.host=localhost worker.ajp13_worker.type=ajp13 worker.ajp13_worker.lbfactor=1 worker.loadbalancer.type=lb worker.loadbalancer.balance_workers=ajp13_worker |
7. Tomcat8 server.xml configuration add
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# vim /opt/tomcat/conf/server.xml //tomcat 경로 찾아서 <!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8" useBodyEncodingForURI="true" /> <!-- 또는 secret로 세팅 --> <Connector port="8009" protocol="AJP/1.3" secret="ajpSecretKey" address="::1" secretRequired="true" redirectPort="8443" URIEncoding="UTF-8" useBodyEncodingForURI="true" /> |
8. virtual Site Setting
1 2 3 4 |
sudo mkdir /etc/httpd/sites-available sudo mkdir /etc/httpd/sites-enabled |
1 2 3 4 5 6 7 |
# sudo vim /etc/httpd/conf/httpd.conf #Add this line to the end of the file: IncludeOptional sites-enabled/*.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# vi /etc/httpd/sites-available/jsp.conf <VirtualHost *:80> ServerName jsp.test.co.kr #ServerAlias jsp.test.co.kr ServerAdmin root@localhost DocumentRoot /var/www/jsp/ROOT <IfModule mod_jk.c> JKMount / ajp13_worker JKMount /* ajp13_worker </IfModule> ErrorLog /var/log/httpd/error.log CustomLog /var/log/httpd/access.log combined <Directory /var/www/jsp/ROOT > Options FollowSymLinks AllowOverride None Order Deny,Allow Allow from all Require all granted </Directory> </VirtualHost> |
9. Tomcat Virtual Setting Site Add
1 2 3 4 5 6 7 8 9 10 |
vi /opt/tomcat/conf/server.xml //tomcat 경로 찾아서 <Host name="jsp.test.co.kr" appBase="/var/www/jsp" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> </Host> |
10. Site load ln -s
1 2 3 4 |
sudo ln -s /etc/httpd/sites-available/jsp.conf /etc/httpd/sites-enabled/jsp.conf |
11. Tomcat/ Apache restart
1 2 3 4 5 |
# systemctl restart tomcat # systemctl restart httpd |
12. port 8090 Check
tcp6 0 0 ::1:8009
1 2 3 4 5 6 7 8 9 10 11 12 |
# netstat -tnlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 950/sshd tcp6 0 0 :::21 :::* LISTEN 5456/vsftpd tcp6 0 0 :::22 :::* LISTEN 950/sshd tcp6 0 0 ::1:8009 :::* LISTEN 2582/java tcp6 0 0 :::80 :::* LISTEN 2621/httpd tcp6 0 0 :::8080 :::* LISTEN 2582/java |
13. Error check: mod_jk.log
1 2 3 |
[info] jk_open_socket::jk_connect.c (815): connect to ::1:8009 failed (errno=111) |
tomcat(tcp6 :::8080) -> mod_jk (tcp6 ::1:8009) -> httpd (tcp6 :::80)
비고) 심볼릭 링크 삭세 -> 가상화를 삭제
1 2 3 |
rm -f /etc/httpd/sites-enabled/jsp.conf |
댓글