Kako preveriti, kateri moduli Apache so omogočeni/naloženi v Linuxu


V tem priročniku bomo na kratko govorili o prednji strani spletnega strežnika Apache in o tem, kako našteti ali preveriti, kateri moduli Apache so omogočeni na vašem strežniku.

Apache je zgrajen na osnovi načela modularnosti, tako da skrbnikom spletnih strežnikov omogoča dodajanje različnih modulov za razširitev njegovih osnovnih funkcij in izboljšanje zmogljivosti apache.

Nekateri pogosti moduli Apache vključujejo:

  1. mod_ssl - ki ponuja HTTPS za Apache.
  2. mod_rewrite - ki omogoča ujemanje vzorcev url z regularnimi izrazi in izvajanje pregledne preusmeritve z uporabo trikov .htaccess ali uporabo odziva kode stanja HTTP.
  3. mod_security - ki vam ponuja zaščito Apacheja pred napadi Brute Force ali DDoS.
  4. mod_status - ki vam omogoča spremljanje obremenitve spletnega strežnika Apache in statike strani.

V Linuxu se ukaz apachectl ali apache2ctl uporablja za nadzor strežniškega vmesnika Apache HTTP, je čelni del Apachea.

Informacije o uporabi apache2ctl lahko prikažete spodaj:

$ apache2ctl help
OR
$ 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 lahko deluje v dveh možnih načinih, inicialnem načinu Sys V in prehodnem načinu. V načinu za zagon SysV apache2ctl sprejme preproste enobesedne ukaze v spodnji obliki:

$ apachectl command
OR
$ apache2ctl command

Če želite na primer zagnati Apache in preveriti njegovo stanje, z ukazom sudo zaženite ta dva ukaza s korenskimi pravicami uporabnika, če ste običajni uporabnik:

$ sudo apache2ctl start
$ sudo apache2ctl status
[email  ~ $ 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
[email  ~ $ 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

In ko deluje v prehodnem načinu, lahko apache2ctl sprejme vse argumente Apache v naslednji sintaksi:

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

Vsi Apache-argumenti so lahko navedeni na naslednji način:

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

Zato, da preverite, kateri moduli so omogočeni na vašem spletnem strežniku Apache, zaženite spodnji ukaz za svojo distribucijo, kjer je -t -D DUMP_MODULES argument Apache za prikaz vseh omogočenih/naloženih modulov. :

---------------  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
 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)
....

To je vse! v tej preprosti vadnici smo razložili, kako uporabljati čelna orodja Apache za naštevanje omogočenih/naloženih modulov apache. Upoštevajte, da se lahko obrnete na spodnji obrazec za povratne informacije in nam pošljete vprašanja ali komentarje v zvezi s tem vodnikom.