Fantastic PHP trick to fix permission errors

by Sapphire (December 21, 2005)

Here’s a tip I learned from the brilliant Garvin of Serendipity blog. Have you ever lost your ability to change permissions, edit or delete a particular file on your server? I’ve had it happen on a couple of sites where I was using php software that had the ability to fetch and install plugins for me - like Serendipity’s one-button install feature for plugins and themes. Some hosts aren’t set up to treat you like the author of those files when that happens, so all of a sudden you can’t touch that file.

Here’s a script that makes all that go away:

<?php
chmod(’/path/to/your/serendipity/serendipity_config_local.inc.php’, 0777);
?>

You want to replace “/home/user/public_html/path/filename.php” with the exact path to the file you want to change permissions on. You just save that code as a file called “fixperm.php” on your server. Then you launch that page in your browser, and the permissions change. You can also replace “0777″ with something else, if you prefer.

This may happen less and less - the latest version of Serendipity has a built-in way to protect against the permission errors in the first place. But I didn’t know that, because really, Serendipity is above my head. So if, like me, you insist on mucking around with software you don’t really understand, this little trick might just come in handy.

Your Ad Here


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Comments will be sent to the moderation queue.