简体   繁体   中英

Apache gives 403 forbidden

I recently had to reinstall Ubuntu and everything else as my SSD crashed.

I've got Apache/MySQL/PHP set up and can access localhost/ without problems. Running PHP and MySQL works fine as well.

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. I've also set up /etc/hosts so that I can access my projects through http://project-name.dev .

However, when I try to visit http://any-project.dev all I get is 403 forbidden . I've run chmod -R 777 Projects/ and all the files and folders are now green in the terminal. 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.

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. 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

Perhaps it has something to do with the projects being located inside the Dropbox folder??

Most probably this is a chmod issue. You must change all trees chmod settings. If you have ssh access you can try this commands:

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'.

Apparently simply chmod ing the directory the project is in wasn't enough. I had to chmod all the directories higher up in the tree as well.

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.

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. You have to also have execute permissions to / /home/ and /home/jsmith . The execute bit allows the affected user to enter the directory, and access files and directories within it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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