安装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】--网站数据目录
![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)
网站数据目录-->
![DocumentRoot.jpg](https://upload-images.jianshu.io/upload_images/21679232-54e424d1d930e7f4.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
网站数据目录的权限-->
![Directory.jpg](https://upload-images.jianshu.io/upload_images/21679232-aacf6efe73fb28e2.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
监听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)
【修改网站的数据目录为/home/wwwroot】
创建目录
![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里的网站数据目录和网站数据目录的权限
![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)
如果没有出现自己设置的页面则需要[关闭SElinux]
修改/etc/selinux/config的selinux为禁用状态
![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)