博主看的安裝教程是centos6.3的,發現安裝時與centos7.1有許多不一樣,因而邊查邊安裝,記錄了這篇Centos7的安裝教程。html
1、安裝httpd服務apache
apache在centos7中是Apache HTTP server。以下對httpd的解釋就是Apache HTTP Server。因此想安裝apache實際上是要安裝httpd。centos
首先,檢測系統中是否已安裝其餘版本的httpd,結果沒有輸出則證實沒有安裝過;服務器
檢測命令:rpm -qa | grep httpdide
查詢系統內置的httpd版本狀況,找到httpd.****:Apache HTTP Server這一句,其中的httpd.****就表明你的服務器自帶的httpd版本;測試
命令:yum search httpdui
運行你的httpd安裝文件;編碼
命令:yum install httpd.x86_64 ----紅色部分替換成你本身的httpd版本。centos7
安裝成功,啓動httpd服務spa
命令(centos7):systemctl start httpd.service
啓動成功!咱們如今來訪問ip測試一下吧!
激動人心的時刻到了!噹噹噹當!出現這個頁面即表明安裝成功!
(若是有朋友使用的是騰訊雲主機,服務器顯示安裝成功,可是網頁鏈接不上的話,請參考個人上一篇博文)
少俠,先別走!最後,咱們來配置一下咱們的httpd文件!
打開/etc/httpd/conf.d/目錄,裏面的【httpd.conf】文件便是httpd的主配置文件;
而後,咱們可使用vi編輯命令對這個文件進行編輯(通常來講安裝完無異常的話能夠不用動)
分別修改如下幾點
#服務器根目錄
ServerRoot "/etc/httpd"
#端口
#Listen 12.34.56.78:80
Listen 80
#域名+端口來標識服務器,沒有域名用ip也能夠
#ServerName www.example.com:80
#不準訪問根目錄
<Directory />
AllowOverride none
Require all denied
</Directory>
# 文檔目錄
DocumentRoot "/var/www/html"
# 對 /var/www目錄訪問限制
<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
# 對/var/www/html目錄訪問限制
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# 默認編碼
AddDefaultCharset UTF-8
#EnableMMAP off
EnableSendfile on
# include進來其它配置文件
IncludeOptional conf.d/*.conf
9.使用vi命令 :wq保存退出,而後再重啓httpd服務就大功告成了!