zoukankan      html  css  js  c++  java
  • Httpd服务入门知识-Httpd服务常见配置案例之定义'Main' server的文档页面路径(文档根路径)

          Httpd服务入门知识-Httpd服务常见配置案例之定义'Main' server的文档页面路径(文档根路径) 

                                                    作者:尹正杰

    版权声明:原创作品,谢绝转载!否则将追究法律责任。

    一.创建测试文件

    [root@node101.yinzhengjie.org.cn ~]# mkdir -pv /data/www/html
    mkdir: created directory ‘/data/www’
    mkdir: created directory ‘/data/www/html’
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# echo "/data/www/html" > /data/www/html/index.html
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# ll /data/www/html/
    total 4
    -rw-r--r-- 1 root root 15 Dec  7 20:07 index.html
    [root@node101.yinzhengjie.org.cn ~]# 

    二.修改根目录路径

    1>.编辑“DocumentRoot ”指令的值

    [root@node101.yinzhengjie.org.cn ~]# egrep -v "^ *#|^$" /etc/httpd/conf/httpd.conf  | grep DocumentRoot
    DocumentRoot "/var/www/html"
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# vim /etc/httpd/conf/httpd.conf
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# egrep -v "^ *#|^$" /etc/httpd/conf/httpd.conf  | grep DocumentRoot
    DocumentRoot "/data/www/html"
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# 

    2>.给自定义的"DocumentRoot"指令指定的目录授权(若不执行该步骤客户端将无法访问"/data/www/html"目录下的文件哟~)

    [root@node101.yinzhengjie.org.cn ~]# cat /etc/httpd/conf.d/document_root.conf
    <Directory "/data/www/html">
        Require all granted
    </Directory>
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# httpd -t
    Syntax OK
    [root@node101.yinzhengjie.org.cn ~]# 
    [root@node101.yinzhengjie.org.cn ~]# systemctl restart httpd
    [root@node101.yinzhengjie.org.cn ~]# 

    3>.测试客户端是否正常访问

  • 相关阅读:
    nginx 附件上传不上去 client_max_body_size 设置的太小
    python 1
    NGINX 常用配置
    Linux OOM Killer 保护机制
    MacbookPro接上HDM连接显示器不能上网的解决方法
    python 逻辑运算符 () > not > and > or
    TASSL 服务端 客户端测试代码
    SSL通信双方如何判断对方采用了国密
    C/S boringSSL那点事
    从Chrome源码看浏览器的事件机制
  • 原文地址:https://www.cnblogs.com/yinzhengjie/p/12002663.html
Copyright © 2011-2022 走看看