Otu esi eleba anya n'ibu sava weebụ Apache na ọnụ ọgụgụ ibe


N'ime edemede a, ị ga-amụta ka esi nyochaa ibu na arịrịọ sava Apache site na iji modul mod_status na nkesa Linux gị dị ka CentOS, RHEL, na Fedora.

Kedu ihe bụ mod_status?

mod_status bụ modul Apache nke na-enyere aka nyochaa ibu ihe nkesa weebụ yana njikọ httpd dị ugbu a na interface HTML nke enwere ike ịnweta site na ihe nchọgharị weebụ.

Apache's mod_status na-egosi ibe HTML dị larịị nwere ozi gbasara ọnụ ọgụgụ dị ugbu a nke sava weebụ gụnyere.

  • Ngụkọta ọnụ ọgụgụ nke arịrịọ mbata
  • Ngụkọta ọnụọgụ bytes na ihe nkesa
  • Ojiji CPU nke sava webụ
  • Ibu Ibu nkesa
  • Oge oge nkesa
  • Mkpokọta okporo ụzọ
  • Ngụkọta ọnụ ọgụgụ ndị ọrụ na-abaghị uru
  • PID nwere ndị ahịa na ọtụtụ ndị ọzọ.

Ọrụ Apache nke ndabara nyere ọha na eze aka ibe ọnụ ọgụgụ sava ha. Iji nweta ngosi nke ibe ọkwa weebụsaịtị nke nọ n'aka, gaa na.

  • https://status.apache.org/

Anyị ejirila gburugburu ule na-esonụ maka akụkọ a iji nyochaa ihe ndị ọzọ gbasara mod_status na ụfọdụ ihe atụ bara uru na nseta ihuenyo.

  1. Sistemụ arụmọrụ – CentOS 8/7
  2. Ngwa – sava weebụ Apache
  3. Adreesị IP – 5.175.142.66
  4. DocumentRoot – /var/www/html
  5. faịlụ nhazi Apache – /etc/httpd/conf/httpd.conf
  6. Port HTTP ndabara – 80 TCP
  7. Nnwale Nhazi Nhazi – httpd -t

Ihe achọrọ maka nkuzi a bụ na ị ga-amarịrị otu esi etinye na hazie ihe nkesa Apache Basic. Ọ bụrụ na ịmaghị ka esi edobe Apache, gụọ akụkọ na-esote nke nwere ike inyere gị aka n'ịtọlite sava weebụ Apache nke gị.

  1. Mepụta sava Webụsaịtị na Bochum Weebụsaịtị na Linux

Otu esi eme mod_status na Apache

Nwụnye Apache ndabara na-abịa na mod_status nyeere. Ọ bụrụ na ọ bụghị, gbaa mbọ mee ya na faịlụ nhazi Apache.

 vi /etc/httpd/conf/httpd.conf

Chọọ okwu ahụ \mod_status ma ọ bụ gaa n'ihu na-atụgharị ruo mgbe ịchọtara ahịrị nwere.

#LoadModule status_module modules/mod_status.so

Ọ bụrụ na ịhụ agwa '#' na mmalite nke LoadModule, nke ahụ pụtara mod_status nwere nkwarụ. Wepu '#' iji mee mod_status.

LoadModule status_module modules/mod_status.so

Ugbu a ọzọ chọọ okwu ahụ \Ebe ma ọ bụ gbadaa ala ruo mgbe ịchọtara ngalaba maka mod_status nke kwesịrị ịdị ka nke a.

# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Change the ".example.com" to match your domain to enable.
#
#<Location /server-status>
#    SetHandler server-status
#    Order deny,allow
#    Deny from all
#    Allow from .example.com
#</Location>

Na ngalaba dị n'elu, ekwupụtaghị ahịrị maka ntuziaka ebe, SetHandler, yana mmachi ndekọ dịka mkpa gị siri dị. Dịka ọmụmaatụ, ana m edobe ya ka ọ dị mfe site na iji Order Allow, gọnarị ma kwere ya maka mmadụ niile.

