If there’s anybody out there reading this (yeah, right) who has worked with WordPress before probably knows about permalinks. They’re those handly little URLs that look like “http://www.sector930.com/01/01/foo-bar” instead of “http://www.sector930.com/?p=666″. We gave permalinks a shot a little while ago, but we noticed it was breaking all the links to individual articles. So we put it on the backburner for a while.
Today I decided to give it another go. The steps involved look something like this:
- Ensure mod_rewrite Apache module is installed
- Enable FollowSymLinks in httpd.conf
- Put AllowOverride FileInfo in httpd.conf
- Ensure WordPress has write access to the .htaccess file in the WordPress directory
Don’t ask me what any of this stuff actually does. I just followed the directions.
Anyways, in order to give WordPress access to the .htaccess file, you can make it group writeable for a certain group (at least on our system). Since I was planning on giving that group write permission to the blog anyways, I came up with this brilliant idea to save time:
cd <www_root> chmod -R 664 wordpress
Now, there’s a slight problem with that command. In order for directories to be readable from the web, they need to have execute permission. But “664″ is “owner read and write, group read and write, everyone else read.” EXECUTE IS NOWHERE IN THERE! And that lovely little “-R” ensured that every single directory underneath “wordpress” would have those permissions also. Here’s my reaction as soon as I ran that command:
#$%@%^$#%^%$#@$%^%$#@$%^&^%$#$%^&^%$#!!!!!!1111!!!1!!!!!!
What I should have run instead was:
chmod -R g+w wordpress
That would have kept me from going through each subdirectory (and there are a lot of them) and turning back on execute permission. I could have tried to write a shell or Perl script to do that quickly, but figuring that out would have taken just as much time.
You would think that by now I would have learned to back things up before making major, sweeping changes, between my job and the work I’ve done on the blog. Maybe this time…
Why didn’t you just issue “find -type d -exec chmod 774 {} \;” ? It recursively searches from and chmods all directories.
Because apparently I’m a CLI noob.
It’s ok I probably would have done it exactly the same way you had. It was only after you mentioned a script that I thought of the find command.
Couldn’t you have just run “chmod -R 775 wordpress” ?
Wouldn’t that have updated the permissions?
What am I missing here?
If I just ran “chmod -R 775 wordpress”, that would make every single file and directory under wordpress have the following permissions: “rwxrwxr-x”. That’s not what we want. We want files to look like “rw-rw-r–” and directories to look like “rwxrwxr-x”.
Before I started, files looked like “rw-r–r–” and directories looked like “rwxr-xr-x”. So if I had just run “chmod -R g+w wordpress”, we would get the desired result. But instead, I made everything, files AND directories, look like “rw-rw-r–”. So I had to go back and fix the directories.