Awọn Aṣẹ Wulo lati Ṣakoso Olupin Wẹẹbu afun ni Linux


Ninu ẹkọ yii, a yoo ṣe apejuwe diẹ ninu awọn aṣẹ iṣakoso iṣẹ Apache (HTTPD) ti o wọpọ julọ ti o yẹ ki o mọ bi olugbala tabi alakoso eto ati pe o yẹ ki o pa awọn ofin wọnyi mọ ni ika ọwọ rẹ. A yoo fi awọn aṣẹ han fun Systemd ati SysVinit.

Rii daju pe, atẹle awọn ofin ni a gbọdọ ṣe bi gbongbo tabi olumulo sudo ati pe o yẹ ki o ṣiṣẹ lori eyikeyi pinpin Linux gẹgẹbi CentOS, RHEL, Fedora Debian, ati Ubuntu.

Fi Olupin Apache sii

Lati fi olupin ayelujara Apache sori ẹrọ, lo oluṣakoso package aiyipada pinpin bi o ti han.

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

Ṣayẹwo Ẹya Apache

Lati ṣayẹwo ẹya ti a fi sori ẹrọ ti olupin ayelujara Apache lori ẹrọ Linux rẹ, ṣiṣe aṣẹ atẹle.

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

Ti o ba fẹ ṣe afihan nọmba ẹya Apache ati ṣajọ awọn eto, lo asia -V bi o ti han.

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

Ṣayẹwo Awọn aṣiṣe Sintasi Iṣatunṣe Apache

Lati ṣayẹwo awọn faili iṣeto Apache rẹ fun eyikeyi awọn aṣiṣe sintasi ṣiṣe aṣẹ atẹle, eyi ti yoo ṣayẹwo iduroṣinṣin ti awọn faili atunto, ṣaaju lati tun bẹrẹ iṣẹ naa.

$ 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

Bẹrẹ Iṣẹ Afun

Lati bẹrẹ iṣẹ Apache, ṣiṣe aṣẹ atẹle.

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

Jeki Iṣẹ Afun

Ofin ti tẹlẹ nikan bẹrẹ iṣẹ Apache fun igba diẹ, lati jẹ ki o bẹrẹ-laifọwọyi ni bata eto, ṣiṣe aṣẹ atẹle.

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

Tun Iṣẹ Afun bẹrẹ

Lati tun Apache tun bẹrẹ (duro ati lẹhinna bẹrẹ iṣẹ), ṣiṣe aṣẹ atẹle.

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

Wo Ipo Iṣẹ Apache

Lati ṣayẹwo iṣẹ ipo Apache ṣiṣe alaye ipo akoko, ṣiṣe aṣẹ atẹle.

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

Tun gbee Iṣẹ Apache

Ti o ba ti ṣe awọn ayipada eyikeyi si iṣeto olupin Apache, o le kọ iṣẹ naa lati tun gbe atunto rẹ nipasẹ ṣiṣe pipaṣẹ atẹle.

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

Duro Iṣẹ Afun

Lati da iṣẹ Apache duro, lo aṣẹ atẹle.

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

Ṣe afihan Iranlọwọ Apfin Apache

Kẹhin ṣugbọn kii kere ju, o le gba iranlọwọ nipa awọn aṣẹ iṣẹ Apache labẹ eto nipasẹ ṣiṣe pipaṣẹ atẹle.

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

O le wa alaye diẹ sii nipa systemctl nipa ṣiṣe imọran: Bii o ṣe le Ṣakoso awọn iṣẹ ‘Systemd’ ati Awọn ipin Lilo ‘Systemctl’ ni Linux.

O tun le fẹ lati ka wọnyi atẹle awọn nkan ti o jọmọ Apache.

  1. Awọn imọran 5 lati ṣe alekun Iṣe ti Olupin Wẹẹbu Apache Rẹ
  2. Bii a ṣe le ṣetọju Fifuye Server Server Apache ati Awọn iṣiro oju-iwe
  3. Bii o ṣe le Ṣakoso Iṣakoso olupin wẹẹbu afun Lilo Lilo Ọpa "Apache GUI"
  4. Bii o ṣe le Yi Port HTTP Apache ni Linux
  5. 13 Aabo Olupin Oju opo wẹẹbu Apache ati Awọn imọran Ṣiṣe lile
  6. Dabobo Afun Lodi si Ipa Agbara tabi Awọn Ikọlu DDoS Lilo Mod_Security ati Awọn modulu Mod_evasive

Iyẹn ni gbogbo fun bayi! Ninu nkan yii, a ti ṣalaye awọn aṣẹ iṣakoso iṣẹ Apache/HTTPD ti o wọpọ julọ ti o yẹ ki o mọ, pẹlu bibẹrẹ, muu ṣiṣẹ, tun bẹrẹ ati didaduro Apache. O le nigbagbogbo de ọdọ wa nipasẹ fọọmu esi ni isalẹ fun eyikeyi ibeere tabi awọn asọye.