When I first installed WordPress on my new VPS server I wasn’t able to upload photos. All I saw was this.
‘An error occurred in the upload. Please try again later.’ Ok.
I did a lot of reading, but couldn’t really find anything. I knew that if I set my folder permissions to 777 that it would do the trick, but I also knew this wasn’t the right solution as this effectively makes it so anyone can access that folder.
End of the day I contact the service folks at my service provider Knownhost who gave me an excellently easy solution in their response. Their service team is awesome.
This is actually a known issue with WordPress using mod_php (DSO) as the PHP handler; in essence, your files (owned by your account) have limited permissions to the webserver (the account “nobody” on a cPanel server) which actually executes PHP code. The better solution (not 777 permissions) is to change the PHP handler to SuPHP, which causes PHP scripts to be run as your account (not as nobody) and thus prevent this issue. You can find an overview of the various common PHP handlers at http://boomshadow.net/tech/php-handlers/ which does specifically address the problem of uploads via PHP script while using DSO.
In shared hosting environments (like DreamHost, who I gather you recently left), SuPHP is by far more common as it prevents certain potential server compromises (related to the fact that under DSO PHP scripts are executed using an account other than your own; especially coupled with 777 permissions, it’s possible for an attacker to modify or inject a PHP script to run arbitrary code, and then gain access to every file which the webserver user can access). We default to DSO on our VPS’s simply because it’s much faster (when used appropriately).
There you have it. I flipped one setting in WHM and everything was working beautifully again.
To do this: Access WHM > Go to Service Configuration > Configure PHP and suEXEC > Change your PHP handler to suphp. Save.