1.新建一个httpd服务目录文件夹
# mkdir /data/web/html -pv
![](https://i-blog.csdnimg.cn/blog_migrate/704b529bded17d7c663e7d8bab49c686.png)
-p, –parents 可以是一个路径名称。此时若路径中的某些目录尚不存在,加上此选项后,系统将自动建立好那些尚不存在的目录,即一次可以建立多个目录;
-v, –verbose 每次创建新目录都显示信息
2.# vim /etc/httpd/conf/httpd.conf
119行"DocumentRoot "/var/www/html"修改为
"DocumentRoot "/data/web/html"
还有
131行"# Further relax access to the default document root:
<Directory "/var/www/html">"需要修改为
<Directory "/data/web/html">
![](https://i-blog.csdnimg.cn/blog_migrate/c218803bf05d6919984aa89c65c307d4.png)
修改完后,使用
httpd -t
检查语法是否有误;
出现的错误:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message(
AH00558:httpd:无法使用localhost可靠地确定服务器的完全限定域名。本地域。全局设置“ServerName”指令以抑制此消息
)
![](https://i-blog.csdnimg.cn/blog_migrate/9ecfa59b1fcf4202f6c9a5a20e81d34a.png)
解决方法:
95行
# vim /etc/httpd/conf/httpd.conf
![](https://i-blog.csdnimg.cn/blog_migrate/0946d7068e65ffa9a6d82d605a0f83ad.png)
# systemctl stop httpd
# systemctl start httpd
# systemctl status httpd
# httpd -t
Syntax OK
![](https://i-blog.csdnimg.cn/blog_migrate/d0ce291b7921cb102de2b654ff004de6.png)
3.新建一个测试主页看一下
# vim /data/web/html/index.html
<h1>change diretory </h1>
<h2>show time </h2>
4. 修改完毕需要重启httpd服务
# systemctl restart httpd.service
![](https://i-blog.csdnimg.cn/blog_migrate/6f5c62d013af79e120fb75d858481c91.png)
修改httpd服务目录