Mapuslanon nga mga Sugo sa Pagdumala sa Apache Web Server sa Linux


Niini nga panudlo, among ihulagway ang pipila sa labing kasagarang gigamit nga Apache (HTTPD) nga mga mando sa pagdumala sa serbisyo nga kinahanglan nimong mahibal-an ingon usa ka developer o tagdumala sa sistema ug kinahanglan nimo nga tipigan kini nga mga mando sa imong mga tudlo. Atong ipakita ang mga sugo alang sa Systemd ug SysVinit.

Siguruha nga, ang pagsunod sa mga mando kinahanglan ipatuman ingon usa ka gamut o sudo nga tiggamit ug kinahanglan magtrabaho sa bisan unsang pag-apod-apod sa Linux sama sa CentOS, RHEL, Fedora Debian, ug Ubuntu.

I-install ang Apache Server

Aron ma-install ang Apache web server, gamita ang imong default distribution package manager sama sa gipakita.

$ sudo apt install apache2	    [On Debian/Ubuntu]
$ sudo yum install httpd	    [On RHEL/CentOS]
$ sudo dnf install httpd	    [On Fedora 22+]
$ sudo zypper install apache2	    [On openSUSE]

Susiha ang Bersyon sa Apache

Aron masusi ang na-install nga bersyon sa imong Apache web server sa imong Linux system, padagana ang mosunod nga sugo.

$ sudo httpd -v
OR
$ sudo apache2 -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Nov  5 2018 01:47:09

Kung gusto nimo ipakita ang numero sa bersyon sa Apache ug i-compile ang mga setting, gamita ang bandila nga -V sama sa gipakita.

$ sudo httpd -V
OR
$ sudo apache2 -V
Server version: Apache/2.4.6 (CentOS)
Server built:   Nov  5 2018 01:47:09
Server's Module Magic Number: 20120211:24
Server loaded:  APR 1.4.8, APR-UTIL 1.5.2
Compiled using: APR 1.4.8, APR-UTIL 1.5.2
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="/run/httpd/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

Susiha ang Apache Configuration Syntax Errors

Aron masusi ang imong mga file sa pag-configure sa Apache alang sa bisan unsang mga sayup sa syntax ipadagan ang mosunud nga mando, nga magsusi sa pagkabalido sa mga file sa config, sa wala pa i-restart ang serbisyo.

$ sudo httpd -t
OR
$ sudo apache2ctl -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using linux-console.net. 
Set the 'ServerName' directive globally to suppress this message
Syntax OK

Pagsugod sa Serbisyo sa Apache

Aron masugdan ang serbisyo sa Apache, pagdagan ang mosunud nga mando.

------------ On CentOS/RHEL ------------ 
$ sudo systemctl start httpd     [On Systemd]
$ sudo service httpd start 	 [On SysVInit]

------------ On Ubunt/Debian  ------------
$ sudo systemctl start apache2   [On Systemd]
$ sudo service apache2 start     [On SysVInit]

I-enable ang Serbisyo sa Apache

Ang nauna nga sugo nagsugod lamang sa serbisyo sa Apache sa kasamtangan, aron mahimo kini nga auto-start sa system boot, padagana ang mosunod nga sugo.

------------ On CentOS/RHEL ------------ 
$ sudo systemctl enable httpd     [On Systemd]
$ sudo chkconfig httpd on 	  [On SysVInit]

------------ On Ubunt/Debian  ------------
$ sudo systemctl enable apache2   [On Systemd]
$ sudo chkconfig apache2 on       [On SysVInit]

I-restart ang Serbisyo sa Apache

Aron i-restart ang Apache (hunong ug dayon sugdi ang serbisyo), padagana ang mosunod nga sugo.

------------ On CentOS/RHEL ------------ 
$ sudo systemctl restart httpd     [On Systemd]
$ sudo service httpd restart 	   [On SysVInit]

------------ On Ubunt/Debian  ------------
$ sudo systemctl restart apache2   [On Systemd]
$ sudo service apache2 restart     [On SysVInit]

Tan-awa ang Status sa Serbisyo sa Apache

Aron masusi ang serbisyo sa Apache nga run time status nga impormasyon, padagana ang mosunod nga sugo.

------------ On CentOS/RHEL ------------ 
$ sudo systemctl status httpd     [On Systemd]
$ sudo service httpd status 	  [On SysVInit]

------------ On Ubunt/Debian  ------------
$ sudo systemctl status apache2   [On Systemd]
$ sudo service apache2 status     [On SysVInit]

I-reload ang Serbisyo sa Apache

Kung nakahimo ka ug bisan unsang mga pagbag-o sa configuration sa Apache server, mahimo nimong tudloan ang serbisyo nga i-reload ang configuration niini pinaagi sa pagpadagan sa mosunod nga command.

------------ On CentOS/RHEL ------------ 
$ sudo systemctl reload httpd     [On Systemd]
$ sudo service httpd reload 	  [On SysVInit]

------------ On Ubunt/Debian  ------------
$ sudo systemctl reload apache2   [On Systemd]
$ sudo service apache2 reload     [On SysVInit]

Hunonga ang Serbisyo sa Apache

Aron mapahunong ang serbisyo sa Apache, gamita ang mosunod nga sugo.

------------ On CentOS/RHEL ------------ 
$ sudo systemctl stop httpd       [On Systemd]
$ sudo service httpd stop 	  [On SysVInit]

------------ On Ubunt/Debian  ------------
$ sudo systemctl stop apache2     [On Systemd]
$ sudo service apache2 stop     [On SysVInit]

Ipakita ang Tabang sa Apache Command

Katapusan apan dili labing gamay, makakuha ka og tabang bahin sa mga sugo sa serbisyo sa Apache ubos sa systemd pinaagi sa pagpadagan sa mosunod nga sugo.

$ sudo httpd -h
OR
$ sudo apache2 -h		
OR
$ systemctl -h apache2	
Usage: 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  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)

Makapangita ka ug dugang nga impormasyon bahin sa systemctl pinaagi sa pagkonsulta: Unsaon Pagdumala sa 'Systemd' Services ug Units Gamit ang 'Systemctl' sa Linux.

Mahimo usab nimo nga basahon kining mosunod nga mga artikulo nga may kalabutan sa Apache.

  1. 5 Mga Tip aron Mapauswag ang Pagganap sa Imong Apache Web Server
  2. Unsaon Pagmonitor sa Apache Web Server Load ug Page Statistics
  3. Unsaon Pagdumala sa Apache Web Server Gamit ang \Apache GUI Tool
  4. Unsaon Pag-ilis sa Apache HTTP Port sa Linux
  5. 13 Apache Web Server Security ug Hardening Tips
  6. Panalipod sa Apache Batok sa Brute Force o DDoS Attacks Gamit ang Mod_Security ug Mod_evasive Module

Kana lang sa pagkakaron! Niini nga artikulo, among gipatin-aw ang labing kasagarang gigamit nga mga sugo sa pagdumala sa serbisyo sa Apache/HTTPD nga kinahanglan nimong masayran, lakip ang pagsugod, pagpagana, pag-restart ug paghunong sa Apache. Kanunay nimong makontak kami pinaagi sa porma sa feedback sa ubos alang sa bisan unsang mga pangutana o komento.