본문 바로가기

Operating Systems/Linux

[ Linux ] Tomcat 컨테이너 추가

[ APACHE 서버 ]

mkdir -p /app/server/tomcat/instance/server11 /app/server/tomcat/instance/server12

cp -r /app/server/tomcat/release/webapps/ROOT /app/server/tomcat/instance/server11/

cp -r /app/server/tomcat/release/webapps/ROOT /app/server/tomcat/instance/server12/

cat <<TOMCAT_SETTING > /app/server/tomcat/release/conf/server.xml
<?xml version="1.0" encoding="UTF-8" ?>
<Server port="8005" shutdown="SHUTDOWN">
$(printf '\t')<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
$(printf '\t')<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
$(printf '\t')<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
$(printf '\t')<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
$(printf '\t')<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
$(printf '\t')<GlobalNamingResources>
$(printf '\t')$(printf '\t')<Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" />
$(printf '\t')</GlobalNamingResources>
$(printf '\t')<Service name="server11">
$(printf '\t')$(printf '\t')<Connector port="8180" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8543" />
$(printf '\t')$(printf '\t')<Connector executor="tomcatThreadPool" port="8180" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8543" />
$(printf '\t')$(printf '\t')<Connector protocol="AJP/1.3" port="8109" address="0.0.0.0" secretRequired="false" redirectPort="8543" />
$(printf '\t')$(printf '\t')<Engine name="server11" defaultHost="localhost">
$(printf '\t')$(printf '\t')$(printf '\t')<Realm className="org.apache.catalina.realm.LockOutRealm">
$(printf '\t')$(printf '\t')$(printf '\t')$(printf '\t')<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase" /></Realm>
$(printf '\t')$(printf '\t')$(printf '\t')<Host name="localhost" appBase="/app/server/tomcat/instance/server11" unpackWARs="true" autoDeploy="true">
$(printf '\t')$(printf '\t')$(printf '\t')$(printf '\t')<Context path="/" reloadable="true" docBase="./ROOT" allowLinking="true" />
$(printf '\t')$(printf '\t')$(printf '\t')$(printf '\t')<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
$(printf '\t')$(printf '\t')$(printf '\t')</Host>
$(printf '\t')$(printf '\t')</Engine>
$(printf '\t')</Service>
$(printf '\t')<Service name="server12">
$(printf '\t')$(printf '\t')<Connector port="8280" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8643" />
$(printf '\t')$(printf '\t')<Connector executor="tomcatThreadPool" port="8280" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8643" />
$(printf '\t')$(printf '\t')<Connector protocol="AJP/1.3" port="8209" address="0.0.0.0" secretRequired="false" redirectPort="8643" />
$(printf '\t')$(printf '\t')<Engine name="server12" defaultHost="localhost">
$(printf '\t')$(printf '\t')$(printf '\t')<Realm className="org.apache.catalina.realm.LockOutRealm">
$(printf '\t')$(printf '\t')$(printf '\t')$(printf '\t')<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase" /></Realm>
$(printf '\t')$(printf '\t')$(printf '\t')<Host name="localhost" appBase="/app/server/tomcat/instance/server12" unpackWARs="true" autoDeploy="true">
$(printf '\t')$(printf '\t')$(printf '\t')$(printf '\t')<Context path="/" reloadable="true" docBase="./ROOT" allowLinking="true" />
$(printf '\t')$(printf '\t')$(printf '\t')$(printf '\t')<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
$(printf '\t')$(printf '\t')$(printf '\t')</Host>
$(printf '\t')$(printf '\t')</Engine>
$(printf '\t')</Service>
</Server>
TOMCAT_SETTING

cat <<APACHE_SETTING > /app/server/apache/release/conf/workers.properties
worker.list=server11 server12

worker.server11.port=8109
worker.server11.host=localhost
worker.server11.type=ajp13
worker.server11.lbfactor=1

worker.server12.port=8209
worker.server12.host=localhost
worker.server12.type=ajp13
worker.server12.lbfactor=1
APACHE_SETTING

