ຄຳ ສັ່ງທີ່ມີປະໂຫຍດໃນການຄຸ້ມຄອງ Apache Web Server ໃນ Linux


ໃນບົດແນະ ນຳ ນີ້, ພວກເຮົາຈະອະທິບາຍບາງ ຄຳ ສັ່ງໃນການຄຸ້ມຄອງບໍລິການຂອງ Apache (HTTPD) ທີ່ທ່ານຄວນຮູ້ໃນຖານະນັກພັດທະນາຫລືຜູ້ບໍລິຫານລະບົບແລະທ່ານຄວນຮັກສາ ຄຳ ສັ່ງເຫລົ່ານີ້ໄວ້ໃນນິ້ວມືຂອງທ່ານ. ພວກເຮົາຈະສະແດງ ຄຳ ສັ່ງ ສຳ ລັບທັງ Systemd ແລະ SysVinit.

ໃຫ້ແນ່ໃຈວ່າ, ຄຳ ສັ່ງຕໍ່ໄປນີ້ຕ້ອງໄດ້ຖືກປະຕິບັດເປັນຜູ້ໃຊ້ຮາກຫລື sudo ແລະຄວນເຮັດວຽກກ່ຽວກັບການແຈກຈ່າຍ Linux ຕ່າງໆເຊັ່ນ CentOS, RHEL, Fedora Debian, ແລະ Ubuntu.

ຕິດຕັ້ງ Apache Server

ການຕິດຕັ້ງເຄື່ອງແມ່ຂ່າຍເວັບໄຊຕ໌ Apache, ໃຊ້ຕົວຈັດການຊຸດການແຈກຢາຍແບບເລີ່ມຕົ້ນຂອງທ່ານດັ່ງທີ່ສະແດງໄວ້.

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

ກວດສອບ Apache Version

ເພື່ອກວດເບິ່ງເວີຊັນທີ່ຕິດຕັ້ງຂອງ server ຂອງທ່ານໃນລະບົບ Linux ຂອງທ່ານ, ໃຫ້ເຮັດຕາມ ຄຳ ສັ່ງຕໍ່ໄປນີ້.

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

ຖ້າທ່ານຕ້ອງການສະແດງ ຈຳ ນວນເວີຊັນ Apache ແລະລວບລວມການຕັ້ງຄ່າ, ໃຫ້ໃຊ້ -V ທຸງດັ່ງທີ່ສະແດງ.

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

ກວດເບິ່ງຂໍ້ຜິດພາດ Syntax ທີ່ມີການຕັ້ງຄ່າຂອງ Apache

ເພື່ອກວດສອບເອກະສານການຕັ້ງຄ່າຂອງ Apache ຂອງທ່ານ ສຳ ລັບຂໍ້ຜິດພາດຂອງ syntax ໃດເຮັດວຽກຕາມ ຄຳ ສັ່ງຕໍ່ໄປນີ້ເຊິ່ງມັນຈະກວດສອບຄວາມຖືກຕ້ອງຂອງແຟ້ມ config, ກ່ອນທີ່ຈະເລີ່ມການບໍລິການ ໃໝ່.

$ 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

ເລີ່ມຕົ້ນບໍລິການ Apache

ເພື່ອເລີ່ມຕົ້ນການບໍລິການ Apache, ດຳ ເນີນການ ຄຳ ສັ່ງຕໍ່ໄປນີ້.

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

ເປີດໃຊ້ບໍລິການ Apache

ຄໍາສັ່ງທີ່ຜ່ານມາພຽງແຕ່ເລີ່ມຕົ້ນໃຫ້ບໍລິການ Apache ໃນເວລານີ້, ເພື່ອໃຫ້ມັນເລີ່ມຕົ້ນໂດຍອັດຕະໂນມັດໃນລະບົບ boot, ດໍາເນີນການຄໍາສັ່ງຕໍ່ໄປນີ້.

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

Restart Apache Service

ເພື່ອເລີ່ມຕົ້ນການເຕັ້ນຣໍາກຸstartຍ (ຢຸດແລະຫຼັງຈາກນັ້ນເລີ່ມຕົ້ນການບໍລິການ), ດໍາເນີນການຄໍາສັ່ງຕໍ່ໄປນີ້.

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

