Tag Archives: linux tips

How to test your website before switching DNS

This article will show you how you can access and test your joomla, wordpress, drupal, or other content managed website before you actually change nameservers or DNS and risk a huge disaster! I’m surprised I haven’t written about this before – it’s such a simple thing to do, and is an absolute killer tip for any developers out there. Read More…

Exim Queue Management Tutorial

So, you have got yourself a shiney new dedicated or VPS server with cPanel or DirectAdmin or some such installed. It probably won’t be long before you have to start checking the exim mail logs and the exim mail queue to trace problems being encountered by customers.

I have put this article here more as an aide-memoir than anything. If anyone finds it useful, I’d love to hear from you!

Respect the exim queue

One of worst things you could ever do as an admin, when finding a mail queue with hundreds or thousands of frozen or delayed messages in it, is to simply clear the queue. DONT DO THIS! You might just as well not run a mail server at all. The messages you remove in this way will just vanish without a trace – your customers and the people they communicate with won’t have a clue what happened, and your service will soon be viewed as unreliable.

Sadly, many inexperienced admins use the graphical UI to do just that – because it’s easy. However, with just a few simple commands, it can become possible to inspect and manage the queue with much greater elegance.

So, read on to find out how Exim queue management can be done from the command line. Read More…

How to clear the DNS cache in Mac OSX, Windows and Linux

If you are developing websites, then the chances are at some time or other you have been driven crazy when you have updated the DNS for a client’s website only to find that your web browser is returning an error, or serving the default Apache webpage.

So, you go and check the DNS out using something like MyIPTest.com only to find that everything appears to be correct.

The confusion can be further compounded by the fact that some tools rely on the operating system’s cache (as do web browsers), while others fetch fresh results. For example, you can ping domain.com on OSX, and get a completely different IP address to that returned by dig domain.com a

This is because sometimes, the operating system’s cache doesn’t update quickly enough, because the TTL values stored within it haven’t yet timed out – so it sees no reason to go and fetch new results – not while the cached IP is reachable.

So, that’s the why – here’s the how! Read More…

Search engine friendly URLs using apache mod_rewrite

As promised, here is a brief technical overview of how to get those nice search friendly URLs using Apache mod_rewrite and .htaccess files. I have already discussed why human readable URLs are a good idea, but it really should be obvious to anyone who has a basic understanding of the way Google views page URLs when calculating page rank.

What are we trying to achieve?

We are going to take the example of a fictitious website that has a database driven catalogue. We will assume for a moment, that the page that handles the navigation of the catalogue is /catalog.php and that it accepts a category and a page number parameter. So, for example, a typical URL might be:

/catalog.php?cat=34&page=2

This would show page 2 of the results for products in the category with id=34. This is a pretty common situation. Read More…

Linux – Move or copy the contents of one directory into another

Linux TuxThe way Linux expands it’s wildcard, or globbing characters, can be confusing at first and even tasks as simple as copying a few files can sometimes turn into a learning exercise. It is sometimes necessary to move or copy files in bulk from one place to another. There are several methods for doing this in Linux, depending on which tools you have installed (Obviously, tools like rsync or unison might be better in many cases), but for this article we’re just sticking to mastering the cp command.

It’s important to understand how Linux sees the contents of each directory, because there are two special entries within each directory which people often overlook – plus there is the issue of hidden dot files – files whose names start with th dot – e.g.  .htaccess

# ls -a1
./  << This is the current directory hard link
../  << This is the parent directory hard link
new/
old/

Read More…

Bash Script to place 404.shtml and favicon.ico in home directories

OK, so you’ve noticed how your error_log files are just full to busting with 404 errors for favicon.ico and 404.shtml? Annoying isn’t it, especially when you have a lot of activity on a server, as these files can mushroom out of control.

This script will go through each user account’s home directory, and where it doesn’t find then, it will place a copy of 404.shtml and favicon.ico for you. Read More…