본문 바로가기
기초 튼튼탄탄탄/서버, OS(리눅스)

웹서버(apache) / WAS(wildfly) / DB(MariaDB) 설치 및 연동하기

by 잇서니 2021. 1. 6.
반응형

 

개요

  • 웹사이트에 필요한 web서버, was, DB서버 설치 및 연동 과정을 정리한다.
  • 실습은 Virtual box를 사용하여 진행한다.
    • vm1 : web + was
    • vm2 : DB

 

리눅스 프로그램 설치방법

1) 소스 설치

  • 소스파일을 다운받아 직접 컴파일하여 프로그램을 설치하는 방법
  • 설치 시, 프로그램 환경설정이 가능 (./configure)
  • 의존성문제가 거의 없음
  • 컴파일러로 컴파일하여 설치하므로 시간이 오래걸림 (make, make install)
  • 환경설정을 잘못할 경우, 프로그램 설치가 안될 수도 있음

2) 바이너리 설치

  • 소스버전으로 설치된 프로그램의 디렉토리를 압축해놓은 파일을 이용하여 설치
  • 압축만 해제하면 설치 가능

3) 패키지 설치

  • rpm을 이용해서 프로그램 설치 및 삭제 등을 관리
  • 프로그램 의존성 문제 발생가능
  • yum : rpm 단점 (의존성문제)을 보완하는 패키지관리 프로그램

 


 

Apache web서버 설치 (vm #1)

소스 설치로 진행

 

1) 설치 전 환경 세팅 (root 유저로 수행)

# yum install gcc gcc-c++ openssl-devel make perl

# mkdir /apache /ap_log

# useradd apache

# passwd apache

# chown apache:apache /apache /ap_log

 

2) 소스 파일 다운로드 (apache 유저로 수행)

/apache/src/

  • httpd-2.4.33.tar.gz
  • tomcat-connectors-1.2.42-src.tar.gz
  • pcre-8.38.tar.gz
  • apr-1.5.2.tar.gz
  • apr-util-1.5.4.tar.gz

 

3) 압축해제 (apache 유저로 수행)

# tar xvzf httpd-2.4.33.tar.gz

# tar xvzf tomcat-connectors-1.2.42-src.tar.gz

# tar xvzf pcre-8.38.tar.gz

# tar xvzf apr-1.5.2.tar.gz

# tar xvzf apr-util-1.5.4.tar.gz

 

4) 빌드 (apache 유저로 수행)

  • pcre
# cd /apache/src/pcre-8.38 
# ./configure --prefix=/apache/pcre 
# make && make install

 

  • apr
# cd /apache/src/apr-1.5.2

# ./configure --prefix=/apache/apr

# make && make install

 

  • apr-util
# cd /apache/src/apr-util-1.5.4

# ./configure --prefix=/apache/apr-util --with-apr=/apache/apr

# make && make install

 

  • apache
# cd /apache/src/httpd-2.4.33

# ./configure --prefix=/apache/apache24 --with-apr=/apache/apr --with-apr-util=/apache/apr-util --with-pcre=/apache/pcre --enable-mpms-shared=all

# make && make install

 

  • tomcat connector
# cd /apache/src/tomcat-connectors-1.2.42-src/native

# ./configure --with-apxs=/apache/apache24/bin/apxs

# make && make install

 

 

5) httpd.conf 파일 수정

  • Listen : 웹 포트 (24589)
  • ServerAdmin : 웹서버 호스트네임 (apache@10.10.10.111)
  • User / Group : 웹서버를 기동할 유저/그룹 (apache / apache)

 

6) 웹서버 기동 및 정지

# /apache/apache24/bin/apachectl start

# /apache/apache24/bin/apachectl stop

 

 

7) 설치확인

  • httpd 프로세스 확인
# ps -ef | grep httpd

root 1937 1 0 08:29 ? 00:00:00 /apache/apache24/bin/httpd -k start

