zend-framework2 - Zend框架2 : 403 forbidden error when trying to access localhost

标签 zend-framework2 localhost http-status-code-403

大家好,我是 Zend Framework 的新手,显然无法使其工作。

当我尝试访问 localhost 时,浏览器向我抛出 403 禁止访问错误。这是我的虚拟主机文件:

  NameVirtualHost *:80
<VirtualHost *:80>
    ServerName zf2-tutorial.localhost
    DocumentRoot /var/www/html/zf2-tutorial/public
    SetEnv APPLICATION_ENV "development"
    <Directory /var/www/html/zf2-tutorial/public>
        Options +Indexes +FollowSymLinks +ExecCGI
    DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

我的 htacces 文件位于/var/www/html/zf2-tutorial/上 zend 应用程序文件夹中的 public 目录中:

RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The 
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to 
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size 
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

我还对该目录中的所有文件拥有 775 权限。然而 apache error_log 似乎不这么认为:

[Thu Mar 14 12:15:48.751980 2013] [core:crit] [pid 5755] (13)Permission denied: [client 127.0.0.1:60849] AH00529: /var/www/html/zf2-tutorial/public/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/var/www/html/zf2-tutorial/public/' is executable

最后,我还在 httpd.conf 上设置了 FileInfo,以允许 htaccess 读取。

那么,有关于这里发生的事情的任何线索吗?谢谢!

更新:我发布了/var/www/html/zf2-tutorial/public 文件夹的文件列表及其权限:

total 28
drwxrwxr-x. 5 gerard root 4096 mar 14 14:01 .
drwxr-xr-x. 7 gerard root 4096 mar 14 11:20 ..
drwxrwxr-x. 2 gerard root 4096 ene 31 17:19 css
-rwxrwxr-x. 1 gerard root  711 mar 14 12:25 .htaccess
drwxrwxr-x. 2 gerard root 4096 ene 31 17:19 images
-rwxrwxr-x. 1 gerard root  303 ene 31 17:19 index.php
drwxrwxr-x. 2 gerard root 4096 ene 31 17:19 js

最佳答案

我在使用 EasyPHP DevServ 14 时遇到了同样的问题。

问题来自于 httpd.conf 文件中缺少一行

要求全部授予

<Directory "PATH TO YOUR DIR">
    Options FollowSymLinks Indexes
    AllowOverride All
    Order deny,allow
    Allow from any
    Deny from none
    Require all granted
</Directory>

希望对你有帮助!

关于zend-framework2 - Zend框架2 : 403 forbidden error when trying to access localhost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15408021/

相关文章:

php - 如何将 mysql 查询转换为 zend 查询?

php - 如何在zf2 AbstractRestfulController中调用模板文件

php - 当我添加 root 密码时,XAMPP 未将 "unsecure"更新为 "secure"

azure - 从另一个 Azure 函数调用一个 Azure 函数时出现 403(禁止)

security - 真的有可能破解抛出 403 错误的禁止 Web 浏览器区域吗?

ruby-on-rails - Google 日历 v3 返回 403 Insufficient Permission

php - ZF2 中的 session

pdo - Zend PDO ODBC 数据库选择

c# - 在 ASP.NET 中调试时,什么可能导致 LocalHost 上出现 "Connection Interrupted"

javascript - Node.js 一直在本地主机上挂起/加载