Wednesday, June 22, 2011

NearlyFree Speech, Mac OSX, and WordPress

I have to get a little technical today. I've had to relearn this issue multiple times and it's just time I wrote it down.
First- I use's hosting service. I do this becuase I'm cheap and I feel like I should learn to be responsible about navigating my own website. Not for the faint of heart- it requires you to have a little know-how in the realm of web development specifically if you want to set anything up like WordPress on a site becuase nothing there is point click and done- there's a lot of manual setup.
One thing that drives me crazy is NearlyFreeSpeech's PHP safe_mode. It's turned on- all of the time- so the scripts that would normally run all cozy inside of WordPress are pickled. It requires you to go and change the group permissions of each folder and file- recursively- into the guts of your site.
That means each time you install, update, or add files- you need to do it all again becuase the new files will have the old default group and permission levels selected for you- and you will get crazy error messages inside of your WordPress install like: If your .htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file. Click in the field and press CTRL + a to select all.


You need to change your group permissions to "web" and most of your problems will be solved- except for your .htaccess file but that's OK- I like to keep those edits away from scripts anyhow.

So here are the instructions (mostly for me) so I stop trying to remember how I did i the last time and flipping through the dumb terminal commands that I use so little now that they aren't burned into my subconscious anymore. (Those of you who play tetris in your dreams using machine language commands are with me on this one- don't lie- it's happened to you.)

If you have FileZilla or WinSCP you can go and look at the permissions on the file. Mine were set to a number. It could also say "me" or something else. If your owner and group permissions are all matchy matchy- then you need to fix the group ownership to web. Here we go-- 

If you have Mac OSX- you need to open the terminal window. It will say
macusername:~ MacUserName$  


It will ask you politely for your password-- type it in
You can check your permissions here as well.  If you installed wordpress in a different directory than the one you are sent to- change to the wordpress directory by typing  cd directory. I don't have to do this but just in case ... Once you are there... Type:

ls -al

The contents of your WordPress directory will show up. There will be two columns in the middle that disply the group and owner permissions. If there is a column that does not say web- move forward. Also- your file permissions should be set to 664 and your directory to 775. If your permissions are set to 777 then someone tricked you- that's a bad deal. It's the cheater's way out and you are vulnerable to goodness knows what. You should definitely change if you see that kind of silliness in there. Mostly people do that when they get confused but that's why safe_mode isn't always safer becuase users avoid it and then leave themselves vulnerable to nasty little attacks. Anyway- if you are like me- you've just added a folder and some permissions are what you are aiming for and some are the default.

Change the group permissions to web by typing:

chgrp -R web *

It might take a while- On to part 2:
Change your file permissions to 664. Type:

find . -type f -exec chmod 664 {} \;

Then change your directory permissions to 775: Type:

find . -type d -exec chmod 775 {} \;

Whew- all done! Go back to FileZilla and refresh. You should see "web" generally in that second set of columns. now. Go back to WordPress and run whatever script you were running before you got your error. It should work now. 
And now that I've documented what I've done- I'll save an hour next time from fiddling around in my terminal window mistyping commands and scrunching my brow in frustration that a 5 minute task is taking me half the evening. Still- I'm saving a ton of cash by going with a less expensive provider-- maybe it's worth the time and it helps keep my skills at least a little untarnished.

No comments:

Post a Comment