cat <<APACHE_SETTING > /app/server/apache/release/conf/server11.properties
/*=server11
APACHE_SETTING

cat <<APACHE_SETTING > /app/server/apache/release/conf/server12.properties
/*=server12
APACHE_SETTING

sed -i '/^<IfModule\s*jk_module>/,/<\/IfModule>/d' /app/server/apache/release/conf/httpd.conf

sed -i "s/^Include\s*conf\/extra\/httpd-server11.conf//g" /app/server/apache/release/conf/httpd.conf

sed -i "s/^Include\s*conf\/extra\/httpd-server12.conf//g" /app/server/apache/release/conf/httpd.conf

cat <<APACHE_SETTING >> /app/server/apache/release/conf/httpd.conf
<IfModule jk_module>
$(printf '\t')JkWorkersFile conf/workers.properties
$(printf '\t')JkLogFile logs/mod_jk.log
$(printf '\t')JkLogLevel info
$(printf '\t')JkLogStampFormat "[%y %m %d %H:%M:%S] "
$(printf '\t')JkShmFile logs/mod_jk.shm
</IfModule>

Include conf/extra/httpd-server11.conf
Include conf/extra/httpd-server12.conf
APACHE_SETTING

cat <<APACHE_SSL_SETTING > /app/server/apache/release/conf/extra/httpd-server11.conf
Listen 1443 https
SSLPassPhraseDialog  builtin
SSLSessionCache "shmcb:/app/server/apache/2.4.55/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300
SSLCryptoDevice builtin

<VirtualHost *:1443>
$(printf '\t')DocumentRoot "/app/server/tomcat/instance/server11/"

$(printf '\t')SSLEngine on
$(printf '\t')SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
$(printf '\t')SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW

$(printf '\t')SSLCertificateFile /app/cert/apache/cert.pem
$(printf '\t')SSLCertificateKeyFile /app/cert/apache/privkey.pem
$(printf '\t')SSLCACertificateFile /app/cert/apache/chain.pem

$(printf '\t')<Files ~ "\.(cgi|shtml|phtml|php3?)$">
$(printf '\t')$(printf '\t')SSLOptions +StdEnvVars
$(printf '\t')</Files>
$(printf '\t')<Directory />
$(printf '\t')Order allow,deny
$(printf '\t')Allow from all
$(printf '\t')Require all granted
$(printf '\t')</Directory>
$(printf '\t')<Directory "/app/server/apache/release/cgi-bin">
$(printf '\t')$(printf '\t')SSLOptions +StdEnvVars
$(printf '\t')</Directory>
$(printf '\t')SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
$(printf '\t')ErrorLog logs/ssl_error_log
$(printf '\t')TransferLog logs/ssl_access_log
$(printf '\t')LogLevel warn
$(printf '\t')CustomLog logs/ssl_request_log    "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
$(printf '\t')JkMountFile /app/server/apache/release/conf/server11.properties

</VirtualHost>
APACHE_SSL_SETTING

cat <<APACHE_SSL_SETTING > /app/server/apache/release/conf/extra/httpd-server12.conf
Listen 2443 https
SSLPassPhraseDialog  builtin
SSLSessionCache "shmcb:/app/server/apache/2.4.55/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300
SSLCryptoDevice builtin

<VirtualHost *:2443>
$(printf '\t')DocumentRoot "/app/server/tomcat/instance/server11/"

$(printf '\t')SSLEngine on
$(printf '\t')SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
$(printf '\t')SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW

$(printf '\t')SSLCertificateFile /app/cert/apache/cert.pem
$(printf '\t')SSLCertificateKeyFile /app/cert/apache/privkey.pem
$(printf '\t')SSLCACertificateFile /app/cert/apache/chain.pem

$(printf '\t')<Files ~ "\.(cgi|shtml|phtml|php3?)$">
$(printf '\t')$(printf '\t')SSLOptions +StdEnvVars
$(printf '\t')</Files>
$(printf '\t')<Directory />
$(printf '\t')Order allow,deny
$(printf '\t')Allow from all
$(printf '\t')Require all granted
$(printf '\t')</Directory>
$(printf '\t')<Directory "/app/server/apache/release/cgi-bin">
$(printf '\t')$(printf '\t')SSLOptions +StdEnvVars
$(printf '\t')</Directory>
$(printf '\t')SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
$(printf '\t')ErrorLog logs/ssl_error_log
$(printf '\t')TransferLog logs/ssl_access_log
$(printf '\t')LogLevel warn
$(printf '\t')CustomLog logs/ssl_request_log    "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
$(printf '\t')JkMountFile /app/server/apache/release/conf/server12.properties

</VirtualHost>
APACHE_SSL_SETTING