Open BlueDragon의 설치파일의 하나인 Viviotech의 Installer는 Tomcat에 내장되어 바로 Apache웹서버와 연동을 해주는 매우 편리한 설치본입니다. 원래 Open BD 역시 J2EE Servlet등에서 Deploy하기 위한 웹아카이브(war)파일로 배포하는 것이 원본이기는 하지만 Tomcat/apache웹서버의 설치 및 연동이 좀 까다롭기에 이를 쉽게 설치할 수 있도록 만든 것이라고 이전글에서 소개한바 있습니다.
Railo 버전 역시 동일한 Installer로도 제공하므로 쉽게 설정할 수 있습니다. 때에 따라서는 단순히 Tomcat의 JSP를 이용할때도 사용할 수 있겠네요. JSP만 이용해도 되니까요. 다만, 이 Installer는 기본 Servlet엔진이 Tomcat이므로 다른 J2EE엔진이나 이미 설치된 J2EE엔진에 Open BD를 적용하려면 Open BlueDragon홈페이지에서 웹아카이브(war)파일을 적용하면 됩니다.
오늘은 실제 Server환경에서 어떻게 설치하고 적용하는지 그리고, Apache의 가상호스트마다 또는 가상호스트가 추가될때마다 어떻게 적용하는지 알아보도록 하겠습니다.
우선 서버환경이 Ubuntu Server 64bit라고 가정하겠습니다. APM은 기본 APT관리자로 설치되어 있다고 가정하겠습니다. Ubuntu에서 APM의 설정방법은 Ubuntu Server APM 기본 패키지 설치 명령어들을 참조하세요. 이왕이면 Sun JDK 같이 먼저 설치합니다.
자, 우선 SFTP 또는 FTP를 이용하여 openbd-1.3-pl0-linux-x64-installer.bin 파일을 업로드합니다. Vivitech의 Open BlueDragon 홈페이지에서 미리 openbd-1.3-pl0-linux-x64-installer.bin 파일을 다운로드해 둡니다.(http://openbd.viviotech.net) 이 파일을 자신의 홈디렉토리로 업로드합니다. 물론 wget 등으로 서버상에서 직접 다운로드할 수 도 있습니다.
SSH로 로그인하여 작업할 준비가 다되었습니다. SSH는 반드시 root권한으로 로그인하고 설치 역시 root권한으로 해야합니다. 서버는 현재 APM과 JDK만 깔려있는 상태가 되어 있습니다. 이하의 대화형 쉘은 Open BD의 설치스크립트입니다. 다음과 같이 755권한을 주고 설치명령을 줍니다.
sudo chmod 755 openbd-1.3-pl0-linux-x64-installer.bin
sudo ./openbd-1.3-pl0-linux-x64-installer.bin
----------------------------------------------------------------------------
Welcome to the Open BlueDragon Setup Wizard.
----------------------------------------------------------------------------
Please specify the directory where Open BlueDragon will be installed.
기본설치경로를 지정합니다. 기본값은 /opt/openbd 입니다.
Installation Directory [/opt/openbd]: /opt/openbd
----------------------------------------------------------------------------
Tomcat Administrator Username
Tomcat includes a web interface that can be used to manage some aspects of your Tomcat server. Please enter the username that you would like to use to access that web based administrator.
Tomcat관리자 아이디를 지정합니다. 기본값은 admin입니다.
Tomcat Administrator Username [admin]: admin
----------------------------------------------------------------------------
Tomcat Administrator Password
Now I need a password for the Tomcat Administrator...
Tomcat관리자 패스워드를 임의로 지정합니다.
Tomcat Administrator Password []: Password입력
----------------------------------------------------------------------------
Tomcat Port
What port number do you want Tomcat to listen to? This will be the port that you will use to access both Tomcat's Web Administrator and OpenBD's Web Administrator. If you're not sure what this is, just leave it set to it's default value.
Tomcat 기본 포트를 지정합니다. 기본값은 8888입니다.
Tomcat Port [8888]: 8888
----------------------------------------------------------------------------
OpenBD Administrator Password
OpenBD comes with a web-based administrator that allows you to control how your instance of OpenBD performs. Please enter a secure password that you will use to access your OpenBD Administrator below.
OpenBD의 관리자 패스워드를 지정합니다. 매우 중요하며, 분실해서는 아니됩니다.
OpenBD Administrator Passowrd []: Password입력
----------------------------------------------------------------------------
Start At Boot?
Do you want OpenBD to start up automatically whenever the system boots up?
OpenBD를 부팅시 자동으로 실행하도록 실행스크립트를 작성하겠느냐는 질문입니다.
이를 N하면 부팅시 매번 수동으로 OpenBD를 구동해야 하므로 Y로 입력합니다.
Yes, Start OpenBD at Boot Time [Y/n]: y
----------------------------------------------------------------------------
Install Apache Connector?
The Apache connector is needed for most installs. The only time it is not needed is if you are not using Apache as your primary web server. If you're not sure what to do here, please install the connector.
Apache2웹서버와 연동모듈을 설치하겠느냐는 질문입니다. Y를 입력합니다.
Install Apache Connector? [Y/n]: y
----------------------------------------------------------------------------
Apache Version Number
Please select the version of Apache that is running on your computer.
Apache 웹서버의 버전을 물어봅니다. 자신의 버전을 입력합니다.
일반적으로 Ubuntu에서 APT관리기로 APM를 설치하면 Apache 2.2가 설치됩니다.
Apache Version Number
[1] Apache 2.2
[2] Apache 2.0
[3] Apache 1.3
Please choose an option [1] : 1
----------------------------------------------------------------------------
Choose Bit Type
Please verify the bit-type you're wanting to install. For example, even tough you may be running on a 64-bit server, under some circumstances you may need to install the 32-bit version of the Apache connector.
서버의 아키텍쳐를 물어보는 질문입니다. 32/64bit 구분하여 입력합니다.
만약 모를 경우 쉘상태에서 arc 명령어로 알 수 있습니다.
Bit Type
[1] 32-bit: 32-bit
[2] 64-bit: 64-bit
Please choose an option [2] : 2
----------------------------------------------------------------------------
Apache Control Script Location
Please enter the location of your apache control script. The default location for this script is "/etc/init.d/httpd" in CentOS and "/etc/init.d/apache2" in Ubuntu.
Apache2의 구동파일의 위치가 어디냐고 물어보는 질문입니다.
바로 위에서 일반적인 CentOS와 Ubuntu에서의 경로를 알려주고 있습니다.
여기서는 우분투이므로 /etc/init.d/apache2입니다.
Apache Control Script Location [/etc/init.d/httpd]: /etc/init.d/apache2
----------------------------------------------------------------------------
Apache Modules Directory
Please enter the directory that apache stores it's modules in. By default, this directory is located at "/usr/lib/httpd/modules/" for RHEL/CentOS, and "/usr/lib/apache2/modules/" for Ubuntu. For 64-bit systems, try changing the "lib" directory to "lib64".
Apache2와 Tomcat 연동모듈인 mod_jk의 위치가 어디냐고 물어보는 질문입니다.
우분투64비트 기본값은 /usr/lib64/apache2/modules/입니다.
(32비트는 /usr/lib/apache2/modules/입니다.)
Apache Modules Directory [/usr/lib/httpd/modules]: /usr/lib64/apache2/modules/
----------------------------------------------------------------------------
Apache Configuration File
The Apache configuration file controls how Apache processes incoming requests. The default location of the Apache configurtion file is "/etc/httpd/conf/httpd.conf" on RHEL/CentOS and "/etc/apache2/apache2.conf" on Ubuntu.
Apache2 설정파일의 위치를 묻는 질문입니다.
우분투 기본값은 /etc/apach2/apache.conf 입니다.
Apache Configuration File [/etc/httpd/conf/httpd.conf]: /etc/apache2/apache2.conf
----------------------------------------------------------------------------
Apache Logs Directory
Please enter the directory that apache stores it's log files in. By default, this directory is located at "/var/log/httpd/" for RHEL/CentOS, and "/var/log/apache2/" for Ubuntu. The installer needs this to properly install the Apache-Tomcat connector (mod_jk).
Apache2로그 디렉토리의 경로를 묻는 질문입니다. 기본경로를 지정합니다.
Apache Logs Directory [/var/log/httpd]: /var/log/apache2/
----------------------------------------------------------------------------
Setup is now ready to begin installing Open BlueDragon on your computer.
설치하겠느냐는 질문입니다. y를 입력하고 설치를 시작합니다.
Do you want to continue? [Y/n]: y
----------------------------------------------------------------------------
Please wait while Setup installs Open BlueDragon on your computer.
Installing
0% ______________ 50% ______________ 100%
#########################################
----------------------------------------------------------------------------
Setup has finished installing Open BlueDragon on your computer.
자, 설치가 모두 끝났습니다. /etc/apache2/apache.conf과 httpd.conf 파일에 mod_jk모듈을 로드하는 구문이 추가되어있는지 확인합니다. 기본적으로 /opt/openbd가 Open BD의 기본설치경로가 되고, 구동/중지파일은 시스템부팅시 바로 구동되도록 /etc/init.d/안에 openbd_ctl 파일명으로 저장되어 있습니다. 따라서 Open BD를 시작/중지/재시작하려면 /etc/init.d에서 sudo ./openbd_ctl start|stop|restart 하시면 됩니다.
자, Apache2의 가상호스트에서 cfm파일과 cfc파일 그리고 OpenBD에서 독특하게 쓰이는 cfvideoplayer 태그를 위한 cfres문서를 Apche의 가상호스트 설정파일에 추가해 줍니다. 다음의 예를 참조하세요.
DirectoryIndex index.htm index.html index.cfm index.cfml index.cfc index.cfres index.php
이제 apache의 가상호스트에 맞춰 tomcat의 가상호스트를 추가해야 합니다. Open BD의 기본설치경로인 /opt/openbd/tomcat/conf/ 안의 server.xml 파일을 vi로 열어 <host>를 추가해 줍니다. 예로 아래와 같이 작성하여 추가합니다.
<Host name="sampledomain.com"
appBase="webapps"
unpackWARs="true"
autoDeploy="true"
xmlValidation="false"
xmlNamespaceAware="false">
<Context path="" docBase="/home/sample/www/" />
<Alias>www.sampledomain.com</Alias>
</Host>
여기서 중요한 것은 Host name입니다. 이 부분은 apache2의 가상호스트의 Name기반 가상호스트명과 일치해야 합니다. 가령, apache2의 Vhost의 ServerName이 sample.com이라면 Tomcat의 Vhost에서도 sample.com이라고 해야지 www.sample.com과 같이 지정하면 안된다는 것입니다. ServeAlias나 Tomcat의 Alias 역시 위 예와 같이 지정합니다. 이 부분은 Open BD가 아니더라도 Tomcat 및 대부분의 J2EE에서 동일하게 설정하는 부분이니 주의하여 설정하시길 바랍니다.
이제, Open BD의 설치경로 /opt/openbd/tomcat/webapps/ROOT 안의 bluedragon 디렉토리와 WEB-INF 디렉토리를 자신의 웹루트 디렉토리에 복사해 줍니다. bluedragon는 각각의 가상호스트별 OpenBD의 웹관리자입니다. Adobe ColdFusion 및 Railo에서의 Context와 같은 것이므로 이 관리자에서 DSN(Data Source Name)이나 Mail 등을 설정하게 됩니다. 복사를 완료하고 나면 이제 Open BD와 Apache2를 재시작해 줍니다. /etc/init.d에서 sudo ./apache2 restart 와 sudo ./openbd_ctl restart해주면됩니다.
그런다음 정상적으로 cfm파일을 해석하는지 다음과 같은 index.cfm 파일을 작성하여 웹루트에 업로드한 다음 브라우저에서 호출해 봅니다. 에러없이 도메인과 User Agent가 나타나면 정상적으로 설치된 것입니다.
<cfset siteName = #SERVER_NAME#>
<cfoutput><h1>#siteName#</h1></cfoutput>
<p>
<cfoutput>http://#SERVER_NAME#<cfif #SERVER_PORT# NEQ "80">:#SERVER_PORT#</cfif>#SCRIPT_NAME#<cfif #QUERY_STRING# NEQ "">?#QUERY_STRING#</cfif></cfoutput>
</p>
<p>
<cfdump var = #CGI.HTTP_USER_AGENT#>
</p>