Remove WordPress generator meta tag from header

Having upgraded to Wordpress 2.5.1 I discovered that if you include wp_head(); in your theme’s header.php, it now displays the following within the generated html header tags by default.

<meta name="generator" content="WordPress 2.5.1" />

Perhaps you don’t want to announce to the world exactly which version of Wordpress you are using - especially if you are slow to upgrade when new exploits become known.

The answer is to add:-

remove_action('wp_head', 'wp_generator');

to your themes functions.php file.

If you don’t have the file functions.php within your theme’s folder, simply make one.

Firefox about:config hacks

The world and his wife have just installed/updated to Firefox 3. I love this browser and have been using it for a long time. However, I’ve made a few hacks I thought I’d share.

Open a tab and type into the url bar about:config and then click on the “I’ll be careful, I promise!” button and you’re ready to roll. Each of the following hacks requires you to start typing in the preference name into the filter bar until you’ve narrowed it down enough to see it. Then you simply double click on it to alter its value.

These are hacks and some have potentially grave consequences, so use at your own risk.

Allowing Firefox to resize any popup windows

It’s sometimes annoying when you get a popup window that you want to resize but the web developer has set the javascript property resizable=no. Do the following to take back control.

dom.disable_window_open_feature.resizable
default set to false, double click and set to true

Disabling right click disabled

Sometimes web developers use javascript to disable your right click. Not anymore!

dom.event.contextmenu.enabled
default true, double click and set to false

URL bar declutter rich suggestions

With Firefox 3 comes a rather (in my opinion) cluttered suggestion drop down while typing in a URL into the URL bar. I’ve turned my down so I only see the top 3 results excluding any from my bookmarks.

browser.urlbar.maxRichResults
default 12, I’ve set mine to 3

browser.urlbar.matchOnlyTyped
default false, set to true to exclude bookmarks

Enable ANY and ALL Add-ons

WARNING: This hack is probably the one you shouldn’t follow if you aren’t sure about which Add-ons you’ve installed.

By default Firefox checks for compatibility and update security of any extensions (Add-ons) you have installed. This can mean when you update Firefox that some Add-ons become disabled because they are deemed not compatible. However, in reality they may still work fine.

extensions.checkCompatibility
default true, toggle to false

extensions.checkUpdateSecurity
default true, toggle to false

Gulp, I can’t believe I’ve just published that hack! Don’t shoot the messenger :)

EDIT: Just after posting I found this great article running over 6 pages with loads of about:config hacks.

Accessing a shared Ubuntu directory via Windows

I’ve set up an Ubuntu LAMP server for use with a Windows machine over a local network. This was primarily so my wife could develop websites from her desktop Windows machine on a local LAMP server before uploading to our live server.

I was writing some tracking code in PHP for one of those websites and needed to gain access to this local test server myself. It made sense to me that it would be simpler if I gave myself access from my Windows desktop to the same webpage files as my wife. Here’s how I did it.

First I needed to give myself a user account on that server.

sudo useradd neil
sudo passwd neil

Then I created a group called ‘usboth’ and added both my username and my wife’s to it.

sudo groupadd usboth
sudo usermod -a -G usboth neil
sudo usermod -a -G usboth amanda

I then needed to change the group ownership of the webpages directory to allow users in that group writable access.

sudo chgrp -R usboth /home/amanda/webpages
sudo chmod g+w /home/amanda/webpages

Altering Samba settings

Samba allows us to connect to our files from our Windows Desktops, so first I needed to add myself as a samba user.

sudo ambpasswd -a neil

And then edit smb.conf.

sudo pico -w /etc/samba/smb.conf

Altering Amanda’s configuration at the bottom of the file to this:-

[amanda]
path = /home/amanda/webpages
valid users = @usboth
available = yes
browsable = yes
public = no
writable = yes
force group = usboth
inherit acls = yes
create mask = 0666
directory mask = 0775

And then replicating it for me like so:-

[neil]
path = /home/amanda/webpages
valid users = @usboth
available = yes
browsable = yes
public = no
writable = yes
force group = usboth
inherit acls = yes
create mask = 0666
directory mask = 0775

Restart samba and we’re done.

sudo /etc/init.d/samba restart

If you find that now apache can’t read those files you may need to alter the permissions.

sudo chmod -R 777 /home/amanda/webpages

But with the samba settings above any new files created from now on should be fine.

We can now both map the webpages directory as a network drive and work collaboratively on the same files before uploading them live. Just the job!

