아파치 설치 및 세팅 (사전준비 및 기동 permission 오류)
## 아파치 설치 전 준비
아파치를 세팅하기 전 mod_jk, mod_proxy, mod_proxy_ajp 사전 설치가 필요합니다.
mod_proxy, mod_proxy_ajp는 존재하므로 mod_jk만 수행하였습니다.
1. mod_jk 설치하려면 gcc, gcc-c++, httpd-devel 3가지가 필요합니다.
| $ yum install gcc gcc-c++ httpd-devel |
2. http://tomcat.apache.org/download-connectors.cgi
tomcat-connectors-1.2.48-src를 다운받아 압축을 푼 후 native 폴더로 이동합니다.
3. Makefile을 생성하기 위해 아래 명령어를 실행하며 옵션 내용은 Apache확장기능 설치를 도와주는 유틸리티의 경로입니다.
하지만 오류 발생..
find로 apxs 경로 확인 결과 /usr/bin이 아닌 /usr/sbin에 위치하고 있다는 것을 확인하고 경로를 수정하여 재실행 했습니다.
무사히 실행에 성공하였네요.
| $ ./configure --with-apxs=/usr/sbin/apxs |
4. make, make install
| $ make $ make install |
install 완료 후 /etc/httpd/modules에 mod_jk.so 파일이 생성된 것을 확인합니다.
## 아파치 설치 및 세팅
/etc/httpd에 기본 파일들은 설치
필요한 부분은 * 192.1.1.227 서버 참고 하여 세팅
1. /etc/httpd/conf/httpd.conf
| ServerRoot "/etc/httpd" Listen 0.0.0.0:80 Listen 0.0.0.0:443 Include conf.modules.d/*.conf User [user명] Group [group명] ServerAdmin root@localhost ServerName [도메인] #도메인은 vhost 파일에서 설정 ServerSignature Off ServerTokens Prod #개발서버인지 운영서버인지 표시 LoadModule jk_module modules/mod_jk.so #아파치 세팅 전 mod_jk 사전 설치를 해줘야 mod_jk.so가 생성된다.. Include "conf/vhosts/httpd-vhost.conf" Include "extra/httpd-ssl.conf" <Directory /> AllowOverride none Require all denied </Directory> DocumentRoot "/webapp/src" <Directory "/webapp/src/web"> Options None AllowOverride None Require all granted </Directory> <IfModule dir_module> DirectoryIndex index.html </IfModule> <Files ".ht*"> Require all denied </Files> #ErrorDocument 403 "/webapp/src/error.html" #ErrorDocument 404 "/webapp/src/error.html" ErrorLog "/log/web/error_log" LogLevel warn <IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> CustomLog "/log/web/access_log" combined </IfModule> <IfModule alias_module> ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" </IfModule> <Directory "/var/www/cgi-bin"> Options None AllowOverride None Require all granted </Directory> <IfModule mime_module> TypesConfig /etc/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType application/x-hwp .hwp .frm .hwt AddType application/mp4 .mp4 AddType video/mp4 .mp4 AddType text/html .shtml AddOutputFilter INCLUDES .shtml </IfModule> AddDefaultCharset UTF-8 <IfModule mime_magic_module> MIMEMagicFile conf/magic </IfModule> EnableSendfile on IncludeOptional conf.d/*.conf |
* 필요한 부분만 기록
2. /etc/httpd/conf/uri/uriworkermap_인스턴스명.properties
| /*.do=[인스턴스명] /*.jsp=[인스턴스명] /*.jspf=[인스턴스명] /*.json=[인스턴스명] |
3. /etc/httpd/conf/vhosts/httpd-vhosts.conf
| <VirtualHost ip:port> ServerName 도메인 DocumentRoot /webapp/src/ ErrorDocument 403 /webapp/src/error.html ErrorDocument 404 /webapp/src/error.html ErrorLog "|/usr/sbin/rotatelogs /log/web/error.log.%Y%m%d 86400" CustomLog "|/usr/sbin/rotatelogs /log/web/bd.log.%Y%m%d 86400" common JkMountFile conf/uri/uriworkermap_인스턴스명.properties <Directory "/webapp/src/"> Options None AllowOverride None Order deny,allow Allow from all </Directory> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*)$ https://%{HTTP_HOST}%{REQUEST_URI}? </VirtualHost> <VirtualHost ip:port> ServerName ip Redirect 403 / ErrorDocument 403 "Sorry, direct IP access not allowed." DocumentRoot /var/www/html UseCanonicalName Off UserDir Disabled </VirtualHost> |
4. /etc/httpd/conf/workers_jk.properties # WAS와 통신하기위해 PORT 지정
| worker.list=인스턴스명 worker.인스턴스명.port=통신포트 worker.인스턴스명.type=ajp13 worker.인스턴스.host=ip worker.인스턴스명.lbfactor=1 |
5. /etc/httpd/conf.d/userdir.conf
| <Directory "/webapp/src/"> AllowOverride FileInfo AuthConfig Limit Indexes Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Require method GET POST OPTIONS </Directory> |
6. /etc/httpd/extra/httpd-ssl.conf
| SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog SSLSessionCache shmcb:/run/httpd/sslcache(512000) SSLSessionCacheTimeout 300 SSLRandomSeed startup file:/dev/urandom 256 SSLRandomSeed connect builtin SSLCryptoDevice builtin <VirtualHost ip:port> DocumentRoot "/webapp/src/" JkMountCopy on ServerName 도메인 ServerAdmin @도메인 ErrorLog "|/usr/sbin/rotatelogs /log/web/ssl_error_log.%Y%m%d 86400" TransferLog "|/usr/sbin/rotatelogs /log/web/ssl_access_log.%Y%m%d 86400" LogLevel warn JkMountFile conf/uri/uriworkermap_인스턴스.properties SSLEngine on SSLProtocol ALL -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 +TLSv1.2 SSLHonorCipherOrder On SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4 SSLCompression off SSLCertificateFile "/etc/httpd/ssl/cert.pem" SSLCertificateKeyFile "/etc/httpd/ssl/key.pem" SSLCertificateChainFile "/etc/httpd/ssl/ThawteDigiCert-Newchain.pem" </VirtualHost> <VirtualHost ip:port> ServerName ip Redirect 403 / ErrorDocument 403 "Sorry, direct IP access not allowed." DocumentRoot /var/www/html UseCanonicalName Off UserDir Disabled </VirtualHost> #SSLCertificateFile, SSLCertificateKeyFile, SSLCertificateChainFile 경로에 붙여넣음 |
## 모든 세팅 완료 후 기동
| $ systemctl status httpd.service $ systemctl start httpd.service |
root 계정으로 실행했으나 permission 오류 발생했습니다.
확인 결과 selinux의 권한문제였고, 아래와 같이 해결했습니다.
방법1)
vi /etc/selinux/config
SELINUX=disabled
재부팅
방법2)
chcon -u system_u -r object_r -t httpd_modules_t /etc/httpd/modules/mod_jk.so
명령어실행
왠만해서는 disable 후 재부팅 권장합니다.
'MiddleWare > Apache, Tomcat' 카테고리의 다른 글
| apache tomcat release (0) | 2022.10.12 |
|---|---|
| 아파치 설치 중 /usr/bin/apxs를 찾지 못하는 경우 (0) | 2022.09.29 |
| WAS Tomcat Instance 서비스 포트 (2) | 2022.09.15 |
| tomcat DB Connection Pool 구성 (DB2, Oracle, MSSQL) (0) | 2022.09.14 |
| Tomcat 클러스터 구성 (톰캣 클러스터구성) (0) | 2022.09.05 |
댓글