php - 如何修复错误 403 错误 php 文件

标签 php apache ubuntu

我正在运行 ubuntu 16.04 并以这种方式安装 LAMP:

安装 Apache

sudo apt-get install apache2



安装 MySQL

sudo apt-get install mysql-server



安装 PHP

sudo apt-get install php7.0 libapache2-mod-php7.0



重启服务器

sudo /etc/init.d/apache2 restart



检查 Apache

Working



检查 PHP

php -r 'echo "\n\nYour PHP installation is working fine.\n\n\n";'





在职的

文件结构:

/var/www/html/index.html > redirects to index.php /var/www/html/pages/index.php < this file is not working and all php files



所有者组设置为:

chown -R www-data:www-data /var/www



文件夹权限为 755。 index.php 权限为 644 这是我的 apache2.conf 文件:https://ghostbin.com/paste/wwhog

但是当我去:http://localhost/pages/index.php我得到这个 403 Forbidden 错误。好像我看不到php文件。

最佳答案

以下是一些解决方法。

  • chmod 文件 644 和文件夹 755(你有相反的一面)
  • 检查文件夹和文件的所有者并正确地chown它们。
  • 禁用 SELinux。

  • 检查 Apache 的错误日志文件将为您提供有关错误的更多信息。

    关于php - 如何修复错误 403 错误 php 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47692648/

    相关文章:

    php - 在 PHP 中使用默认魔术引号或用户定义的 addslash/stripslash 哪个更好?

    PHP _POST 问题毫无意义。值(value)观消失?

    javascript - 通过 javascript 使用来自 ajax 的数据填充 <select>

    linux - 无法利用所有文件的 shellshock 漏洞

    maven - Jenkins 在 mercurial commit 之后构建

    java - 将 array_chunk 从 php 转换为 java

    ajax - Apache和Nodejs跨域ajax问题

    Java使用HTTP客户端4.5客户端get语句

    php - 从 php 调用 perl?

    php - 使用虚拟机设置具有可切换 PHP 版本的本地网络服务器