Linux-da Apache web serwerini dolandyrmak üçin peýdaly buýruklar


Bu gollanmada, dörediji ýa-da ulgam dolandyryjysy hökmünde bilmeli we bu buýruklary eliňizde saklamaly iň köp ulanylýan Apache (HTTPD) hyzmat dolandyryş buýruklaryny suratlandyrarys. Systemd we SysVinit üçin buýruklary görkezeris.

Aşakdaky buýruklaryň kök ýa-da sudo ulanyjysy hökmünde ýerine ýetirilmelidigine we CentOS, RHEL, Fedora Debian we Ubuntu ýaly Linux paýlanyşynyň üstünde işlemelidigine göz ýetiriň.

Apache serwerini guruň

Apache web serwerini gurmak üçin, görkezilişi ýaly deslapky paýlama bukjasynyň dolandyryjysyny ulanyň.

$ 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 wersiýasyny barlaň

Linux ulgamyňyzdaky Apache web serweriňiziň gurnalan wersiýasyny barlamak üçin aşakdaky buýrugy işlediň.

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

Apache wersiýa belgisini görkezmek we sazlamalary düzmek isleseňiz, görkezilişi ýaly -V baýdagyny ulanyň.

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

Apache konfigurasiýa sintaksis säwliklerini barlaň

Apache konfigurasiýa faýllaryňyzy sintaksis säwlikleriniň bardygyny barlamak üçin hyzmaty täzeden başlamazdan ozal konfigurasiýa faýllarynyň dogrulygyny barlaýan aşakdaky buýrugy işlediň.

$ 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 hyzmatyny başlaň

Apache hyzmatyny başlamak üçin aşakdaky buýrugy işlediň.

------------ 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 hyzmatyny açyň

Öňki buýruk, ulgam ýüklemesinde awtomatiki başlamagy üpjün etmek üçin aşakdaky buýrugy işletmek üçin diňe Apache hyzmatyny başlaýar.

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

Apache hyzmatyny täzeden açyň

Apache-i täzeden açmak üçin (duruzyň we hyzmaty başlaň) aşakdaky buýrugy işlediň.

------------ 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 hyzmatynyň ýagdaýyny görüň

Apache hyzmatynyň wagt ýagdaýy baradaky maglumatlary barlamak üçin aşakdaky buýrugy işlediň.

------------ 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 hyzmatyny täzeden ýükläň

Apache serweriniň konfigurasiýasyna haýsydyr bir üýtgeşme girizen bolsaňyz, hyzmaty aşakdaky buýrugy ýerine ýetirip, konfigurasiýasyny täzeden açmagy tabşyryp bilersiňiz.

------------ 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 hyzmatyny bes ediň

Apache hyzmatyny duruzmak üçin aşakdaky buýrugy ulanyň.

------------ 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 buýruk kömegini görkeziň

Iň soňkusy, aşakdaky buýrugy işledip, systemd astyndaky Apache hyzmat buýruklary barada kömek alyp bilersiňiz.

$ 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 hakda has giňişleýin maglumat bilen maslahatlaşyp bilersiňiz: Linux-da “Systemctl” ulanyp, “Systemd” hyzmatlaryny we bölümlerini nädip dolandyrmaly.

Şeýle hem, Apache bilen baglanyşykly aşakdaky makalalary okamak isläp bilersiňiz.

  1. Apache web serweriňiziň öndürijiligini ýokarlandyrmak üçin 5 maslahat
  2. Apache web serweriniň ýüküne we sahypa statistikasyna nädip gözegçilik etmeli
  3. \Apache GUI guralyny ulanyp, Apache web serwerini nädip dolandyrmaly
  4. Linux-da Apache HTTP portuny nädip üýtgetmeli
  5. 13 Apache web serweriniň howpsuzlygy we gatylaşdyryş maslahatlary
  6. Apache-ni Mod_Security we Mod_evasive Modullary ulanyp, zalym güýçlerden ýa-da DDoS hüjümlerinden goraň

Bularyň hemmesi häzirlikçe! Bu makalada, Apache başlamak, işletmek, gaýtadan açmak we duruzmak ýaly bilmeli iň köp ulanylýan Apache/HTTPD hyzmat dolandyryş buýruklaryny düşündirdik. Islendik sorag ýa-da teswir üçin aşakdaky seslenme formasy arkaly bize elmydama baryp bilersiňiz.