2020-03-14

安裝Apache服務程序

yum install httpd

![yuminstallhttpd.jpg](https://upload-images.jianshu.io/upload_images/21679232-fb18a465f615ea61.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

rpm -ql httpd? 查看安裝的所有文件

![http.conf.jpg](https://upload-images.jianshu.io/upload_images/21679232-7e53e2f006852cda.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

【/etc/httpd】--服務目錄

【/etc/httpd/conf/httpd.conf】--主配置文件

【/var/www/html】--網站數(shù)據(jù)目錄

![html.jpg](https://upload-images.jianshu.io/upload_images/21679232-270bd111aa476c64.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

【/var/log/httpd/access_log】--訪問日志

![access_log.jpg](https://upload-images.jianshu.io/upload_images/21679232-05099dcd3eabb2f8.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

訪問日志實時更新用戶訪問的詳細信息

![access.jpg](https://upload-images.jianshu.io/upload_images/21679232-3abfb429aa5b0a55.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

【/var/log/httpd/error_log】--錯誤日志

![error_log.jpg](https://upload-images.jianshu.io/upload_images/21679232-8124f7ad28a73fca.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

進入主配置文件 vim /etc/httpd/conf/httpd.conf

服務目錄-->

![ServerRoot.jpg](https://upload-images.jianshu.io/upload_images/21679232-1a6c6cc7a9508bc1.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

管理員郵箱-->

![ServerAdmin.jpg](https://upload-images.jianshu.io/upload_images/21679232-c2823f50d6fba458.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

運行服務的用戶&運行服務的用戶組-->

![UserandGroup.jpg](https://upload-images.jianshu.io/upload_images/21679232-74b611b776587a60.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

網站服務器的域名-->

![ServerName.jpg](https://upload-images.jianshu.io/upload_images/21679232-94a78be57d5d4329.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

網站數(shù)據(jù)目錄-->

![DocumentRoot.jpg](https://upload-images.jianshu.io/upload_images/21679232-54e424d1d930e7f4.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

網站數(shù)據(jù)目錄的權限-->

![Directory.jpg](https://upload-images.jianshu.io/upload_images/21679232-aacf6efe73fb28e2.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

監(jiān)聽IP地址與端口號-->

![Listen.jpg](https://upload-images.jianshu.io/upload_images/21679232-712896f2a4f2cd40.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

默認索引頁頁面-->

![DirectoryIndex.jpg](https://upload-images.jianshu.io/upload_images/21679232-78604ce8aebf0189.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

修改/var/www/html/index.html內容

![echo.jpg](https://upload-images.jianshu.io/upload_images/21679232-6b64cebb5668af27.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

打開火狐瀏覽器輸入127.0.0.1

![firefox.jpg](https://upload-images.jianshu.io/upload_images/21679232-608ce7048c23977c.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

【修改網站的數(shù)據(jù)目錄為/home/wwwroot】

創(chuàng)建目錄

![wwwroot.jpg](https://upload-images.jianshu.io/upload_images/21679232-8367142566c1ed84.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

修改/etc/httpd/conf/httpd.conf里的網站數(shù)據(jù)目錄和網站數(shù)據(jù)目錄的權限

![home_wwwroot.jpg](https://upload-images.jianshu.io/upload_images/21679232-3ee52232b3357eb3.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

修改完畢后wq保存退出

systemctl restart httpd --重啟Apache服務

打開火狐重新訪問

![www.xbmvp.cn.jpg](https://upload-images.jianshu.io/upload_images/21679232-f91bc33c67c2e20e.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

如果沒有出現(xiàn)自己設置的頁面則需要[關閉SElinux]

修改/etc/selinux/config的selinux為禁用狀態(tài)

![selinux.jpg](https://upload-images.jianshu.io/upload_images/21679232-b1e42d713cdbe7ac.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

修改完畢之后重新訪問即可

【個人用戶主頁功能】

編輯vim /etc/httpd/conf.d/userdir.conf

在第17行加上注釋--24行去掉注釋

![userdir.jpg](https://upload-images.jianshu.io/upload_images/21679232-cebec15dd577554e.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容