{"id":213,"date":"2013-06-03T22:08:25","date_gmt":"2013-06-03T22:08:25","guid":{"rendered":"http:\/\/blog.shineservers.com\/?p=213"},"modified":"2013-06-03T22:08:25","modified_gmt":"2013-06-03T22:08:25","slug":"auto-fix-file-permissions-and-ownership-on-cpanel","status":"publish","type":"post","link":"https:\/\/www.shineservers.com\/2013\/06\/03\/auto-fix-file-permissions-and-ownership-on-cpanel\/","title":{"rendered":"Auto Fix File Permissions And Ownership On cPanel"},"content":{"rendered":"<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone\" alt=\"\" src=\"http:\/\/www.cpanelhostings.org\/wp-content\/themes\/greyville\/i\/cpanel.jpg\" width=\"612\" height=\"287\" \/><\/p>\n<p>suPHP and FastCGI require files and folders to have a specific set of permissions\/ownership from other handlers. Without these permissions set you will see a lot of errors such as: \u201c403 Forbidden\u201d, \u201c500 Internal Server Error\u201d, or simply generic errors that commonly have the word \u2018permission\u2019 in them.<\/p>\n<div><\/div>\n<p>It can be very time consuming to track down and check file permissions across a whole server. Luckily, fixing this on a cPanel box can be scripted. This gives us a quick and very easy script you can wget to any cPanel server. Simply run the \u2018fixperms\u2019 script, specifying the user (or all users), sit back and watch the errors just disappear. I use this script daily in my administrative work and it never fails! It is simply a good generic fix if you cannot find your permission problem, or if you have just switched your handler and need a quick way to change every user account on the server.<\/p>\n<p><strong>***WARNING!!!<\/strong> The following scripts are intended for <strong>suPHP<\/strong> or <strong>FastCGI<\/strong>. If you are not running either of these two handlers, be aware of how the script works and the changes it makes.<\/p>\n<p>For example, when running DSO, some files\/folders may need to be owned by \u2018nobody\u2019 in order to function properly (such as in certain WordPress functions or PHP based file uploads). Running this fixperms will set everything to USER:USER. Under DSO, this is potentially not a problem for most sites, except a few core functions may not work. You can always change specific files later if any errors pop up.<\/p>\n<p>Furthermore, it is highly recommended that you run a full backup of your server before running fixperms or any other script that makes changes to multiple files.<\/p>\n<p>This \u2018fixperms\u2019 script is intended for cPanel servers only. It is dependent on cPanel\u2019s internal scripts and file structure. If you\u2019re on anything else (such as Plesk), it will simply fail to run. It won\u2019t be able to do anything.<\/p>\n<h2>Fixperms \u2013 for one single user<\/h2>\n<p>To use the fixperms script, simply log into your server as root, wget the file from our server, then run it. Type in the cPanel username and it will run only for that particular account.<\/p>\n<p>It does not matter which directory you are in when you run fixperms. You can be in the user\u2019s home directory, the server root, etc. The script will not affect anything outside of the particular user\u2019s folder.<\/p>\n<blockquote>\n<pre>wget http:\/\/scripts.shineservers.in\/tools\/fixperms.sh\nsh .\/fixperms.sh -a USER-NAME<\/pre>\n<\/blockquote>\n<h2>Fixperms \u2013 for all of the users<\/h2>\n<p>If you would like fix the permissions for every user on your cPanel server, simply use the \u2018-all\u2019 option:<\/p>\n<blockquote>\n<pre>wget http:\/\/scripts.shineservers.in\/tools\/fixperms.sh\nsh .\/fixperms.sh -all<\/pre>\n<\/blockquote>\n<h4>Verbosity of Fixperms<\/h4>\n<p>By default, the script runs in a \u2018quiet\u2019 mode with minimal display. However, if you\u2019re like me, you may want to see everything that is happening. You can turn on verbosity and have the script print to the screen everything that is being changed. I find this extremely useful when fixing large accounts that have many files. You can watch the changes as a sort of \u2018progress bar\u2019 of completion. The \u2018-v\u2019 option can be used per account or with all accounts.<\/p>\n<p>For one single account:<\/p>\n<blockquote>\n<pre>sh .\/fixperms.sh -v -a USER-NAME<\/pre>\n<\/blockquote>\n<p>For all accounts:<\/p>\n<blockquote>\n<pre>sh .\/fixperms.sh -v -all<\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>suPHP and FastCGI require files and folders to have a specific set of permissions\/ownership from other handlers. Without these permissions set you will see a lot of errors such as: \u201c403 Forbidden\u201d, \u201c500 Internal Server Error\u201d, or simply generic errors that commonly have the word \u2018permission\u2019 in them. It can be very time consuming to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[58],"tags":[91],"class_list":["post-213","post","type-post","status-publish","format-standard","hentry","category-cpanel-control-panel","tag-fix-ownership-and-permissions-cpanel"],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/comments?post=213"}],"version-history":[{"count":0,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/213\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/media?parent=213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/categories?post=213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/tags?post=213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}