Tuesday, 20 November 2007

Windows 2003 Shutdown Restart Command with Examples

Have you ever found loads of windows 2003 command examples, which say they work when the truth is they don't?

Well here are a couple of examples that do shutdown or restart the Server;

Shutdown Windows 2003

  • SHUTDOWN /s /d P:2:17

Restart Windows 2003

  • SHUTDOWN /r /d P:2:17

These two commands appear to work for me. visit this link (http://www.ss64.com/nt/shutdown.html) for further information.

Saturday, 29 September 2007

ie css bug fixes

Well, there are many problems that ie appears to have when it comes to css. Most problems can be fixed fairly easily when you know what the problem is, so I thought i'd list a few common fixes i use from time to time.

IE Position, Stretch or Browser Resize Problem

IE stretches too wide or after the browser is resized, ie doesn't reposition elements correctly.

ie fix

Apply position:relative to the body tag, the element and containing elements, which are effected by the bug. e.g. in your css file add


You may also have to play around with width but the above code should work a treat!

IE White Space Bug

This usually occurs when you've been floating elements around each other. This manifests itself in in ie either as a big line space appears at the bottom of the elements or the elements don't stretch the page relative to each other.

IE White Space Fix

at the bottom of the elements, add a new block element like a paragraph tag with a style of clear:both; e.g.

You may also need to adjust the height, line height and the font size so the block element doesn't appear as a new line, e.g.;

Thursday, 30 August 2007

MySQL Password Reset Root


If you're reading this - chances are, you're an idiot. I know this as I am also an idiot as I installed a development server recently and forgot the root password for mysql. Yes I should have written the password down, no I didn't. here's the steps for resetting the root password on a working linux server;

1.) First login as root via ssh
2.) kill the mysqld service and all other mysql running processes e.g.
#> service mysqld stop
#> ps waux

ps waux gets a list of all running processes

use kill to stop any running mysql processes eg kill 6194 (kill pid).

3.) After stopping/killing mysqld, run the foillowing line;
#> mysqld_safe --skip-grant-tables &

4.) You are now logged into mysql safe mode. Cut and paste the following lines

mysql -u root mysql
UPDATE user SET password=PASSWORD("your_password") WHERE User="root";

5.) then start up the mysqld service;

#> service mysqld start

That's it - all done. Now remember to write down ur password this time u idiot!

Tuesday, 28 August 2007

SELinux CURL Problem

skip to solution

Recently, I made a recursive xml sitemap generator tool, which quickly generates a sitemap, calculating how popular certain pages are related to how may linke they have internally. This helps make quick, good xml sitemaps that google likes as it follows the rough popularity that google sees of each page.

So I spent about 3 hours on this script - making it proper kick ass only to discover that when I upload the script from my dev server to my live server - the fucker doesn't work! not only that, but there's nothing reported in /var/log/messages.

After updating php-curl using yum and turning my firewall off with still no luck - I decided to get heavy handed and ask my server people to reinstall a newer version of fedora.

so afterspending another half a day setting up ftp/httpd/iptables/mysql/php/bind/etc. I uploaded the xmlsitemap generator and it still doesn't fucking work!

Oh where do I start? 'Livid' doesn't even come close - not only had i wasted the best part of a day updating my server - I didn't even manage to fix my sitemap script!!!

However, i did now have a message in /var/log/messages;

comm="httpd" dest=80 scontext=root:system_r:httpd_t:s0 tcontext=system_u:object_r:http_port_t:s0 tclass=tcp_socket

After much googling, I found this solution;


in the cli, type the following

#> getsebool -a
#> setsebool httpd_can_network_connect true

The first command displays the current SELinux settings, the second should change the SELinux setting so that httpd can access tinterweb.

I think this is one of thise annoying SELinux bugs that no-one really understands as there's not much on google about it - however i've found loads of people moaning about it and not getting it to work. Therefore I hope this helps someone!

Saturday, 11 August 2007

Vi Search and Replace

Sometimes when working with Linux cli, you have to edit files and make bulk changes to configuration files.

I use vi as a text editor and I thought I'd add this example fo search and replace using vi;


In the above example, 1 represents the first line, $s represents the end line.

One important thing to note is that you need to escape any characters like dots, for example;


would be the way you change domain names from suffolk-web-design.co.uk to suffolk-web-design.com

Wednesday, 8 August 2007

Fedora Startup Scripts

I have a fedora core box which needs to run different scripts on startup to connect to other boxes on the network.

After a bit of fiddling around, I found what appears to be the best solution for me, using ntsysv and init.d. Here's how it's done;

1.) make a new file in the /etc/init.d/ directory
2.) add your script to this file with the following lines at the top;
# chkconfig: 345 85 15
# description: of your file

3.) enter this in the shell;
chkconfig --add startup_filename

4.) type ntsysv - your startup script should now be in the list, checked and ready for action!

It's that easy!

Friday, 3 August 2007

Apache Proxypass and IIS

Once upon a time, in a lad far far away... Mr Fletcher had two demonstration servers on his local network, an excellent Linux box running php/apache, also running some funky wildcard DNS Shizzle and the other box running Windows 2003 & IIS.

