首页 文章

无法从/ var / www / html - 403禁止运行index.html

提问于
浏览
0

我将一些文件从本地文件夹复制到apache服务器文件夹/ var / www / html,其中 includes an index.html as well .

我创建了一个测试文件来检查文件夹中的php版本,它给出了正确的phpinfo()结果 .

但我无法从浏览器运行localhost / index.html . 我得到错误 -

Forbidden

You don't have permission to access /index.html on this server.

Apache/2.4.7 (Ubuntu) Server at localhost Port 80

我在 /var/www/html 内运行 ls -l 检查了所有者信息,这是结果 -

drwx--S--- 4 root www-data  4096 Mar 26 22:28 ch01
-rw-r--r-- 1 root www-data    20 Mar 26 22:16 check.php
-rw------- 1 root www-data 36911 Mar 26 22:28 fang.jpg
-rw------- 1 root www-data  2060 Mar 26 22:28 index.html
-rw-r--r-- 1 root www-data    19 Mar 26 22:28 pp.php
-rw------- 1 root www-data  1261 Mar 26 22:28 report.php
-rw------- 1 root www-data    77 Mar 26 22:28 style.css

我试图从头首先运行示例代码到PHP和MySQL .

我使用本指南安装了apache和php - https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu

2 回答

  • 0
    -rw------- 1 root www-data  2060 Mar 26 22:28 index.html
    

    该文件是

    • 由root拥有(谁可以读写它( rw- ))

    • www-data组的成员(无法对其执行任何操作( --- ))
      公众无法触及

    • ---

    您的网络服务器几乎肯定是以www-data运行的,因此您需要:

    • 更改文件的所有权: chown www-data index.html

    • 授予组编辑权限: chmod 660 index.html


    您与其他文件有类似的问题 .


    注意:当前的所有权和权限表明您使用root帐户来管理网站的文件 . 不要那样做 . 为此目的创建一个访问权限受限的帐户 . 只有在必要时才以root身份运行 .

  • 0

    默认位置是

    /var/www/
    

    并不是 '

    /var/www/html/
    

    你可以访问index.html at

    http://localhost:80/html/index.html
    

相关问题