Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dedadev's avatar

Laravel project folder permissions on shared hosting

Hi, as @Snapey suggested here I created a symbolic link public_html to the public folder inside the laravel project

.
./myproject
./public_html (this is the symlink to `myproject/public` folder`)

At first I set the myproject folder permissions equal to the ones in the original public_html folder (750), and that gave me this error

    Forbidden

    You don't have permission to access this resource.
    Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

But if I set the myproject permission to 755 everything is working fine.

The funny thing is that in another server (still cpanel, different hosting) the myproject permissions are 750.

I would like to know why this is happening and, security wise, if it's ok to use 755

Thank you in advance

Bye

0 likes
2 replies
Snapey's avatar

Its because of file ownership

When you list a directory you see something like snapey snapey against each file or directory which means that I own the file and the file belongs to the snapey group.

The permission 750 says that the owner can read, execute and write, group members can read and execute, and all other users have no access.

The permission 755 says that the owner can read, execute and write, group members can read and execute, and all other users can read and execute.

Assuming your web server is running under an account like www-data and is a member of group www-data then with 750 it has no rights to access snapey's files.

You can change ownership with the chown command, for instance chown -R www-data:www-data public_html would change the ownership so that the folder and all its children (-R) belongs to www-data user

dedadev's avatar

Thank you @snapey for your answer.

After researching a bit on the matter I've found this article from the cPanel support QA. In my case it seems that to use the default 750 permission you need a folder owned by the group nobody. Unfortunately the hosting does not provide an ssh access but I still got the older public_html folder (with 750 permissions) just renamed to public_html_bkp. So I think I could just copy that folder, renamed it and copy inside the data from the current myproject folder. That should let me have a folder with the correct permissions.

Maybe I could have changed the ownership using a one-time cronjob but I don't think my user has the permission to do so.

Thanks again

Please or to participate in this conversation.