Bii a ṣe le ṣetọju Fifuye Server Server Apache ati Awọn iṣiro Oju-iwe


Ninu àpilẹkọ yii, iwọ yoo kọ bi o ṣe le ṣe abojuto fifuye olupin ayelujara Apache ati awọn ibeere nipa lilo modulu mod_status ninu awọn pinpin Linux rẹ bii CentOS, RHEL, ati Fedora.

Kini mod_status?

mod_status jẹ modulu Apache kan ti o ṣe iranlọwọ lati ṣe atẹle fifuye olupin wẹẹbu ati awọn asopọ httpd lọwọlọwọ pẹlu wiwo HTML ti o le wọle nipasẹ ẹrọ lilọ kiri lori ayelujara kan.

Apache’s mod_status fihan oju-iwe HTML pẹtẹlẹ ti o ni alaye nipa awọn iṣiro lọwọlọwọ ti webserver pẹlu.

  • Lapapọ nọmba ti awọn ibeere ti nwọle
  • Lapapọ nọmba ti awọn baiti ati ka olupin olupin
  • Lilo Sipiyu ti Webserver
  • Fifuye olupin
  • Igbesi aye olupin
  • Lapapọ Ijabọ
  • Lapapọ nọmba ti awọn alainiṣẹ
  • Awọn PID pẹlu awọn oniwun oniwun ati ọpọlọpọ diẹ sii.

Aṣeṣe Apache aiyipada ṣiṣẹ oju-iwe awọn iṣiro olupin wọn si gbogbogbo. Lati ni ifihan ti oju-iwe ipo oju opo wẹẹbu ti o nšišẹ, ṣabẹwo.

  • https://status.apache.org/

A ti lo Ayika Idanwo atẹle fun nkan yii lati ṣawari diẹ sii nipa mod_status pẹlu diẹ ninu awọn apẹẹrẹ iṣe ati awọn titu iboju.

  1. Ẹrọ Ṣiṣẹ - CentOS 8/7
  2. Ohun elo - Olupin Wẹẹbu Apache
  3. Adirẹsi IP - 5.175.142.66
  4. DocumentRoot -/var/www/html
  5. Faili iṣeto ni Apache - /etc/httpd/conf/httpd.conf
  6. Ibudo HTTP Aiyipada - 80 TCP
  7. Awọn Eto iṣeto iṣeto Idanwo - httpd -t

Awọn ohun ti o ṣe pataki fun itọnisọna yii ni pe o yẹ ki o ti mọ tẹlẹ bi o ṣe le fi sori ẹrọ ati tunto Server Apache Ipilẹ kan. Ti o ko ba mọ bi o ṣe le ṣeto Apache, ka nkan atẹle ti o le ṣe iranlọwọ fun ọ ni siseto olupin Web Web Apache tirẹ.

  1. Ṣẹda Ayelujara ti ara Rẹ ati Alejo A Oju opo wẹẹbu kan ni Lainos

Bii o ṣe le Mu mod_status ṣiṣẹ ni Apache

Fifi sori ẹrọ Apache aiyipada wa pẹlu mod_status ṣiṣẹ. Ti kii ba ṣe bẹ, rii daju lati muu ṣiṣẹ ni faili iṣeto Apache.

 vi /etc/httpd/conf/httpd.conf

Wa ọrọ\"mod_status" tabi tẹsiwaju yi lọ si isalẹ titi iwọ o fi wa laini ti o ni.

#LoadModule status_module modules/mod_status.so

Ti o ba ri ohun kikọ '#' ni ibẹrẹ ti “LoadModule”, iyẹn tumọ si pe mod_status jẹ alaabo. Yọ '#' lati jeki mod_status.

LoadModule status_module modules/mod_status.so

Bayi tun wa fun ọrọ\"Ipo" tabi yi lọ si isalẹ titi iwọ o fi rii apakan fun mod_status eyiti o yẹ ki o dabi atẹle.

# 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>

Ninu apakan ti o wa loke, ṣoki awọn ila fun itọsọna agbegbe, SetHandler, ati awọn ihamọ itọsọna gẹgẹbi awọn aini rẹ. Fun apẹẹrẹ, Mo n mu ki o rọrun pẹlu aṣẹ Gba laaye, sẹ ati pe o gba laaye fun gbogbo eniyan.

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

