728x90

Aapche 서버를 3Tier 로 구성할 때 Apache + PHP-FPM 설정한 WAS 서버 환경 옵션을 제대로 처리를 못해서 이 문제 해결하는데 엄청 시간을 허비했다.

이 자료를 오픈할까 말까 엄청 고민했다.

아래 예시는 무료 인증서를 설치한 것 기준으로 작성된 Apache httpd.conf 와 관련 파일이다.

 

httpd.conf 설정사항

 

DocumentRoot "/home/httpd/test/www/htdocs"
 
# Further relax access to the default document root:
<Directory "/home/httpd/test/www/htdocs">
    Options +FollowSymLinks -Indexes
    AllowOverride All
    Require all granted
    <LimitExcept GET POST>
      Order deny,allow
      Deny from all
    </LimitExcept>
</Directory>
 
<IfModule dir_module>
    DirectoryIndex index.php index.html 
</IfModule>
 
<IfModule mime_module>
    TypesConfig /etc/mime.types
    #AddType application/x-gzip .tgz
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php .html .do
    AddType application/x-httpd-php-source .phps
    AddType text/css .css
    AddType text/javascript .js
    #AddHandler cgi-script .cgi
    #AddHandler type-map var
    #AddOutputFilter INCLUDES .shtml
</IfModule>
 

 

default.conf

<VirtualHost *:80> 
       DocumentRoot "/home/httpd/test/www/htdocs"
       ServerName test.abc.com
       ServerAlias test.abc.com
 
       ErrorLog /var/log/httpd/test-error.log
       CustomLog /var/log/httpd/test-access.log combined
 
RewriteEngine on
RewriteCond %{SERVER_NAME} =test.abc.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

 

 

default-le-ssl.conf

 

<IfModule mod_ssl.c>
<VirtualHost *:443> 
       DocumentRoot "/home/httpd/test/www/htdocs"
       ServerName test.abc.com
       ServerAlias test.abc.com
 
       ErrorLog /var/log/httpd/test-error.log
       CustomLog /var/log/httpd/test-access.log combined
 
SSLCertificateFile /etc/letsencrypt/live/test.abc.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/test.abc.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/test.abc.com/chain.pem
</VirtualHost>
</IfModule>
 

 

.htaccess

 

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{THE_REQUEST} !^(POST|GET)\ /.*\ HTTP/1\.1$
RewriteRule .* - [R=405,L]
 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ error.html?/$1 [QSA,PT,L]
</IfModule>

 

.htaccess 에서 error.html 대신에 index.php 로 하면 없는 파일을 검색 시 로그인 화면으로 이동하도록 처리하는 것도 좋은 방법인 거 같다.

'리눅스' 카테고리의 다른 글

일반사용자 root 권한 부여  (0) 2021.04.10
yum update 시 에러 Berkeley DB library error  (0) 2021.03.24
CentOS7 PHP-FPM 제거시  (0) 2021.02.16
CentOS7 nginx + PHP 7.3 설치  (0) 2020.12.28
CentOS7 기반 phpMyAdmin 설치  (0) 2020.12.18
블로그 이미지

Link2Me

,