Umarni masu fa'ida don Sarrafa Sabar Yanar Gizo ta Apache a cikin Linux


A cikin wannan koyawa, za mu bayyana wasu umarnin gudanarwar sabis na Apache (HTTPD) da aka fi amfani da su waɗanda yakamata ku sani a matsayin mai haɓakawa ko mai kula da tsarin kuma yakamata ku kiyaye waɗannan umarni a hannunku. Za mu nuna umarni don duka Systemd da SysVinit.

Tabbatar cewa, bin umarni dole ne a kashe su azaman tushen ko mai amfani da sudo kuma yakamata suyi aiki akan kowane rarraba Linux kamar CentOS, RHEL, Fedora Debian, da Ubuntu.

Shigar da Apache Server

Don shigar da sabar gidan yanar gizo ta Apache, yi amfani da tsoho mai sarrafa fakitin rarraba kamar yadda aka nuna.

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

Duba Shafin Apache

Don bincika sigar sabar gidan yanar gizon ku ta Apache akan tsarin Linux ɗinku, gudanar da umarni mai zuwa.

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

Idan kana so ka nuna lambar sigar Apache da haɗa saituna, yi amfani da tutar -V kamar yadda aka nuna.

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

Bincika Kurakurai Kan Kanfigareshan Apache

Don bincika fayilolin sanyi na Apache don kowane kurakuran haɗin gwiwa gudanar da umarni mai zuwa, wanda zai duba ingancin fayilolin daidaitawa, kafin a sake kunna sabis ɗin.

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

Fara Sabis na Apache

Don fara sabis na Apache, gudanar da umarni mai zuwa.

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

Kunna Sabis na Apache

Umurnin da ya gabata yana farawa ne kawai sabis na Apache na yanzu, don kunna shi ta atomatik a boot ɗin tsarin, gudanar da umarni mai zuwa.

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

Sake kunna Sabis na Apache

Don sake kunna Apache (tsayawa sannan fara sabis ɗin), gudanar da umarni mai zuwa.

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

Duba Matsayin Sabis na Apache

Don duba bayanan halin lokacin tafiyar sabis na Apache, gudanar da umarni mai zuwa.

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

Sake kunna Sabis na Apache

Idan kun yi kowane canje-canje ga saitin uwar garken Apache, zaku iya umurtar sabis ɗin don sake loda tsarin sa ta hanyar aiwatar da umarni mai zuwa.

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

Dakatar da Sabis na Apache

Don dakatar da sabis na Apache, yi amfani da umarni mai zuwa.

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

Nuna Taimakon Umurnin Apache

A ƙarshe amma ba kalla ba, zaku iya samun taimako game da umarnin sabis na Apache a ƙarƙashin systemd ta hanyar gudanar da umarni mai zuwa.

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

Kuna iya samun ƙarin bayani game da systemctl ta hanyar tuntuɓar: Yadda ake Sarrafa Sabis ɗin 'Systemd' da Raka'a Amfani da 'Systemctl' a cikin Linux.

Hakanan kuna iya son karanta waɗannan labarai masu alaƙa da Apache.

  1. Nasihu 5 don Haɓaka Ayyukan Sabar Yanar Sadarwar Yanar Gizo na Apache
  2. Yadda ake Kula da Load ɗin Sabar Gidan Yanar Gizo na Apache da Ƙididdiga na Shafi
  3. Yadda ake Gudanar da Sabar Yanar Gizo ta Apache Ta Amfani da Kayan aikin Apache GUI
  4. Yadda ake Canja tashar HTTP ta Apache a cikin Linux
  5. 13 Tsaro na Sabar Yanar Sadarwar Yanar Gizo na Apache da Tukwici masu ƙarfi
  6. Kare Apache Daga Ƙarfin Ƙarfafa ko hare-haren DDoS Ta amfani da Mod_Security da Mod_evasive Modules

Wannan ke nan a yanzu! A cikin wannan labarin, mun bayyana umarnin gudanarwar sabis na Apache/HTTPD da aka fi amfani da su waɗanda yakamata ku sani, gami da farawa, kunnawa, sake farawa da dakatar da Apache. Kuna iya ko da yaushe isa gare mu ta hanyar amsa tambayoyin da ke ƙasa don kowace tambaya ko sharhi.