Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED How to reset permissions on hosting account files

Discussion in 'General Discussion' started by maestroc, Sep 9, 2018.

  1. maestroc

    maestroc Well-Known Member

    Joined:
    Aug 23, 2012
    Messages:
    56
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Reseller Owner
    I have an account on my server with wordpress installed as an add-on domain. Somehow I must have screwed up the permissions on the account because WP will no longer allow me to install anything (says it cannot create folders, etc.). Is there any way to easily reset the permissions including ownership of folders and files on an account to the way they were when the account was opened?

    I had considered deleting the account and restoring from backup but wouldn't that just put the same permissions back in place? This has been going on for a while so I do not have a backup from before the problem started.

    Any idea how I can fix this?
     
  2. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    1,088
    Likes Received:
    442
    Trophy Points:
    113
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    Here is how I usually correct all permissions for a site (as root).

    (You may need to ask the server administrator to do this for you if your Reseller shell access doesn't have enough privileges)
    Code:
    find /home/<cpuser>/public_html/ -type f -exec chmod 644 {} \;
    
    find /home/<cpuser>/public_html/* -type d -exec chmod 755 {} \;
    Replace <cpuser> with the actual account username. If your Add-On domain is being served from another folder, or from outside of /public_html, you should modify the folder paths as necessary.



    You can also change the file and folder permissions from the File Manager in the users cPanel.

    See File Manager - Version 74 Documentation - cPanel Documentation for full details
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #2 rpvw, Sep 9, 2018
    Last edited: Sep 9, 2018
    cPanelLauren likes this.
  3. DennisMidjord

    DennisMidjord Well-Known Member

    Joined:
    Sep 27, 2016
    Messages:
    210
    Likes Received:
    20
    Trophy Points:
    18
    Location:
    Denmark
    cPanel Access Level:
    Root Administrator
    While the above is usually fine, some files and folders sometimes needs other permissions.
     
  4. maestroc

    maestroc Well-Known Member

    Joined:
    Aug 23, 2012
    Messages:
    56
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Reseller Owner
    I gave those commands a try. Sadly I still get the Could not create directory error.
    Could it be ownership somehow? /Public_html is username:nobody but all files and folders inside the public_html have been set as username:username recursively.

    drwxr-xr-x 9 username username 4096 Sep 9 19:46 sitename.com

    and inside that folder as an example:

    -rw-r--r-- 1 username username 3340 May 22 23:39 wp-config.php
    drwxr-xr-x 7 username username 4096 Aug 9 2017 wp-content
    -rw-r--r-- 1 username username 3669 May 11 03:24 wp-cron.php
    -rw-r--r-- 1 username username 246 Jul 29 2014 wp-feed.php
    drwxr-xr-x 18 username username 12288 May 11 03:25 wp-includescd

    if I dig deeper into those folders the permissions and ownership seem to be correct.

    Is there anything else I should try?
     
  5. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    6,237
    Likes Received:
    478
    Trophy Points:
    233
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @maestroc

    What's the error you're getting specifically - this would most likely show up in the PHP logs (if enabled) from the domain's docroot

    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. maestroc

    maestroc Well-Known Member

    Joined:
    Aug 23, 2012
    Messages:
    56
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Reseller Owner
    The error_log file is there but it hasn't been updated since around the time this problem started happening. My guess is that the error_log for that folder cannot be written to even though it is set to 0644 and username:username

    If I force an error by trying to install a new plugin it does not append anything to the error file. The last lines in the file are from a year ago (yes this site does not get new content very often). Those lines are pasted below but I don't think they are applicable to this. No idea though...

    [01-Sep-2017 08:07:55 UTC] PHP Warning: Illegal string offset 'choice_new' in /home/xxxx/public_html/vx/wp-content/themes/wp_olympic5-v1.0.1/functions.php on line 308
    [01-Sep-2017 08:07:55 UTC] PHP Warning: Illegal string offset 'placeholder' in /home/xxxx/public_html/vx/wp-content/themes/wp_olympic5-v1.0.1/functions.php on line 309
    [01-Sep-2017 08:07:55 UTC] PHP Warning: Illegal string offset 'section_id' in /home/xxxx/public_html/vx/wp-content/themes/wp_olympic5-v1.0.1/functions.php on line 310
    [01-Sep-2017 08:07:55 UTC] PHP Warning: Illegal string offset 'option_group' in /home/xxxx/public_html/vx/wp-content/themes/wp_olympic5-v1.0.1/functions.php on line 313
     
  7. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    1,088
    Likes Received:
    442
    Trophy Points:
    113
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    I hate to do this:

    You may want to review Topic: Problem with several themes | WordPress.org

    Download a new copy of the wp_olympic5-v1.0.1 theme to your computer, and compare the functions.php file to the one on the server. (This is not 100% fool-proof, as the theme provider itself may have been compromised at source)

    If the site has been hacked, they may have set the files or folder to be immutable, and even installed more damaging remote access software or a webshell (not necessarily in that particular account or folder)

    If you determine that the theme is OK and non of the files have been tampered with, and that there are no other signs of rogue files or access, you could try switching to one of the standard Wordpress themes for a moment, and see if the problem persists.

    A couple of other forum posts that may be relevant:
    Can't delete infected file
    WordPress sites getting compromised and Malware
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    Infopro likes this.
  8. maestroc

    maestroc Well-Known Member

    Joined:
    Aug 23, 2012
    Messages:
    56
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Reseller Owner
    Not sure if it was hacked or not but sure enough, I swapped in a different theme and everything started working again... Thank you for assisting with this!
     
  9. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    6,237
    Likes Received:
    478
    Trophy Points:
    233
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Thank @maestroc for posting the errors you were receiving as you can see they helped a lot! I'm glad you were able to get the issue fixed.

    @rpvw thanks for the sound advice!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice