PHP Safe mode workaround

Just had a small crisis with an author trying to post a
breaking news story to a WordPress site I maintain. The site had just
been moved across from GoDaddy hosting to Media Temple’s dedicated
virtual hosting platform. Everything went fine with the move from
servers, the db backed up and imported no hassles, everything just
worked – or so it seemed!

When trying to upload an image to go with the breaking story, the author encountered an error:

The uploaded file could not be moved to .../path/to/file/

This was quite alarming as without the image, the news story could
not be released. I found the cause to be php running in safe mode, a
common configuration for the security conscious. As I’m in a dedicated
server, not a 100% private server, Media Temple sets it up like this by
default to protect all other users. That’s nice but it killed my ability
to upload in WordPress!

The long workaround is to contact Media Temple, request a support
ticket and have them enable root access for me, then go in and edit the
php.ini file via the shell and restart the web daemon. Easy – not! Also,
I would prefer no down time if possible.

The PHP Safe mode workaround I came up with was to
delete the current month’s upload folder (it was empty, so not scary!)
and then create the same named folder with my FTP program. This gave the
correct group user ID to the upload folder, allowing WordPress to
upload to it.

This wouldn’t work so easily if you already have files in the said
folder, you would first have to download them or move them to another
folder, delete the original, create the same named folder via FTP and
then put said files back.

This really got me out of trouble and will buy me time until Media
Temple grants me root access to make the long term changes needed.

More info about this problem and other workarounds are available at Sébastien Wains homepage.

Share on twitter
Twitter
Share on reddit
Reddit
Share on telegram
Telegram
Share on email
Email
Share on print
Print

Site made with love of these open source tools

The beautifully-crafted OS that forces you to learn how to do things properly.

For better or worse, WordPress powers 30% of the web. ClassicPress reduces some of the bloat.

Text is my material. Learn one text editor well.

Version controlling all the things.

Retaining workspaces on local and remote servers.

Supporting the OpenBSD community with opinionated VMs. €10/yr donated to the OpenBSD Foundation.

To Roman Zolotarev, for helping us Master the Web. My family and friends for enduring my voluntary financial hardship while pursuing my passions.