However, he only had one IP address could only demonstrate one server at any given time, until he discovered Apache's ProxyPass with added wildcards.

Here's the apache Virtual Host;

<VirtualHost *:80>
ServerName ms.mysite.com
ProxyPreserveHost On
ProxyRequests Off
ServerAlias *.ms.mysite.com
ProxyPass /
ProxyPassReverse /
<VirtualHost *:80>

In this example, all subdomains of ms.mysite.com now forward onto the IIS server.

Friday, 27 July 2007

MySQL time date difference in Minutes

Here's a handy MySQL function from finding the number of minutes since a given date. In the following example, there is a table called message with 3 colums - id, pubdate and message;

SELECT TIMESTAMPDIFF(MINUTE, pubdate, now()), id, message from message;

Messages from the last 5 minutes

You can get all messages from the last 5 minutes with the following example;

SELECT TIMESTAMPDIFF(MINUTE, pubdate, now()), id, message from message where (TIMESTAMPDIFF(MINUTE, pubdate, now()) < 5);

This method is quite handy for systems displaying live data.

Thursday, 26 July 2007

PHP IP Addresses

I keep finding naffexample of how to find someones ip address.

However, I stumbled across this solution;



It returns the ip address, even if somone is behind a proxy and appears to always return an ip address.

Monday, 23 July 2007

Adobe Contribute Port Settings

Macromedia's Contribute is essentially an ftp program made to help users with limited knowledge of web design to make new and edit existing pages to their website.

Sounds Great?

Well for those of you who have had to make contribute for commercial environments and have encountered networks with a firewall - things aren't always straight forward. Lots of business networks are so secure - they prohibit contribute from accessing the internet at all.

This is very important to check out your clients network before building a contribute site.

Therefore You need to make sure the following ports are open on your clients pc/network;


To test this, I would recommend asking your client to download a copy of contribute from adobe and then ask them to connect to an ftp server test page which you have setup.

If you don't do this test, you run the risk of having to make a basic CMS very quickly for your client.

If you need a CMS very quickly and are reading this article, please feel free contact me - I have experience with having to make very quick, good CMS's for just this purpose!


Saturday, 21 July 2007

Your Indexed Pages on Google

Have you ever wanted to know what google sees when it looks at your site? Here's a search command you can use which should help.

If you want to see which pages are indexed, you can run the following command as a google search;

site:suffolk-web-design.co.uk - asdf

The "site:" part of the search means use this site, the "-asdf" part means don't use any keywords. the result is that google pulls back all pages it has indxed on your site.

This command should give you a list of all of the pages google has indexed on your site. In my experience, the most popular pages appear near the top of the search results.

You can click here to see the search in action.

Wednesday, 6 June 2007

gd-png: fatal libpng error: zlib error

When upgrading php from php4 to php5, the following error occurs;

gd-png: fatal libpng error: zlib error

I've found the solution - so I thought i'd post it here to help others.

In php5, the quality range changes for imagePNG from 0-99 to 0-9. therefore you need to change your code to relect this, e.g.

imagePNG('','', 9);

(instead of imagePNG('','',90)) - I divided the quality value by 10 and then round or floor the value accordingly.

Tuesday, 5 June 2007

Change Password in Linux

The password for linux can be changes using the passwd command. Here are a few basic examples of how to change the password from the command line;

passwd Change your own password.
passwd ftpuser Change ftpusers' password.
passwd -d ftpuser Delete ftpusers' password.

Short but sweet - i'd thought i'd add this as I always forget things like this!

Thursday, 31 May 2007

Apache Restricting using htaccess

Have you ever made a site you only want a few people to access? Perhaps you have a competitor who keeps viewing your website?

Well, there's several easy ways in apache to do this using the htaccess file and here they are;

Restrict Access by IP Address

Ok, there are several commands to remember when restricting by IP address. The first is that everything needs to go in limit tags;


Depending on the information you need you can either specify POST or GET or both as an option of the limit tag (e.g. <limit POST GET>). POST is used when getting user id's and GET is used to get information like hostnames and ip addresses.

The next useful commands are 'deny from' and 'allow from'. You can deny or allow from 'all' or from specific ip addresses or from hostnames e.g.

<limit GET>
deny from all

This means no-one has access to this site when placed in the htaccess file.

<h2>Useful Examples</h2>

Allow only from a computer with an ip address of;

<limit GET>
deny from all
allow from

Allow only from computers with an ip address in the range of 192.168.1.*

<limit GET>
deny from all
allow from 192.168.1

Allow everyone apart from computers with hostname google.co.uk or ipaddress of

<limit GET>
allow from all
deny from google.co.uk
deny from


Wednesday, 30 May 2007

The Suffolk Web Design Blog

Welcome to the first entry of the Suffolk Web Design Blog.

My name is Neil Fletcher and I own www.suffolk-web-design.co.uk - a website which I use for my sole trading business Clever SEO and In case you haven't realised (by the name of my website), I'm based in Suffolk.

This Blog is intended to help designers and developers alike. I'll be posting code and tips on how to run linux webservers, partly for my own benefit, but also for anyone who happens across this blog.

If you have any questions, please feel free to contact me here.