ເບິ່ງສະຖານະບໍລິການ Apache

ເພື່ອກວດສອບຂໍ້ມູນກ່ຽວກັບສະຖານະພາບຂອງການບໍລິການ Apache, ດຳ ເນີນການ ຄຳ ສັ່ງຕໍ່ໄປນີ້.

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

ໂຫຼດໂປແກຼມ Apache ຄືນ ໃໝ່

ຖ້າທ່ານໄດ້ມີການປ່ຽນແປງໃດໆກ່ຽວກັບການຕັ້ງຄ່າຂອງ server server, ທ່ານສາມາດແນະ ນຳ ໃຫ້ບໍລິການໂຫຼດຄ່າການຕັ້ງຄ່າຂອງມັນຄືນ ໃໝ່ ໂດຍການ ດຳ ເນີນການ ຄຳ ສັ່ງຕໍ່ໄປນີ້.

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

ຢຸດບໍລິການ Apache

ເພື່ອຢຸດການບໍລິການ Apache, ໃຊ້ ຄຳ ສັ່ງຕໍ່ໄປນີ້.

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

ສະແດງຄວາມຊ່ວຍເຫລືອ Apache Command

ສຸດທ້າຍ, ທ່ານສາມາດຂໍຄວາມຊ່ວຍເຫຼືອກ່ຽວກັບ ຄຳ ສັ່ງບໍລິການ Apache ທີ່ຢູ່ພາຍໃຕ້ລະບົບໂດຍການ ດຳ ເນີນການ ຄຳ ສັ່ງຕໍ່ໄປນີ້.

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

ທ່ານສາມາດຊອກຫາຂໍ້ມູນເພີ່ມເຕີມກ່ຽວກັບ systemctl ໂດຍການປຶກສາ: ວິທີການຈັດການ 'Systemd' ການບໍລິການແລະ ໜ່ວຍ ງານການໃຊ້ 'Systemctl' ໃນ Linux.

ທ່ານອາດຈະຢາກອ່ານບົດຄວາມທີ່ກ່ຽວຂ້ອງກັບ Apache ຕໍ່ໄປນີ້.

<

  • 5 ຄຳ ແນະ ນຳ ເພື່ອຊ່ວຍເພີ່ມປະສິດທິພາບຂອງ Apache Web Server ຂອງທ່ານ
  • ວິທີການກວດສອບ Apache Web Server Load ແລະສະຖິຕິຂອງ ໜ້າ ເວັບ
  • ວິທີການບໍລິຫານ Apache Web Server ໂດຍໃຊ້ເຄື່ອງມື“ Apache GUI”
  • ວິທີການປ່ຽນ Apache Port Port ໃນ Linux
  • 13 ຄວາມປອດໄພຂອງ Server Web Apache ແລະ ຄຳ ແນະ ນຳ ທີ່ແຂງກະດ້າງ
  • ປົກປ້ອງ Apache ຕໍ່ກັບ Brute Force ຫຼື DDoS Attacks ໂດຍໃຊ້ Mod_Security ແລະ Mod_evasive Modules
  • ດຽວນີ້ ໝົດ ແລ້ວ! ໃນບົດຂຽນນີ້, ພວກເຮົາໄດ້ອະທິບາຍ ຄຳ ສັ່ງກ່ຽວກັບການບໍລິການ Apache/HTTPD ທີ່ໃຊ້ຫຼາຍທີ່ສຸດທີ່ທ່ານຄວນຮູ້, ລວມທັງການເລີ່ມຕົ້ນ, ເປີດໃຊ້ງານ, ເລີ່ມຕົ້ນ ໃໝ່ ແລະຢຸດ Apache. ທ່ານສາມາດຕິດຕໍ່ຫາພວກເຮົາໄດ້ໂດຍຜ່ານແບບຟອມ ຄຳ ເຫັນຂ້າງລຸ່ມນີ້ ສຳ ລັບ ຄຳ ຖາມຫຼື ຄຳ ເຫັນ.