리눅스에서 활성화된/로드된 Apache 모듈 확인하는 방법

이 가이드에서는 Apache 웹 서버 프론트엔드에 대해 간단히 이야기하고, 서버에서 어떤 Apache 모듈이 활성화되어 있는지 확인하거나 나열하는 방법을 설명할 것입니다.

Apache는 모듈화의 원칙을 기반으로 구축되어 있어, 웹 서버 관리자가 다양한 모듈을 추가하여 기본 기능을 확장하고 Apache 성능을 향상시킬 수 있습니다.

추천 읽기: Apache 웹 서버의 성능을 높이는 5가지 팁

일반적인 Apache 모듈에는 다음이 포함됩니다.

  1. mod_sslApache에 대한 HTTPS를 제공합니다.
  2. mod_rewrite – 이는 url 패턴을 정규 표현식으로 일치시키고, .htaccess 트릭을 사용하여 투명한 리디렉션을 수행하거나 HTTP 상태 코드 응답을 적용할 수 있습니다.
  3. mod_security – 이를 통해 Apache를 무차별 대입 공격이나 DDoS 공격으로부터 보호할 수 있습니다.
  4. mod_status – 이를 통해 Apache 웹 서버 부하와 페이지 통계를 모니터링할 수 있습니다.

리눅스에서는 apachectl 또는 apache2ctl 명령을 사용하여 Apache HTTP 서버 인터페이스를 제어합니다. 이는 Apache의 프론트 엔드입니다.

$ apache2ctl help
OR
$ apachectl help
apachectl help
Usage: /usr/sbin/httpd [-D name] [-d directory] [-f file]
                       [-C "directive"] [-c "directive"]
                       [-k start|restart|graceful|graceful-stop|stop]
                       [-v] [-V] [-h] [-l] [-L] [-t] [-S]
Options:
  -D name            : define a name for use in  directives
  -d directory       : specify an alternate initial ServerRoot
  -f file            : specify an alternate ServerConfigFile
  -C "directive"     : process directive before reading config files
  -c "directive"     : process directive after reading config files
  -e level           : show startup errors of level (see LogLevel)
  -E file            : log startup errors to file
  -v                 : show version number
  -V                 : show compile settings
  -h                 : list available command line options (this page)
  -l                 : list compiled in modules
  -L                 : list available configuration directives
  -t -D DUMP_VHOSTS  : show parsed settings (currently only vhost settings)
  -S                 : a synonym for -t -D DUMP_VHOSTS
  -t -D DUMP_MODULES : show all loaded modules 
  -M                 : a synonym for -t -D DUMP_MODULES
  -t                 : run syntax check for config files

apache2ctl은 두 가지 모드에서 작동할 수 있습니다. Sys V init 모드와 pass-through 모드입니다. SysV init 모드에서는 apache2ctl이 아래와 같은 형식의 간단한 한 단어 명령을 수행합니다.

$ apachectl command
OR
$ apache2ctl command

예를 들어, Apache를 시작하고 상태를 확인하려면 루트 사용자 권한으로 다음 두 명령을 실행하십시오. 일반 사용자인 경우 sudo 명령을 사용합니다.

$ sudo apache2ctl start
$ sudo apache2ctl status
Check Apache Status
tecmint@TecMint ~ $ sudo apache2ctl start
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
httpd (pid 1456) already running
tecmint@TecMint ~ $ sudo apache2ctl status
Apache Server Status for localhost (via 127.0.0.1)

Server Version: Apache/2.4.18 (Ubuntu)
Server MPM: prefork
Server Built: 2016-07-14T12:32:26

-------------------------------------------------------------------------------

Current Time: Tuesday, 15-Nov-2016 11:47:28 IST
Restart Time: Tuesday, 15-Nov-2016 10:21:46 IST
Parent Server Config. Generation: 2
Parent Server MPM Generation: 1
Server uptime: 1 hour 25 minutes 41 seconds
Server load: 0.97 0.94 0.77
Total accesses: 2 - Total Traffic: 3 kB
CPU Usage: u0 s0 cu0 cs0
.000389 requests/sec - 0 B/second - 1536 B/request
1 requests currently being processed, 4 idle workers

__W__...........................................................
................................................................
......................

Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process

pass-through 모드에서 작동할 때, apache2ctl은 다음 구문의 모든 Apache 인수를 사용할 수 있습니다.

$ apachectl [apache-argument]
$ apache2ctl [apache-argument]

모든 Apache 인수는 다음과 같이 나열될 수 있습니다.

$ apache2 help    [On Debian based systems]
$ httpd help      [On RHEL based systems]

활성화된 Apache 모듈 확인

따라서 Apache 웹 서버에서 활성화된 모듈을 확인하려면 해당 배포판에 대해 아래 명령을 실행하십시오. 여기서 -t -D DUMP_MODULES는 모든 활성화된/로드된 모듈을 표시하는 Apache 인수입니다.

---------------  On Debian based systems --------------- 
$ apache2ctl -t -D DUMP_MODULES   
OR 
$ apache2ctl -M
---------------  On RHEL based systems --------------- 
$ apachectl -t -D DUMP_MODULES   
OR 
$ httpd -M
$ apache2ctl -M
List Apache Enabled Loaded Modules
[root@tecmint httpd]# apachectl -M
Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authn_file_module (shared)
 authn_alias_module (shared)
 authn_anon_module (shared)
 authn_dbm_module (shared)
 authn_default_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 authz_owner_module (shared)
 authz_groupfile_module (shared)
 authz_dbm_module (shared)
 authz_default_module (shared)
 ldap_module (shared)
 authnz_ldap_module (shared)
 include_module (shared)
....

그게 전부야! 이 간단한 튜토리얼에서는 Apache 프론트엔드 도구를 사용하여 활성화된/로드된 Apache 모듈을 나열하는 방법을 설명했습니다. 이 가이드와 관련된 궁금한 점이나 의견을 보내려면 아래 피드백 양식을 사용하여 연락할 수 있다는 것을 기억해주세요.

Source:
https://www.tecmint.com/check-apache-modules-enabled/