1、Apache服务的搭建 1.1系统 操作系统:centos 7 1.2关闭selinux 修改配置selinux的配置文件 #vim /etc/selinux/config 将内容中的SELINUX=enforcing修改为SELINUX=disable #setenforce 0 #reboot #sestatus 2、启动Apache网站 #systemctl restart httpd 如果启动不了 就查看80端口是否被占用,再把占用的服务关掉 #lsof -i:80 3、测试在浏览器输入IP 看到这个页面说明你的服务启动成功了!!! 4、添加测试内容 #cd /var/www/html/ 在这个目录下创建一个文件夹(必须以.html为后缀) welcome to qianfeng!!! #systemctl restart httpd 重启服务器 刷新浏览器页面 也可以这样查看内容 查看网站访问 5、将网站目录修改为/www #mkdir /www #vim /etc/httpd/conf/http.conf //修改119和131行内容 :119 DocumentRoot “/www” :131 <Directory “/www” #systemctl restart httpd 浏览器测试 (什么也没有,因为目录已经修改了) #cd /www #ls #vim index.html 123456789 #systemctl restart httpd 浏览器刷新就可以看见新的内容 6、修改主页类型或者主页名 #vim systemctl restart httpd //修改164行的内容 :164 DirectoryIndex index.php #systemctl restart httpd 在/www目录下创建的内容必须以.php结尾才能在网站上显示