无法访问复制到 /var/www/ 或其他文件夹中的 php 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14992802/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 08:19:53  来源:igfitidea点击:

Can't access php files copied into /var/www/ or other folders

phpapacheubuntuhtdocs

提问by lovetostrike

I'm on Ubuntu 12.10 with LAMP setup. I copied a subdirectory which has project files (php, html, css) from xampp/htdocs on my Windows PC into /var/www/ of my ubuntu. However, when I access those files from browser (I can see the directory listing), I get 403 Forbidden on all files within that directory. So I create new dummy php files within that directory just to see if I can access, and it works. Any idea what might be the problem?

我使用的是带有 LAMP 设置的 Ubuntu 12.10。我将一个包含项目文件(php、html、css)的子目录从 Windows PC 上的 xampp/htdocs 复制到我的 ubuntu 的 /var/www/ 中。但是,当我从浏览器访问这些文件时(我可以看到目录列表),我在该目录中的所有文件上都收到了 403 Forbidden。所以我在该目录中创建了新的虚拟 php 文件,只是为了看看我是否可以访问,并且它可以工作。知道可能是什么问题吗?

采纳答案by Robert Mihai Ionas

may be a ownership problem. try do chmod -R 775 /var/www/folderand/or chown -R domain:www-data /var/www/folder- where domain is the user of that particular virtualhost or www-data

可能是所有权问题。尝试做 chmod -R 775 /var/www/folder和/或 chown -R domain:www-data /var/www/folder- 其中域是该特定虚拟主机或 www-data 的用户

for directory listing you may want to modify in /etc/apache2/sites-available/default

对于目录列表,您可能需要在 /etc/apache2/sites-available/default 中修改

+Indexes

+索引

see http://www.cyberciti.biz/faq/enabling-apache-file-directory-indexing/

http://www.cyberciti.biz/faq/enabling-apache-file-directory-indexing/

回答by Praneeth Jayarathna

This is how I solved the issue:

我是这样解决这个问题的:

sudo su
chmod a+rwx /var/www/html/