centos7怎么安裝apache

apache http服務器是世界上最流行的web服務器。 它是一款免費的開源和跨平臺的http服務器,提供強大的功能,可以通過各種模塊進行擴展。 以下說明介紹如何在centos?7機器上安裝和管理apache web服務器。

centos7怎么安裝apache

安裝Apache

Apache在默認的CentOS倉庫中可用,安裝非常簡單。 在CentOS和RHEL上,Apache軟件包和服務稱為httpd。 要安裝軟件包,請運行以下命令:

sudo?yum?install?httpd

安裝完成后,啟用并啟動Apache服務:

sudo?systemctl?enable?httpd sudo?systemctl?start?httpd

如果您正在運行防火墻,則還需要打開HTTP和HTTPS端口80和443:

sudo?firewall-cmd?--permanent?--zone=public?--add-service=http sudo?firewall-cmd?--permanent?--zone=public?--add-service=https sudo?firewall-cmd?--reload

我們可以通過以下方式檢查Apache服務的狀態(tài)和版本:

sudo?systemctl?status?httpd

輸出:

?httpd.service?-?The?Apache?HTTP?Server ??Loaded:?loaded?(/usr/lib/systemd/system/httpd.service;?enabled;?vendor?preset:?disabled) ??Active:?active?(running)?since?Thu?2018-04-26?07:13:07?UTC;?11s?ago ????Docs:?man:httpd(8) ??????????man:apachectl(8)  ?Main?PID:?3049?(httpd) ??Status:?"Total?requests:?0;?Current?requests/sec:?0;?Current?traffic:??0?B/sec" ??CGroup:?/system.slice/httpd.service ??????????├─3049?/usr/sbin/httpd?-DFOREGROUND ??????????├─3050?/usr/sbin/httpd?-DFOREGROUND ??????????├─3051?/usr/sbin/httpd?-DFOREGROUND ??????????├─3052?/usr/sbin/httpd?-DFOREGROUND ??????????├─3053?/usr/sbin/httpd?-DFOREGROUND ??????????└─3054?/usr/sbin/httpd?-DFOREGROUND
sudo?httpd?-v

輸出:

Server?version:?Apache/2.4.6?(CentOS) Server?built:??Oct?19?2017?20:39:16

最后,要驗證安裝,在您所選擇的瀏覽器中打開您的服務器IP地址http://YOUR_IP

使用systemctl管理Apache服務

我們可以像任何其他系統(tǒng)單元一樣管理Apache服務。

要停止Apache服務,請運行:

sudo?systemctl?stop?httpd

要再次啟動,請鍵入:

sudo?systemctl?start?httpd

重新啟動Apache服務:

$sudo?systemctl?restart?httpd

在進行一些配置更改后重新加載Apache服務:

$sudo?systemctl?reload?httpd

如果您想禁用Apache服務以在啟動時啟動:

$sudo?systemctl?disable?httpd

并重新啟用它:

$sudo?systemctl?enable?httpd

更多Apache的相關技術文章,請訪問Apache教程欄目進行學習!

? 版權聲明
THE END
喜歡就支持一下吧
點贊15 分享