wordpress

mod_security won’t let you post [solved]

In my last post, I kept getting this error when I clicked Publish in wordpress:

Error 406, Not Acceptable. An appropriate representation of the requested resource /wp-admin/post.php could not be found on this server.

It turned out my host was running mod_security and there are certain phrases it won’t let you publish. It’s censorship, but I understand why they do it. I was talking about the most dangerous command you can run in unix:

sudo rm -rf

That’s what triggered it. I had to obfuscate the text in that entry and this one just to be able to post it. (View the source of this page to see what I mean).

If you’ve been able to post normally and suddenly you can’t and are getting this error, check for weird linux commands or files in your post that could be triggering this.

Download packages and wordpress plugins with wget and SSH [solved]

If you’re a typical web designer, when you install web packages like phpBB or wordpress or plugins like bad behavior or spam karma, you probably go to the web page that hosts the file, download it to your computer, unzip it, FTP to your host, and upload the directory to install the package.

Well, if your host has SSH access, there’s an easier way:

Go to the webpage of the file you want to download and right click and copy the link instead of downloading it.

Get putty and connect to your host via SSH on port 22, using your FTP login and password.

cd to the directory you want to download the file to (such as cd public_html/wordpress/wp-content/plugins/).

Type in this command:

wget [URL]

Where [URL] is the link to the downloaded file. For instance:

wget http://mnm.uib.es/gallir/wp-content/wp-cache-2-1-1.zip

You can right click to paste in putty, so just type wget, hit space and then right click and hit enter.
Voila! Now you’ve downloaded the package right to your host. It’s way faster too.

Wget also works great for anonymous FTP files, just paste in the URL in the same way.

After you’re done downloading, to unzip a .zip file you just type:

unzip [nameoffile.zip]

To gunzip and untar a .tar.gz file you can type:

tar -xvzf [nameoffile.tar.gz]

Voila! Then follow the instructions to continue installing your package (such as logging into wordpress, clicking on plugins and activating your plugin).

Is the directory named something different than you want? Just use mv:

mv [nameofdirectory] [newnamefordirectory]

Does the unzipped directory have an unwanted subdirectory? cd into the directory/subdirectory and then move everything down a level:

cd [directory]/[unwantedsubdirectory]/

mv * ..

This is a no brainer for your typical linux guru, but a great trick for your average web developer!