<Location /server-status>
   SetHandler server-status
   Order allow,deny
   Deny from all
   Allow from all 
</Location>

Rịba ama: Nhazi dị n'elu bụ nhazi nke ndabara maka ebe nrụọrụ weebụ Apache (otu webụsaịtị). Ọ bụrụ na ị mepụtara otu ma ọ bụ karịa Apache Virtual Hosts, nhazi dị n'elu agaghị arụ ọrụ.

Yabụ, n'ụzọ bụ isi, ịkwesịrị ịkọwapụta otu nhazi maka onye nnabata ọ bụla maka ngalaba ọ bụla ị haziri na Apache. Dịka ọmụmaatụ, nhazi nhazi nke ọma maka mod_status ga-adị ka nke a.

<VirtualHost *:80>
    ServerAdmin [email 
    DocumentRoot /var/www/html/example.com
    ServerName example.com
    ErrorLog logs/example.com-error_log
    CustomLog logs/example.com-access_log common
<Location /server-status>
   SetHandler server-status
   Order allow,deny
   Deny from all
   Allow from example.com 
</Location>
</VirtualHost>

Ntọala “ExtendedStatus” na-agbakwunye ozi ndị ọzọ na ibe ọnụ ọgụgụ dị ka ojiji CPU, arịrịọ kwa sekọnd, mkpokọta okporo ụzọ, wdg. Iji mee ya, dezie otu faịlụ httpd.conf wee chọọ okwu ahụ \Extended na Uncomment line na tọọ ọkwa \Na maka ntuziaka ExtendedStatus.

# ExtendedStatus controls whether Apache will generate "full" status
# information (ExtendedStatus On) or just basic information (ExtendedStatus
# Off) when the "server-status" handler is called. The default is Off.
#
ExtendedStatus On

Ugbu a gbaa mbọ hụ na i meela nke ọma ma hazie ibe ọnọdụ sava Apache. Ị nwekwara ike ịlele mperi dị na nhazi httpd.conf site na iji iwu a.

 httpd -t

Syntax OK

Ozugbo, ịnweta syntax dị mma, ị nwere ike ịmalitegharị ọrụ httpd.

 service httpd restart
OR
 systemctl restart httpd
Stopping httpd:                                          [  OK  ]
Starting httpd:                                          [  OK  ]

A ga-enweta ibe ọkwa Apache site na aha ngalaba gị nwere “/ọnọdụ sava” na URL ndị a.

http://serveripaddress/server-status

OR

http://serev-hostname/server-status

Ị ga-ahụ ihe yiri ibe na-esonụ na ExtendedStatus nyeere.

Na foto dị n'elu, ị nwere ike ịhụ na interface HTML, nke na-egosi ozi niile gbasara oge ihe nkesa, nhazi Id na ndị ahịa ya, ibe ha na-agbalị ịnweta.

Ọ na-egosipụtakwa ihe pụtara na ojiji nke ndebiri ndebiri niile ejiri gosipụta ọkwa nke na-enyere anyị aka ịghọta ọnọdụ nke ọma.

Ị nwekwara ike imegharị ibe ahụ oge ọ bụla sekọnd (kwuo 5 sekọnd) ka ịhụ ọnụ ọgụgụ emelitere. Iji tọọ ume ọhụrụ akpaghị aka, biko tinye “?refresh=N” na ngwụcha URL. Ebe enwere ike iji ọnụọgụ sekọnd dochie N nke ịchọrọ ka ibe gị nweta ume ọhụrụ.

http://serveripaddress/server-status/?refresh=5

Ị nwekwara ike ịlele ibe ọkwa Apache site na interface-akara interface site na iji ihe nchọgharị ahịrị iwu pụrụ iche a na-akpọ njikọ ma ọ bụ lynx. Ị nwere ike iwunye ha site na iji ọrụ njikwa ngwugwu a na-akpọ yum dị ka egosiri n'okpuru.

# yum install links

OR

# yum install lynx

Ozugbo, ị wụnyela, ị nwere ike nweta otu ọnụ ọgụgụ ahụ na ọdụ gị site na iji iwu na-esonụ.

 links http://serveripaddress/server-status
OR
 lynx http://serveripaddress/server-status
OR
  /etc/init.d/httpd fullstatus
                     Apache Server Status for localhost
   Server Version: Apache/2.2.15 (Unix) DAV/2 PHP/5.3.3
   Server Built: Aug 13 2013 17:29:28

   --------------------------------------------------------------------------
   Current Time: Tuesday, 14-Jan-2014 04:34:13 EST
   Restart Time: Tuesday, 14-Jan-2014 00:33:05 EST
   Parent Server Generation: 0
   Server uptime: 4 hours 1 minute 7 seconds
   Total accesses: 2748 - Total Traffic: 9.6 MB
   CPU Usage: u.9 s1.06 cu0 cs0 - .0135% CPU load
   .19 requests/sec - 695 B/second - 3658 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 a worker, "." Open slot with no current process

Srv PID     Acc    M CPU   SS  Req Conn Child Slot     Client        VHost             Request
0-0 -    0/0/428   . 0.30 5572 0   0.0  0.00  1.34 127.0.0.1      5.175.142.66 OPTIONS * HTTP/1.0
                                                                               GET
1-0 5606 0/639/639 _ 0.46 4    0   0.0  2.18  2.18 115.113.134.14 5.175.142.66 /server-status?refresh=5
                                                                               HTTP/1.1
                                                                               GET
2-0 5607 0/603/603 _ 0.43 0    0   0.0  2.09  2.09 115.113.134.14 5.175.142.66 /server-status?refresh=5
                                                                               HTTP/1.1
3-0 -    0/0/337   . 0.23 5573 0   0.0  0.00  1.09 127.0.0.1      5.175.142.66 OPTIONS * HTTP/1.0
                                                                               GET
4-0 5701 0/317/317 _ 0.23 9    0   0.0  1.21  1.21 115.113.134.14 5.175.142.66 /server-status?refresh=5
                                                                               HTTP/1.1
                                                                               GET
5-0 5708 0/212/213 _ 0.15 6    0   0.0  0.85  0.85 115.113.134.14 5.175.142.66 /server-status?refresh=5
                                                                               HTTP/1.1
6-0 5709 0/210/210 W 0.16 0    0   0.0  0.84  0.84 127.0.0.1      5.175.142.66 GET /server-status
                                                                               HTTP/1.1
7-0 -    0/0/1     . 0.00 5574 0   0.0  0.00  0.00 127.0.0.1      5.175.142.66 OPTIONS * HTTP/1.0

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

    Srv  Child Server number - generation
    PID  OS process ID
    Acc  Number of accesses this connection / this child / this slot
     M   Mode of operation
    CPU  CPU usage, number of seconds
    SS   Seconds since the beginning of the most recent request
    Req  Milliseconds required to process most recent request
   Conn  Kilobytes transferred this connection
   Child Megabytes transferred this child
   Slot  Total megabytes transferred this slot
   --------------------------------------------------------------------------

    Apache/2.2.15 (CentOS) Server at localhost Port 80

Mmechi

Apache's mod_status modul bụ ngwa nleba anya nke ukwuu maka nyochaa arụmọrụ nke sava weebụ ma nwee ike igosipụta nsogbu n'onwe ya. Maka ozi ndị ọzọ gụọ ibe ọkwa nke nwere ike inyere gị aka ịghọ onye nchịkwa sava weebụ na-aga nke ọma.

  1. Apache mod_status homepage

Nke ahụ bụ maka mod_status maka ugbu a, anyị ga-ewepụta ụzọ aghụghọ na ndụmọdụ Apache na nkuzi n'ọdịnihu. Ruo mgbe ahụ nọrọ Geeky wee lelee linux-console.net ma echefula itinye nkọwa gị bara uru.