【问题标题】:how do i create an html file in document root and after that open it in my browser我如何在文档根目录中创建一个 html 文件,然后在我的浏览器中打开它
【发布时间】:2017-05-08 12:00:16
【问题描述】:

如何在 CentOS 中找到 DocumentRoot 目录,然后在该目录中创建一个 HTML 文件?如何通过我的浏览器打开该文件?

【问题讨论】:

    标签: html linux apache


    【解决方案1】:

    首先,您必须在系统中安装 Web 服务器。 Apache Web 服务器的默认 DocumentRoot 目录是 /var/www/html。 因此,如果你已经安装了 apache web 服务器,那么你需要使用 vi/nano 等任何编辑器在 /var/www/html/ 目录中创建 html 文件。

    如果您没有任何域,则可以使用该服务器 ip 在浏览器中访问该文件。 http://x.x.x.x/index.html 如果那是您的本地系统,那么您可以使用 http://localhost/index.html

    【讨论】:

      【解决方案2】:

      在 CentoS 系统中查找 Apache DocumentRoot 使用 grep 命令如下:

      grep -i 'DocumentRoot' /etc/httpd/conf/httpd.conf

      样本输出应该是:

      DocumentRoot:您将在其中提供服务的目录

      DocumentRoot "/var/www/html"

      访问不在 DocumentRoot 下的内容。

      然后通过键入以下内容转到该目录(例如 /var/www/html):

      cd /var/www/html

      然后在其中创建名为 index.html 的 html 文件,如下所示:

      vi index.html

      键入简单的单词,如 (Hello world),然后保存并退出文件

      最后,要通过浏览器 (firefox) 打开该文件,请键入下一个命令并回车:

      firefox 文件:///var/www/html/index.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-04-09
        • 1970-01-01
        • 2022-12-10
        • 2014-04-07
        • 2012-06-26
        • 2012-07-29
        • 1970-01-01
        • 2023-03-16
        相关资源
        最近更新 更多