创新路
我们一直在努力

如何查看 Apache 模块是否正常

Apache是基于模块化的理念而构建,这样就可以让管理员添加不同的模块来扩展Apache的主要的功能及增强性能。常见的 Apache 模块主要有:

1、mod_ssl – 提供了 HTTPS 功能。

2、mod_rewrite – 可以用正则表达式匹配 url 样式,并且使用 .htaccess 技 巧来进行透明转发,或者提供 HTTP 状态码回应。

3、mod_security – 用于保护 Apache 免于暴力破解或者 DDoS 攻击。

4、mod_status – 用于监测 Apache 的负载及页面统计。
在 Linux 中我们可以用apachectl或者apache2ct命令来控制管理Apache 服务器。

我们可以用下面的命令显示 apachectl 的使用信息:

[root@localhost ~]# 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] [-T] [-S] [-X]

Options:

-D name            : define a name for use in <IfDefine name> 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 vhost settings

-t -D DUMP_RUN_CFG : show parsed run settings

-S                 : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG

-t -D DUMP_MODULES : show all loaded modules

-M                 : a synonym for -t -D DUMP_MODULES

-t                 : run syntax check for config files

-T                 : start without DocumentRoot(s) check

-X                 : debug mode (only one worker, do not detach)

[root@localhost ~]#

apachectl 可以工作在两种模式下,SysV init 模式和直通模式。在 SysV init 模式下,apachectl 用apachectl command的单命令形式:

比如要启动并检查它的状态,运行这个命令。如果你是普通用户,使用 sudo 命令来以 root 用户权限来运行:

[root@localhost ~]# apachectl start

[root@localhost ~]# apachectl status

* httpd.service – The Apache HTTP Server

Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)

Active: active (running) since Fri 2016-11-25 08:51:01 CST; 5h 28min ago

Docs: man:httpd(8)

man:apachectl(8)

Main PID: 1144 (httpd)

Status: “Total requests: 774; Current requests/sec: 0; Current traffic:   0 B/sec”

CGroup: /system.slice/httpd.service

|-1144 /usr/sbin/httpd -DFOREGROUND

|-2238 /usr/sbin/httpd -DFOREGROUND

|-2244 /usr/sbin/httpd -DFOREGROUND

|-2246 /usr/sbin/httpd -DFOREGROUND

|-2250 /usr/sbin/httpd -DFOREGROUND

|-2511 /usr/sbin/httpd -DFOREGROUND

|-2518 /usr/sbin/httpd -DFOREGROUND

|-2519 /usr/sbin/httpd -DFOREGROUND

|-2521 /usr/sbin/httpd -DFOREGROUND

|-2525 /usr/sbin/httpd -DFOREGROUND

`-3240 /usr/sbin/httpd -DFOREGROUND

 

Nov 25 08:50:57 localhost.localdomain systemd[1]: Starting The Apache HTTP Ser….

Nov 25 08:50:59 localhost.localdomain httpd[1144]: AH00558: httpd: Could not r…e

Nov 25 08:51:01 localhost.localdomain systemd[1]: Started The Apache HTTP Server.

Nov 25 14:18:58 localhost.localdomain systemd[1]: Started The Apache HTTP Server.

Hint: Some lines were ellipsized, use -l to show in full.

[root@localhost ~]#

因此,为了查看 Apache 服务器启动了哪些模块,可以用命令apachectl -t -D DUMP_MODULES 来显示所有启用的模块的 Apache 参数:

[root@localhost ~]# apachectl -t -D DUMP_MODULES

Passing arguments to httpd using apachectl is no longer supported.

You can only start/stop/restart httpd using this script.

If you want to pass extra arguments to httpd, edit the

/etc/sysconfig/httpd config file.

AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using localhost.localdomain. Set the ‘ServerName’ directive globally to suppress this message

Loaded Modules:

core_module (static)

so_module (static)

http_module (static)

access_compat_module (shared)

actions_module (shared)

alias_module (shared)

allowmethods_module (shared)

auth_basic_module (shared)

auth_digest_module (shared)

authn_anon_module (shared)

authn_core_module (shared)

authn_dbd_module (shared)

authn_dbm_module (shared)

authn_file_module (shared)

authn_socache_module (shared)

authz_core_module (shared)

authz_dbd_module (shared)

authz_dbm_module (shared)

authz_groupfile_module (shared)

authz_host_module (shared)

authz_owner_module (shared)

authz_user_module (shared)

autoindex_module (shared)

cache_module (shared)

cache_disk_module (shared)

data_module (shared)

dbd_module (shared)

deflate_module (shared)

dir_module (shared)

dumpio_module (shared)

echo_module (shared)

env_module (shared)

expires_module (shared)

ext_filter_module (shared)

filter_module (shared)

headers_module (shared)

include_module (shared)

info_module (shared)

log_config_module (shared)

logio_module (shared)

mime_magic_module (shared)

mime_module (shared)

negotiation_module (shared)

remoteip_module (shared)

reqtimeout_module (shared)

rewrite_module (shared)

setenvif_module (shared)

slotmem_plain_module (shared)

slotmem_shm_module (shared)

socache_dbm_module (shared)

socache_memcache_module (shared)

socache_shmcb_module (shared)

status_module (shared)

substitute_module (shared)

suexec_module (shared)

unique_id_module (shared)

unixd_module (shared)

userdir_module (shared)

version_module (shared)

vhost_alias_module (shared)

dav_module (shared)

dav_fs_module (shared)

dav_lock_module (shared)

lua_module (shared)

mpm_prefork_module (shared)

proxy_module (shared)

lbmethod_bybusyness_module (shared)

lbmethod_byrequests_module (shared)

lbmethod_bytraffic_module (shared)

lbmethod_heartbeat_module (shared)

proxy_ajp_module (shared)

proxy_balancer_module (shared)

proxy_connect_module (shared)

proxy_express_module (shared)

proxy_fcgi_module (shared)

proxy_fdpass_module (shared)

proxy_ftp_module (shared)

proxy_http_module (shared)

proxy_scgi_module (shared)

proxy_wstunnel_module (shared)

ssl_module (shared)

systemd_module (shared)

cgi_module (shared)

php5_module (shared)

[root@localhost ~]#

 

就是这样,我们可以查看到 Apache 服务器启动了哪些模块,并且这些模块的基本状态。当然一些更多的Apache服务器控制命令可以在apachectl help查看。

未经允许不得转载:天府数据港官方信息博客 » 如何查看 Apache 模块是否正常

客官点个赞呗! (0)
分享到:

评论 抢沙发

评论前必须登录!

天府云博 - 做有态度的开发&运维&设计学习分享平台!

联系我们百度云主机