daemon 1938 1937 0 08:29 ? 00:00:00 /apache/apache24/bin/httpd -k start

daemon 1939 1937 0 08:29 ? 00:00:00 /apache/apache24/bin/httpd -k start

daemon 1940 1937 0 08:29 ? 00:00:00 /apache/apache24/bin/httpd -k start

root 2067 2031 0 08:30 pts/0 00:00:00 grep httpd

 

  • 웹브라우저 접속
    http://10.10.10.111:24589

 

2. Wildfly WAS 설치 (vm #1)

바이너리설치로 진행. (압축해제만 하면 설치 완료)

 

1) wildfly 개념

  • standalone 모드
    •  초기구성이 단순하다. 인스턴스가 독립적이므로 장애 확산범위가 좁다.
    •  서버를 일일이 관리해야 하므로 운영 비용이 높다.
  • domain 모드
    •  인스턴스들의 일괄관리가 가능하다.
    •  standalone모드보다 초기구성이 복잡하다. 잘못된 config가 전체에 영향을 미친다.

 

2) 바이너리 설치 (압축해제만 하면 설치완료)

  • wildfly-9.0.2.Final.zip
  • jdk-8u171-linux-x64.tar.gz
# mkdir /jboss

# unzip wildfly-9.0.2.Final.zip

# tar xvzf jdk-8u171-linux-x64.tar.gz

 

3) standalone 설정

VM 수가 적으므로 standalone 모드로 진행하기로 한다.

  • standalone.xml 구조 (/jboss/wildfly-9.0.2.Final/standalone/configuration/standalone.xml)
    • <extension> : 기본적인 모듈 리스트를 포함. 모듈 위치는 $WILDFLY_HOME/modules
    • <management> : security realms / audit log / management interfaces / the access control
    • <profile> : subsystem
    • <interface> : server network interface
    • <socket-binding> : 포트설정
  • 설정값 수정
    vm 환경인 관계로 모든 ip가 접속 가능하도록 함. <interface> 태그에 다음의 값을 수정한다.
    • jboss.bind.address.management : 0.0.0.0
    • jboss.bind.address : 0.0.0.0

      <socket-binding> 태그에 jboss.management.http.port : 29865 (default 9990) 값도 수정했다.

 

4) 관리용 계정 생성

  • 보안상 관리용 계정을 생성해야 관리페이지에 접속할 수 있다.
# cd /jboss/wildfly-9.0.2.Final/bin

# ./add-user.sh

What type of user do you wish to add?
a) Management User (mgmt-users.properties)
b) Application User (application-users.properties)
(a): a

Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username :

Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.

  • The password should be different from the username
  • The password should not be one of the following restricted values

    {root, admin, administrator}

  • The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
    Password :
  • /jboss/jboss/wildfly-9.0.2.Final/standalone/configuration/mgmt-users.properties 를 확인하면 생성된 유저정보가 있다.

 

5) WAS 기동 및 정지

# nohup /jboss/wildfly-9.0.2.Final/bin/standalone.sh &

# /jboss/wildfly-9.0.2.Final/bin/jboss-cli.sh --controller=10.10.10.111:29865 --connect --command=:shutdown

 

6) 설치 확인

  • 포트 확인

    # netstat -an | grep 29865

  • 생성한 관리용 계정으로 웹브라우저 접속 (10.10.10.111:29865)

 

 

3. MariaDB 설치 (vm #2)

패키지 설치로 진행.

설치

# yum install MariaDB-server

설치확인

# service mysql start

# mysql -uroot

 

4. WEB-WAS 연동

아파치 웹서버의 mod_jk 모듈과 ajp 프로토콜을 사용한다.

 

1) 사전 준비

  • tomcat-connectors-1.2.42-src.tar.gz 를 압축풀고 컴파일을 한다. (웹서버 설치시 미리 해놓은 상태임)
  • 컴파일을 하면, /apache/apache24/modules 에 mod.jk.so 파일이 생긴다.

 

