简体   繁体   English

Apache禁止使用403

[英]Apache gives 403 forbidden

I recently had to reinstall Ubuntu and everything else as my SSD crashed. 最近,由于SSD崩溃,我不得不重新安装Ubuntu和所有其他软件。

I've got Apache/MySQL/PHP set up and can access localhost/ without problems. 我已经设置了Apache / MySQL / PHP,并且可以访问localhost /,而不会出现问题。 Running PHP and MySQL works fine as well. 运行PHP和MySQL也可以正常工作。

I keep my projects in a Dropbox folder (since the crash) located at /home/powerbuoy/Dropbox/Projects/ and have set up VHOSTs that point to some of the projects in there. 我将项目保存在/home/powerbuoy/Dropbox/Projects/的Dropbox文件夹中(自崩溃之后),并设置了指向其中某些项目的VHOST。 I've also set up /etc/hosts so that I can access my projects through http://project-name.dev . 我还设置了/etc/hosts以便可以通过http://project-name.dev访问我的项目。

However, when I try to visit http://any-project.dev all I get is 403 forbidden . 但是,当我尝试访问http://any-project.dev得到的却是403 forbidden I've run chmod -R 777 Projects/ and all the files and folders are now green in the terminal. 我已经运行chmod -R 777 Projects/ ,并且终端中的所有文件和文件夹现在都是绿色的。 That didn't help. 那没有帮助。

I checked the error-logs and they say: 我检查了错误日志,他们说:

[crit] [client 127.0.0.1] (13)Permission denied: /home/powerbuoy/Dropbox/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

But there isn't even supposed to be a .htaccess file anywhere there. 但是,甚至不应该在任何地方都有.htaccess文件。

I even set up a completely empty project ( /home/powerbuoy/Dropbox/Projects/test/index.php with just <?php phpinfo() inside), set up a VHOST and a http://test.dev URL. 我什至设置了一个完全空的项目( /home/powerbuoy/Dropbox/Projects/test/index.php其中仅包含<?php phpinfo() ),设置了VHOST和http://test.dev URL。 I get the same error here. 我在这里得到同样的错误。

Any ideas? 有任何想法吗?

Thanks 谢谢

Edit: I tried moving my test project to the desktop ( /home/powerbuoy/Desktop/test/ ) and now it works :P 编辑:我尝试将测试项目移至桌面( /home/powerbuoy/Desktop/test/ ),现在它可以工作了:P

Perhaps it has something to do with the projects being located inside the Dropbox folder?? 也许与放置在Dropbox文件夹中的项目有关?

Most probably this is a chmod issue. 这很可能是chmod问题。 You must change all trees chmod settings. 您必须更改所有树的chmod设置。 If you have ssh access you can try this commands: 如果您具有ssh访问权限,则可以尝试以下命令:

chmod 755 $(find /home/user/public_html -type d)
chmod 644 $(find /home/user/public_html -type f)

Please replace /home/user/public_html part to 'your real path'. 请将/ home / user / public_html部分替换为“您的真实路径”。

Apparently simply chmod ing the directory the project is in wasn't enough. 显然仅chmod项目所在的目录还不够。 I had to chmod all the directories higher up in the tree as well. 我还必须将树中所有更高的目录都更改为chmod

So even though my VHOST pointed to /home/powerbuoy/Dropbox/Projects/AProject/ simply chmod ing /AProject/ is not enough but it has to be done all the way from /home/powerbuoy/ it seems. 因此,即使我的VHOST指出/home/powerbuoy/Dropbox/Projects/AProject/只是chmod ING /AProject/是不够的,但它有许多工作要做,从一路/home/powerbuoy/看起来。

The reason you had to chmod the permission going up the directory tree is that Linux doesn't permit you to simply access a folder such as /home/jsmith/my_folder directly. 您必须chmod进入目录树的权限的原因是Linux不允许您直接访问/home/jsmith/my_folder类的文件夹。 You have to also have execute permissions to / /home/ and /home/jsmith . 您还必须具有对/ /home//home/jsmith执行权限。 The execute bit allows the affected user to enter the directory, and access files and directories within it. execute位允许受影响的用户进入目录,并访问其中的文件和目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM