변군이글루

[app] nginx + tomcat(멀티 인스턴스) 설치 본문

서___리눅스

[app] nginx + tomcat(멀티 인스턴스) 설치

변군 변군이글루 2017.03.17 18:00

1. nginx 설치
[root@web01 ~]# yum install pcre-devel zlib-devel openssl-devel
[root@web01 ~]# mkdir /app
[root@web01 ~]# cd /app/

[root@web01 app]# tar xvfz nginx-1.10.3.tar.gz
[root@web01 app]# cd nginx-1.10.3
[root@web01 nginx-1.10.3]# ./configure --prefix=/app/nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module
[root@web01 nginx-1.10.3]# make && make install
[root@web01 nginx-1.10.3]# cd /app/nginx/sbin/
[root@web01 sbin]# /app/nginx/sbin/nginx
[root@web01 sbin]# ps -ef | grep nginx
root     12446     1  0 17:33 ?        00:00:00 nginx: master process /app/nginx/sbin/nginx
nobody   12447 12446  0 17:33 ?        00:00:00 nginx: worker process
root     12465  8135  0 17:33 pts/0    00:00:00 grep --color=auto nginx
[root@web01 sbin]# vi /app/nginx/conf/nginx.conf
 18
 19         upstream tomcat{
 20                 server 127.0.0.1:8081;
 21                 server 127.0.0.1:8082;
 22                 keepalive 10;
 23         }
 24
...
 49
 50         location / {
 51         #    root   html;
 52         #    index  index.html index.htm;
 53                 proxy_pass              http://tomcat;
 54                 proxy_redirect          off;
 55                 proxy_set_header        Host $host;
 56                 proxy_set_header        X-Real-IP $remote_addr;
 57                 proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
 58                 proxy_set_header        X-Forwarded-Proto $scheme;
 59         }
 60

2. java 설치
[root@web01 app]# tar xvfz jdk-8u111-linux-x64.tar.gz
[root@web01 app]# ln -s jdk1.8.0_111 java
[root@web01 app]# su - tomcat
[tomcat@web01 ~]$ vi .bashrc
---
## JAVA_HOME
export JAVA_HOME="/app/java"
export PATH="$PATH:$JAVA_HOME/bin"
---
[tomcat@web01 ~]$ source .bashrc

3. tomcat 설치
[root@web01 app]# tar xvfz apache-tomcat-8.0.38.tar.gz
[root@web01 app]# mv apache-tomcat-8.0.38 was01
[root@web01 app]# cp -rf was01 was02
[root@web01 app]# chown -R tomcat.tomcat was01 was02
[root@web01 app]# su - tomcat
[tomcat@web01 ~]$ vi /app/was01/conf/server.xml
---
 21  -->
 22 <Server port="8501" shutdown="SHUTDOWN">
 23   <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
...
 68     -->
 69     <Connector port="8081" protocol="HTTP/1.1"
 70                connectionTimeout="20000"
 71                redirectPort="8443" />
...
 90     <!-- Define an AJP 1.3 Connector on port 8009 -->
 91     <Connector port="8901" protocol="AJP/1.3" redirectPort="8443" />
 92
---
[tomcat@web01 ~]$ vi /app/was02/conf/server.xml
---
 21  -->
 22 <Server port="8502" shutdown="SHUTDOWN">
 23   <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
...
 68     -->
 69     <Connector port="8082" protocol="HTTP/1.1"
 70                connectionTimeout="20000"
 71                redirectPort="8443" />
...
 90     <!-- Define an AJP 1.3 Connector on port 8009 -->
 91     <Connector port="8902" protocol="AJP/1.3" redirectPort="8443" />
 92
---
[tomcat@web01 ~]$ cat .bashrc
---
## JAVA_HOME
export JAVA_HOME="/app/java"
export PATH="$PATH:$JAVA_HOME/bin"

## WAS startup/down script
alias was01_startup="/app/was01/bin/startup.sh"
alias was01_shutdown="/app/was01/bin/shutdown.sh -force"
alias was01_log="tail -f /app/was01/logs/catalina.out"

alias was02_startup="/app/was02/bin/startup.sh"
alias was02_shutdown="/app/was02/bin/shutdown.sh -force"
alias was02_log="tail -f /app/was02/logs/catalina.out"

alias all_startup="was01_startup && was02_startup"
alias all_shutdown="was01_shutdown && was02_shutdown"
alias all_log="was01_log && was02_log"
---
[tomcat@web01 ~]$ source .bashrc
[tomcat@web01 ~]$ all_startup
Using CATALINA_BASE:   /app/was01
Using CATALINA_HOME:   /app/was01
Using CATALINA_TMPDIR: /app/was01/temp
Using JRE_HOME:        /app/java
Using CLASSPATH:       /app/was01/bin/bootstrap.jar:/app/was01/bin/tomcat-juli.jar
Using CATALINA_PID:    /app/was01/logs/.tomcat_pid
Tomcat started.
Using CATALINA_BASE:   /app/was02
Using CATALINA_HOME:   /app/was02
Using CATALINA_TMPDIR: /app/was02/temp
Using JRE_HOME:        /app/java
Using CLASSPATH:       /app/was02/bin/bootstrap.jar:/app/was02/bin/tomcat-juli.jar
Using CATALINA_PID:    /app/was02/logs/.tomcat_pid
Tomcat started.

JSP 테이브 페이지
[tomcat@web01 ~]$ cat /app/was01/webapps/ROOT/index.jsp
<%@ page
    language="java"
    contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"
%><?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><title>TOMCAT devsp3(Instance1) - TOMCAT TEST</title></head>
<body><pre>
운영체제: <%=System.getProperty("os.arch")%>
데이터모델: <%=System.getProperty("sun.arch.data.model")%>
클래스경로: <%=System.getProperty("java.class.path",".")%>
라이브러리경로: <%=System.getProperty("java.library.path", ".")%>
파라메터: <%=request.getParameter("param")%> ('한글'이라고 표기되어야 함)

파일인코딩: <%=System.getProperty("file.encoding")%>
시스템캐릭터셋: <%=java.nio.charset.Charset.defaultCharset().name()%>
페이지캐릭터셋: <%=response.getCharacterEncoding()%>

서블릿 경로: <%=application.getRealPath("")%>
</pre></body>
</html>
[tomcat@web01 ~]$ cat /app/was02/webapps/ROOT/index.jsp

0 Comments
댓글쓰기 폼