Fixing files and folders permissions on your host account

Some users can face permissions problems with the hosting account service.
After you published aplications and you get messages like "500 Internal Server Error" or when trying to creating the connection on scriptcase deploy environment you get an error like this "failed to open stream: Permission denied in..."

The first thing that some people say is to give 0777 permission. The first "7" is the total permission for the owner, the second one is for the group and the third "7" is for everyone. Here is the trick, for hosts company, a permission 0777 is a security issue for php files. "Everyone" can't have total permission. So you cant an internal server error.

The correct permissions are:

Folders: 0755
Files: 0644

So, how to fix? 
Step-by-step:

1. Open a shell (or putty on windows) and log in into your SSH account;
(if you don't know how do this, just follow this tutorial: https://client.scriptcase.host/knowledgebase/2342/How-to-access-your-hosting-account-at-the-terminal-SSH.html)

2. Execute the command to solve these problems at your public_html(www) folder:

find /home/$(whoami)/public_html/ -type d -exec chmod 755 {} \; && find /home/$(whoami)/public_html/ -type f -exec chmod 644 {} \; && find /home/$(whoami)/public_html/ -name wkhtmltopdf* -exec chmod 755 {} \; && find /home/$(whoami)/public_html/ -name phantomjs* -exec chmod 755 {} \; && find /home/$(whoami)/public_html/ -name zend* -exec chmod 755 {} \;

If you need to change permissions in another directory like a addon domain directory, just replace every public_html is this command by the directory name you want.

Was this answer helpful?

 Print this Article

Also Read

How to redirect a site from http to https using .htaccess

First you need to create a .htaccess file on your host.After you need to use the rules below:...

php error: Allowed memory size of x bytes exhausted

If you are getting an error like "Allowed memory size of... in file...

How to redirect a page to another page or website using .htaccess?

If a page on your website no longer exist and you want to redirect it to your new page or website...

How to create a user-friendly URL using .htaccess?

If your website is using long URL like example.com/files/folder/sitemap.html, you can change it...