Archive
Tag "problem"

HOWTO: Fix upload errors for WordPress on sites hosted on Nearlyfreespeech

Oh, how I hate ‘PHP safe_mode.” Unfortunately for me (and many others), this is turned on by my host, Nearlyfreespeech.net.

While this mode is turned on, you won’t be able to upload files to your blog through WordPress, which is rather annoying when inserting an image. You also won’t be able to make changes to your theme or plugin files.

The reason is because the mode disallows PHP scripts from editing a file or folder that does not have the same group as it does. It also requires that the script doing any kind of writing be part of the group “web.”

I ran a quick Google search on the problem and found a solution that works. Here are the instructions (from the author’s blog):

1)

Download Putty.

2)

Download and install the FTP client FileZilla. You won’t actually be using it to do much, but it makes it much easier to see what Putty’s doing.

It doesn’t absolutely have to be FileZilla – if you’ve got another FTP client installed, and it can do SFTP and can show you a file’s permissions, owner, and group, then that’s fine.

3)

Open Putty. There’ll be a box that says “Host Name (or IP address).” Into that box, paste “ssh.phx.nearlyfreespeech.net”. This is NearlyFreeSpeech’s SSH Hostname.

4)

Hit the “Open” button. The first time you do this, you will see a very scary-looking dialog box, saying something like “The server’s host key is not cached in the registry. Indescribably horrible things will happen to you if you click ‘Yes’ down there. My brother died that way.” It’s probably fine, hit “Yes.”

5)

A terrifying terminal window will appear, black as a moonless night. It will say “login as:” Type in your username. This is the same as your FTP username, and can be found on your “Site Information” page.

6)

It’ll ask you for your password. Type that in.

7)

Open FileZilla and log into your account using SFTP. You do that exactly the same way you log in using normal FTP, except that you put “ssh.phx.nearlyfreespeech.net” in the “Host” box instead of “ftp.phx.nearlyfreespeech.net,” and select “SFTP” instead of “FTP” in the “Servertype” box.

The first time you do this, there should be a dialog box asking if you’re sure you want to go through with this and talking about bad guys coming to get you, but you can just ignore it. They’re probably very small bad guys.

When you’re logged in, navigate to the directory WordPress is installed in and look at your file permissions and owner/group columns. Go into a few subdirectories and check them out, too.

In all likelihood, your owner/group column says “me me” all the way down. (If you have an .htaccess file in there, it may possibly say “web me” or “web web.” Don’t worry about it.) Ideally, your file permissions are all set to 664, and your directory permissions are set to 775. If not, we’ll change them in a minute.

7a)

Oh, and if you don’t have an .htaccess file in the main WordPress directory, create an empty one now.

8)

Putty starts out in your “htdocs” directory, aka your “public” directory. If you installed WordPress directly in this directory, skip to the next step.

If not, we need to change directories, using the brilliantly namedbash command “cd”. Figure out the pathname for your directory, and type in:

cd path

For example, if your WordPress installation’s in /htdocs/wordpress or /htdocs/personal/wordpress,

cd wordpress
cd personal/wordpress

9)

Okay, so you’re in your WordPress directory. Type in

ls -al

A long list of all the files in the directory will appear. The entries should look something like this:

drwxrwxr-x 8 me me 2048 Jul 3 11:06 wp-admin
-rw-rw-r-- 1 me me 32776 Jul 3 10:54 wp-app.php
-rw-rw-r-- 1 me me 129 Jul 3 10:54 wp-atom.php
-rw-rw-r-- 1 me me 1026 Jul 3 10:54 wp-blog-header.php

Yeah, it looks pretty much like what you’re seeing in FileZilla. The incomprehensible string of characters at the beginning of each line represents the file’s permissions, and the “me me” after it means that the file’s user and group are both “me.”

10)

This is the part where we actually change something. We will be changing every single file and subdirectory in your WordPress installation at once. If you’re going to chicken out, do so now.

We’re first going to change everything in the directory’s group to “web”. The command to do that is

chgrp -R web *

Type that in and hit enter. There’ll probably be a short pause before the command line reappears again.

Once it has, go into FileZilla, move to another directory, then move back. Your owner/group column should now say “me web” all the way down (except possibly for the .htaccess file, which might say “web web”). Now move into a couple of subdirectories and check them out. We did it!

11)

We probbbably did it. Just to double-check, go back to Putty, and type in

find . -group me

This will search for any files in the directory that are still part of group “me”. If you installed WordPress via Subversion, there may still be some in a directory called .svn. You can ignore those – as long as there aren’t any others, you’re safe.

12)

Now we’re going to make sure your file and directory permissions are all correct. They should be fine already – a fresh WordPress install has the correct permissions automatically – but if you or anyone else has been fiddling around with the installation trying to fix things, you may have changed some to 777 or something, which is not good. So just to be paranoid, we’re going to reset them to the default.

First, we want to change all your files’ permissions to 664 – that is, group-writable. To do that, type

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

Now, we’ll change all the directories’ permissions to 775 (group-writable all-executable, because directories need to be executable if you ever think you’ll want to, you know, open them):

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

Annnd go check around in FileZilla to make sure everything looks right.

13)

Now go test whatever didn’t work before in your WordPress installation. Hopefully it works now!

14)

Remember that whenever you upload a new file via FTP, its group will always be “me” by default. This means that next time you upgrade or install a plugin that needs to be able to write to files, you’re going to need to go back into Putty and change everything to group “web.” Again, the command to do that is:

chgrp -R web *

Thanks for the instructions, Snarp!

Comment

Google Chrome Has Troubles With Other Google Products

Just found out that you can’t create a Google Group Page with Chrome!

How funny…

Chrome not working

Peter Kao

Comment

Wow, My Windows Vista Self-Destructed

I was running a routine CHKDSK on my laptop last week and according to the Vista there were some files that required moving. So, Vista moved them around for me to “solve the problem” but instead of optimizing my laptop, it self-destructed by moving BOOT records to weird places which means that my computer can’t boot up anymore!

Comment