Connecting to your Ubuntu Server remotely

As you already know, my wife is using an old computer running Ubuntu for her web development server. I can’t see the point in having a monitor plugged into it when all she ever needs to do is either a) alter the DocumentRoot when she works on a different site or b) wants to shut it down (rarely).

Here’s how we can do all this remotely from our Windows desktop.

Installing SSH on Ubuntu desktop

sudo apt-get install ssh

That was so easy it barely needed its own heading. SSH stands for Secure SHell and allows us to make a secure direct connection with our server. To do this we need to use an SSH client.

Connecting to our server using PuTTy

PuTTY is a free and simple ssh client for Windows. Simply download the latest version here and then run it.

Type in your Ubuntu server’s IP address where it says ‘Host Name (or IP address)’ and then hit the ‘Open’ button. From here you simply login with your Linux username and password. Now you are sitting at your Windows desktop machine but using your Ubuntu Server’s command line as if you were right there on your server.

TIP: if you want to remotely shutdown your server you type in:-

sudo /etc/sbin/shutdown -h now

Using your Ubuntu Apache test server with Windows

So we’ve set up our Ubuntu LAMP server, but now we want to use it to develop our wonderful websites. Years ago I only had one computer so I ran Linux on it and worked directly on the server itself as well as using it as my desktop. However, I personally prefer to use Windows as my desktop and use an entirely separate machine as my test LAMP server. I will be writing this ‘how to’ from that point of view, although there will be some things you can take away from this if you intend on running just Linux on one machine and nothing else.

NOTE: wherever you see username you need to change it for your actual Linux username.

Setting up a static IP address

Using the top menu navigate as follows:-

System > Administration > Network | Network Settings > Connections Tab > Choose Unlock > (enter password) > Choose Wired connection (or whatever connection method you use) > Properties > untick Enable roaming mode > choose:-

Configuration: Static IP Address
IPaddress: 192.168.1.xx , where xx is a number you choose between 0-255 (perhaps your network is 192.168.0.xx - so choose accordingly)
Subnet mask: 255.255.255.0
Gateway address: 192.168.1.1 (this is my router address, perhaps yours is 192.168.0.1 or something else!)

sudo /etc/init.d/networking restart

This basically ensures we have a static IP for our server. It means that when we want to see our website from our local network (on our Windows machine) we simply type in http://192.168.1.xx/ (whatever you chose as the IP address). Do it now and you should see the message “It works!”. If not, something went wrong.

Setting up samba

sudo apt-get install samba
sudo ambpasswd -a username

Where username is your Linux username. Here you want to have your Windows username and password identical to that of your Linux username and password. Capitals matter. If you log into Windows with Fred but your Linux username is fred then you need to change your Windows username to fred also. First change it to fred1 and then fred, because Windows thinks Fred and fred are the same and won’t change it directly.

gksude /etc/samba/smb.conf

Find and set:-

workgroup = MSHOME

remove the semicolon (;) from the beginning of

security = user

And then at the very bottom of the conf file add:-

[username]
path = /home/username/webpages-here
available = yes
browsable = yes
public = no
writable = yes

Now save and exit and restart Samba

sudo /etc/init.d/samba restart

So now we can use our Windows machine to navigate the network, find our Ubuntu server and browse all our /home/username/ files. Personally I right click on here and choose to map as network drive so it’s easily available whenever I want it. We’re nearly there!

Configuring a new DocumentRoot for apache

Create a directory in your /home/username/ called webpages. This will be where we put the websites we work on. Now we need to make apache look there instead of /var/www/.

mkdir /home/username/webpages/testsite01
gksudo /etc/apache2/sites-available/default

Alter DocumentRoot /var/www/ to DocumentRoot /home/username/webpages/testsite01/

Also change Directory /var/www/ to Directory /home/username/webpages/ and then directly under this alter AllowOverride None to AllowOverride All.

Now restart apache and you’re done.

sudo /etc/init.d/apache restart

Whenever you want to work on a new website (say testsite02) then create the new folder under webpages and put all the working files in there. Then edit /etc/apache2/sites-available/default and put a # in front of the old DocumentRoot and put a new one underneath pointing to your new testsite02. Putting # in front acts as commenting it out. This makes it easy to switch between the sites you are working on, commenting and uncommenting DocumentRoot as appropriate. Don’t forget whenever you change DocumentRoot a restart of apache is required.

There are bound to be easier, better, more elegant ways to do this, but this is an example of how I do it and it works well for me, and maybe it could work well for you too.