Akiyesi: Iṣeto ni oke ni iṣeto aiyipada fun aaye ayelujara Apache aiyipada (oju opo wẹẹbu kan). Ti o ba ti ṣẹda ọkan tabi diẹ sii Awọn ọmọ ogun Virtual Apache, iṣeto ti o wa loke kii yoo ṣiṣẹ.

Nitorinaa, ni ipilẹ, o nilo lati ṣalaye iṣeto kanna fun olugbalejo foju kọọkan fun eyikeyi awọn ibugbe ti o ti tunto ni Apache. Fun apẹẹrẹ, iṣeto iṣeto ogun foju fun mod_status yoo dabi eleyi.

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

Awọn eto “ExtendedStatus” ṣafikun alaye diẹ si oju-iwe awọn iṣiro bi lilo Sipiyu, ibeere fun iṣẹju-aaya, ijabọ lapapọ, ati bẹbẹ lọ Lati jẹki o, satunkọ faili httpd.conf kanna ki o wa ọrọ naa “Afikun” ati Uncomment laini ati ṣeto ipo\"Tan" fun itọsọna 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

Bayi rii daju pe o ti muu ṣiṣẹ daradara ati tunto oju-iwe ipo olupin olupin Apache. O tun le ṣayẹwo fun awọn aṣiṣe ni iṣeto httpd.conf nipa lilo pipaṣẹ atẹle.

 httpd -t

Syntax OK

Ni ẹẹkan, o gba itumọ jẹ O DARA, o le ni anfani lati tun bẹrẹ iṣẹ httpd.

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

Oju-iwe ipo Apache yoo wa ni wiwọle nipasẹ orukọ orukọ rẹ pẹlu “/ ipo olupin” ni URL atẹle naa.

http://serveripaddress/server-status

OR

http://serev-hostname/server-status

Iwọ yoo wo nkan ti o jọra si oju-iwe atẹle pẹlu ExtendedStatus ṣiṣẹ.

Ninu aworan ti o wa loke, o le rii pe wiwo HTML kan, eyiti o fihan gbogbo alaye nipa akoko igbesoke olupin, ṣe ilana Id pẹlu alabara rẹ, oju-iwe ti wọn n gbiyanju lati wọle si.

O tun fihan itumọ ati lilo ti gbogbo awọn kuru ti a lo lati ṣe afihan ipo eyiti o ṣe iranlọwọ fun wa lati ni oye ipo naa daradara.

O tun le tun sọ oju-iwe naa ni gbogbo igba iṣẹju-aaya (sọ awọn aaya 5) lati wo awọn iṣiro ti o ni imudojuiwọn. Lati ṣeto isọdọtun adaṣe, jọwọ ṣafikun “? Sọtun = N” ni opin URL naa. Nibiti N le rọpo pẹlu nọmba awọn aaya eyiti o fẹ ki oju-iwe rẹ ni itura.

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

O tun le wo oju-iwe ipo Apache lati wiwo laini aṣẹ pẹlu lilo awọn aṣawakiri laini aṣẹ pataki ti a pe ni awọn ọna asopọ tabi lynx. O le fi wọn sii nipa lilo ohun elo oluṣakoso package aiyipada ti a pe ni yum bi o ṣe han ni isalẹ.

# yum install links

OR

# yum install lynx

Ni ẹẹkan, o ti fi sii, o le gba awọn iṣiro kanna lori ebute rẹ nipa lilo pipaṣẹ atẹle.

 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

Ipari

Module mod_status Apache jẹ ọpa ibojuwo ti o ni ọwọ pupọ fun mimojuto iṣẹ ti iṣẹ olupin ayelujara kan ati pe o le ṣe afihan awọn iṣoro funrararẹ. Fun alaye diẹ sii ka oju-iwe ipo ti o le ṣe iranlọwọ fun ọ lati di alaṣakoso olupin ayelujara ti o ni aṣeyọri diẹ sii.

  1. Oju-iwe akọọkan mod_status Apache

Iyẹn ni gbogbo fun mod_status fun bayi, a yoo wa pẹlu awọn ẹtan diẹ sii ati awọn imọran lori Apache ni awọn itọnisọna ọjọ iwaju. Titi lẹhinna o duro Geeky ati aifwy si linux-console.net ati maṣe gbagbe lati ṣafikun awọn asọye ti o niyelori rẹ.