php 打开本地主机时权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15596020/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Permission denied when opening localhost
提问by Hari krishnan
I had recently installed Apache, PHP and MySQL in Ubuntu. And copied the files I created to the var/wwwdirectory. But when I open http://localhostit is showing
我最近在 Ubuntu 中安装了 Apache、PHP 和 MySQL。并将我创建的文件复制到var/www目录中。但是当我打开http://localhost它显示
Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
Fatal error: Unknown: Failed opening required '/var/www/index.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
警告:未知:无法打开流:第 0 行未知中的权限被拒绝
致命错误:未知:在第 0 行的未知中打开所需的“/var/www/index.php”(include_path='.:/usr/share/php:/usr/share/pear')失败
How can I run my project normally? It was working fine in windows.
如何正常运行我的项目?它在 Windows 中运行良好。
采纳答案by Nicholas Pickering
According to this article, you need to give read/execute permissions to Owner, Group, and Everyone.
根据这篇文章,您需要向所有者、组和所有人授予读取/执行权限。
Set permissions on the problem file to 777. Note, you should avoid doing this on a server that's accessible from the internet.
将问题文件的权限设置为 777。请注意,您应该避免在可从 Internet 访问的服务器上执行此操作。
http://webomania.wordpress.com/2007/03/12/permission-denied-in-unknown-on-line-0/
http://webomania.wordpress.com/2007/03/12/permission-denied-in-unknown-on-line-0/
回答by fengd
To fix this problem, look at the line in your ErrorLog, to find out which folder it is trying to access. If a block already exists for that folder, make sure it is set to allow access as necessary. If not, add a block to your Apache configuration file, allowing access as required. See the example below for folder /usr/local/awstats/htdocs.
要解决此问题,请查看 ErrorLog 中的行,以找出它尝试访问的文件夹。如果该文件夹已存在块,请确保将其设置为根据需要允许访问。如果没有,请在您的 Apache 配置文件中添加一个块,根据需要允许访问。请参阅以下文件夹 /usr/local/awstats/htdocs 的示例。
Order allow,deny Allow from all
命令允许,拒绝所有人允许
for a complete reference, check the apache wiki
如需完整参考,请查看apache wiki