2) 연동 설정

  • WAS 서버 (/jboss/wildfly-9.0.2.Final/standalone/configuration/standalone.xml)

ajp listener 설정만 추가해주면 된다. ajp 포트(8009)는 원래 설정되어 있다.

<subsystem xmlns="urn:jboss:domain:undertow:2.0">
<buffer-cache name="default"/>
<server name="default-server">
<ajp-listener name="ajp" scheme="http" socket-binding="ajp"/>
<http-listener name="default" socket-binding="http" redirect-socket="https"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>

.
.
</subsystem>

.

.

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="$

{jboss.socket.binding.port-offset:0}

">
        <socket-binding name="management-http" interface="management" port="$

{jboss.management.http.port:29990}

"/>
        <socket-binding name="management-https" interface="management" port="$

{jboss.management.https.port:9993}

"/>
        <socket-binding name="ajp" port="$

{jboss.ajp.port:8009}

"/>
        <socket-binding name="http" port="$

{jboss.http.port:28080}

"/>
        <socket-binding name="https" port="$

{jboss.https.port:8443}

"/>
        <socket-binding name="txn-recovery-environment" port="4712"/>
        <socket-binding name="txn-status-manager" port="4713"/>
        <outbound-socket-binding name="mail-smtp">
            <remote-destination host="localhost" port="25"/>
        </outbound-socket-binding>
    </socket-binding-group>
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="$

{jboss.socket.binding.port-offset:0}

">

        <socket-binding name="management-http" interface="management" port="$

{jboss.management.http.port:29865}

"/>

        <socket-binding name="management-https" interface="management" port="$

{jboss.management.https.port:9993}

"/>

        <socket-binding name="ajp" port="${jboss.ajp.port:8009}

"/>
.

.

</socket-binding-group>

 

  • 웹서버 (/apache/apache24/conf/httpd.conf)

LoadModule jk_module modules/mod_jk.so //mod_jk.so 파일을 불러옴

JkWorkersFile conf/workers.properties //웹서버와 연동할 worker들 (WAS)의 정보를 담고 있는 파일 명시

JkShmFile /ap_log/jk/shm/mod_jk.shm

JkLogFile /ap_log/jk/mod_jk.log JkLogLevel info

JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"

JkMount /* wlb //모든 형식의 파일들을 wlb라는 워커들(WAS)이 작업하도록 한다.

 

  • 웹서버 (/apache/apache24/conf/workers.properties)
worker.list=wlb worker.wlb.type=lb worker.wlb.balance_workers=portal11 # Node Configure worker.template.type=ajp13 worker.template.socket_timeout=300 worker.template.socket_keepalive=true worker.template.recovery_options=7 worker.template.ping_mode=A worker.template.ping_timeout=10000 worker.template.connection_pool_size=500 worker.template.connection_pool_minsize=300 worker.template.connection_pool_timeout=60 # Node Configure START worker.portal11.reference=worker.template worker.portal11.port=8009 worker.portal11.host=10.10.10.111 worker.portal11.lbfactor=1 # Session Cluster Configure worker.wlb.method=Session worker.wlb.sticky_session=true

 

5. WAS-DB 연동

WAS management 웹에 접속하여 설정한다.

 

<socket-binding name="management-http" interface="management" port="{jboss.management.http.port:29865}"/>

 

  • 드라이버 Deployment
    Deployments 메뉴 -> Add -> Upload a new deployment 
    드라이버 파일을 업로드한다. (mysql-connector-java-5.1.29.jar)

 

  • Datasource 추가
    Configuration 메뉴 -> Subsystem -> Datasources -> Non-XA -> Add
    DB종류 설정, Datasource 이름 등을 설정한다.

 

  • 연동 설정 및 확인
    Configuration 메뉴 -> Subsystem -> Datasources -> Non-XA -> View

connection탭] 커넥션 정보 설정 및 테스트

security 탭] 데이터베이스 접속 정보 설정

 

 

 

 

반응형

댓글