Skip to main content

suphp breaking WP sites

Comments

6 comments

  • dalem
    run chown -R user:user /home/user/public_html chown user:nobody /home/user/public_html for the affected accounts of course changing the user to the real user
    0
  • WorkinOnIt
    Well after spending a few hours Workin On It - Of course, I had simply to chmod the user directory.... I had done that already, but of course then I upgraded to EA4 and that had wiped out the permissions! Problem solved!
    0
  • cPanelMichael
    New Well after spending a few hours Workin On It - Of course, I had simply to chmod the user directory.... I had done that already, but of course then I upgraded to EA4 and that had wiped out the permissions!

    Hello, I'm happy to see the issue is now resolved. Could you verify which directory you had to change permissions on, and what you changed the permissions from, and to? Thank you.
    0
  • Infopro
    This is one of those warning I always think of when I see someone suggesting chmod and chown users files. Cpanel Easyapache Symlink w/dso vs suPHP
    0
  • twhiting9275
    Here's a very, very basic script that will fix almost every suphp permission/uid issue. Been using it for years, I just forget where I grabbed it from :)
    #! /bin/bash verbose="" #Print the help text helptext () { tput bold tput setaf 2 echo "Fix perms script help:" echo "Sets file/directory permissions to match suPHP and FastCGI schemes" echo "USAGE: fixperms [options] -a account_name" echo "-------" echo "Options:" echo "-h or --help: print this screen and exit" echo "-v: verbose output" echo "-all: run on all cPanel accounts" echo "--account or -a: specify a cPanel account" tput sgr0 exit 0 } # Main workhorse, fix perms per account passed to it fixperms () { #Get account from what is passed to the function account=$1 #Check account against cPanel users file if ! grep $account /var/cpanel/users/* then tput bold tput setaf 1 echo "Invalid cPanel account" tput sgr0 exit 0 fi #Make sure account isn't blank if [ -z $account ] then tput bold tput setaf 1 echo "Need an account name!" tput sgr0 helptext #Else, start doing work else tput bold tput setaf 4 echo "Fixing perms for $account:" tput setaf 3 echo "------------------------" tput setaf 4 echo "Fixing website files...." tput sgr0 #Fix individual files in public_html find /home/$account/public_html -type d -exec chmod $verbose 755 {} \; find /home/$account/public_html -type f | xargs -d$'\n' -r chmod $verbose 644 find /home/$account/public_html -name '*.cgi' -o -name '*.pl' | xargs -r chmod $verbose 755 chown $verbose -R $account:$account /home/$account/public_html/* find /home/$account/* -name .htaccess -exec chown $verbose $account.$account {} \; tput bold tput setaf 4 echo "Fixing public_html...." tput sgr0 #Fix perms of public_html itself chown $verbose $account:nobody /home/$account/public_html chmod $verbose 750 /home/$account/public_html #Fix subdomains that lie outside of public_html tput setaf 3 tput bold echo "------------------------" tput setaf 4 echo "Fixing any domains with a document root outside of public_html...." for SUBDOMAIN in $(grep -i document /var/cpanel/userdata/$account/* | awk '{print $2}' | grep home | grep -v public_html) do tput bold tput setaf 4 echo "Fixing sub/addon domain document root $SUBDOMAIN...." tput sgr0 find $SUBDOMAIN -type d -exec chmod $verbose 755 {} \; find $SUBDOMAIN -type f | xargs -d$'\n' -r chmod $verbose 644 find $SUBDOMAIN -name '*.cgi' -o -name '*.pl' | xargs -r chmod $verbose 755 chown $verbose -R $account:$account $SUBDOMAIN find $SUBDOMAIN -name .htaccess -exec chown $verbose $account.$account {} \; done #Finished tput bold tput setaf 3 echo "Finished!" echo "------------------------" printf "\n\n" tput sgr0 fi return 0 } #Parses all users through cPanel's users file all () { cd /var/cpanel/users for user in * do fixperms $user done } #Main function, switches options passed to it case "$1" in -h) helptext ;; --help) helptext ;; -v) verbose="-v" case "$2" in -all) all ;; --account) fixperms "$3" ;; -a) fixperms "$3" ;; *) tput bold tput setaf 1 echo "Invalid Option!" helptext ;; esac ;; -all) all ;; --account) fixperms "$2" ;; -a) fixperms "$2" ;; *) tput bold tput setaf 1 echo "Invalid Option!" helptext ;; esac
    To use -- login via ssh -- save everything in the code block as a file (I call it fixperms) -- chmod the file (chmod a+x fixperms) -- run the file. Initially, I'd run it as ./fixperms -all . You can run it as ./fixperms -a [username] as well Ignore errors that it spits out. I've yet to see what's causing those, or a fix to them, but it's harmless You can also run this on a periodic basis (say, maybe monthly) to automatically fix user permission issues for them, if you're feeling adventurous
    0
  • Infopro
    Appears to be from here: gist.github.com/webspectyler/6900878
    0

Please sign in to leave a comment.