Skip to content

Apache httpd

아파치 웹 서버(Apache Web Server)는 아파치 소프트웨어 재단에서 관리하는 http 웹 서버이다. BSD, 리눅스등 유닉스 계열 뿐 아니라 마이크로소프트 윈도나 노벨 넷웨어 같은 기종에서도 운용할 수 있다.

Categories

Service port

서비스 포트를 변경하고 싶을 때, httpd 루트 디렉토리의 /conf/httpd.conf파일의 Listen 항목을 수정하면 된다.

모듈의 유효성 검증

<IfModule>를 사용하면 모듈의 사용여부(유효성)을 검사할 수 있다.

<IfModule [MODULE_NAME]>
...
</IfModule>

Command line options

httpd -M
Dump a list of loaded Static and Shared Modules.
httpd -t
Uses the directives in the file config on startup.
apache2ctl -S
Get a list of all virtual hosts which are defined in all apache configuration files.

With OpenSSL

Apache를 OpenSSL과 함께 설치하기 위해 configure 옵션에 --with-openssl를 추가할 수 있다.

MAC OSX Commandline option

MAC OSX에서 정상적으로 설치되지 않아, Log message에 x86_64 Architecture 관련 에러가 발생할 경우 아래의 옵션을 추가하면 된다.

./configure darwin64-x86_64-cc -fPIC

Apache HTTPS 적용

CentOS에서는 기본 패키지에 mod_ssl이 포함되어 있지 않다. 아래와 같이 설치하면 된다.

$ yum install mod_ssl

Ubuntu

sudo a2enmod ssl
sudo a2ensite default-ssl
sudo service apache2 reload
sudo service apache2 restart

Apache HTTPS를 위한 SSL 인증서 적용 방법

OpenSSL 설치 및 인증서 생성 후 파일 복사.

$ sudo apt-get install openssl
## ...
$ sudo cp server.crt /etc/ssl/certs
$ sudo cp server.key /etc/ssl/private

Apache HTTP 2.x 설정

$ sudo a2ensite ssl <- /etc/apache2/mods-available/ssl 파일을 /etc/apache2/mods-enabled/ssl 파일에 링크시킴

Httpd-ssl.conf 설정

$ vi /etc/apache2/conf.d/httpd-ssl.conf

아래와 같이 수정한다.

<ifmodule ssl_module>
<VirtualHost _default_:443>
#   General setup for the virtual host
...
#   SSL Engine Switch:
#   Enable/Disable SSL for this virtual host.
SSLEngine on
SSLCertificateFile /etc/ssl/certs/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key

마지막으로 아파치를 재구동해준다.

$ sudo service apache2 restart

Troubleshooting

Apache httpd 사용중 발생할 수 있는 문제점에 대하여 정리한다.

(13) Permission denied

Unix계열 OS에서는 1024이하의 Well-known Port는 Root만 접근이 가능하다. 따라서 Root 계정으로 실행하면 된다.

Apache 2.4: 403 Status code

아파치 2.4.x 로 업데이트 한 후 발생할 수 있는 403 Forbidden 결과코드가 발생될 경우 아래와 같이 Require all granted를 추가하면 된다.

<Directory "your directory here">
   Order allow,deny
   Allow from all
   # New directive needed in Apache 2.4.3: 
   Require all granted
</Directory>

404 Not found

php와 같은 스크립트를 사용할 경우 실제 디렉터리로 존재하지 않는 경로를 집입할 겨우 404에러가 발생될 수 있다. 이 경우 Indexes옵션을 제거하면 된다.

<VirtualHost _default_:443>
    ...
    <Directory /var/www/html>
        Options -Indexes
        AllowOverride All
        <IfModule mod_authz_core.c>
            Require all granted
        </IfModule>
    </Directory>
    ...
</VirtualHost>

AH00548

설정파일을 테스트하면 아래와 같은 경고가 출력된다.

AH00548: NameVirtualHost has no effect and will be removed in the next release

차 후 NameVirtualHost는 사라질 예정이다. 이 구문은 제거해도 된다.

Favorite site

Log file management

Guide & Tip

References


  1. Www.superuser.co.kr.7z