亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    在Linux中管理Apache Web服務(wù)器的有用命令

    在本教程中,我們將介紹一些您應(yīng)該了解的開發(fā)人員或系統(tǒng)管理員最常用的Apache(HTTPD)服務(wù)管理命令,并且應(yīng)該讓這些命令保持在您的指尖。 我們將顯示Systemd和SysVinit的命令。

    確保以下命令必須以root或sudo用戶身份執(zhí)行,并且應(yīng)該適用于任何Linux發(fā)行版,如CentOS,RHEL,F(xiàn)edora Debian和Ubuntu。

    在Linux中管理Apache Web服務(wù)器的有用命令

    安裝Apache服務(wù)器

    要安裝Apache Web服務(wù)器,請使用默認(rèn)的分發(fā)包管理器,如下所示。

    $ 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版本

    要在Linux系統(tǒng)上檢查已安裝的Apache Web服務(wù)器版本,請運(yùn)行以下命令。

    $ sudo httpd -v

    $ sudo apache2 -v

    輸出示例

    Server version: Apache/2.4.6 (CentOS)
    Server built:  Nov  5 2018 01:47:09

    如果要顯示Apache版本號和編譯設(shè)置,請使用-V標(biāo)志,如圖所示。

    $ sudo httpd -V
    或者
    $ 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配置語法錯(cuò)誤

    要檢查Apache配置文件是否存在任何語法錯(cuò)誤,請運(yùn)行以下命令,該命令將在重新啟動服務(wù)之前檢查配置文件的有效性。

    $ sudo httpd -t
    或者
    $ sudo apache2ctl -t

    輸出示例

    AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using linuxidc.com.
    Set the ‘ServerName’ directive globally to suppress this message
    Syntax OK

    啟動Apache服務(wù)

    要啟動Apache服務(wù),請運(yùn)行以下命令。

    ———— 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服務(wù)

    上一個(gè)命令僅在此期間啟動Apache服務(wù),要使其在系統(tǒng)引導(dǎo)時(shí)自動啟動,請運(yùn)行以下命令。

    ———— 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服務(wù)

    要重新啟動Apache(停止然后啟動該服務(wù)),請運(yùn)行以下命令。

    ———— 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服務(wù)狀態(tài)

    要檢查Apache服務(wù)運(yùn)行時(shí)狀態(tài)信息,請運(yùn)行以下命令。

    ———— 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服務(wù)

    如果您對Apache服務(wù)器配置進(jìn)行了任何更改,則可以通過運(yùn)行以下命令指示服務(wù)重新加載其配置。

    ———— 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服務(wù)

    要停止Apache服務(wù),請使用以下命令。

    ———— 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命令幫助

    最后但并非最不重要的是,您可以通過運(yùn)行以下命令獲得有關(guān)systemd下的Apache服務(wù)命令的幫助。

    $ sudo httpd -h
    或者
    $ sudo apache2 -h 
    或者
    $ 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)

    就這樣了! 在本文中,我們已經(jīng)解釋了您應(yīng)該了解的最常用的Apache/HTTPD服務(wù)管理命令,包括啟動,啟用,重新啟動和停止Apache。 如有任何問題或意見,您可以隨時(shí)通過下面的反饋表聯(lián)系我們。

    如何在Ubuntu 18.04上安裝和配置Apache 2 Web服務(wù)器  http://fxwbio.com/Linux/2018-11/155507.htm

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號