Archive for the ‘Tutorial’ Category

Greasemonkey Scripts

Tuesday, September 21st, 2010

I’ve recently started playing with greasemonkey scripts. Greasemonkey is a browser extension that allows you to input javascript code into a webpage locally. This basically means you can change a website to how you would like it to do (well, as much as you can do with javascript).

So, I decided that I would do some page editing. I first of all turned my sights onto Google Reader. What a load of rubbish buttons and links that I never use. Why is that there? Thats what I was thinking. So, I wrote a greasemonkey script to get rid of all the rubbish that I don’t use. It may work for you as well, or it may not. Feel free to take the code and change it to how it would work for you. You can find the script here. And you can find the rest of my scripts here.

I am going to focus on another of my scripts in another blog post, but it isn’t quite up to scratch yet. You can have a look if you want.

I would recommend you to try out greasemonkey. It is great and stops you moaning about those little things in websites. Because, lets be honest, not every website is perfect for you. And how many times have you gone “I wish that wasn’t there” or “I would love this to be over here”. I would recommend using this introduction to greasemonkey from o’reilly. It really helped me in getting started with it.

Go script!!!

GD Star Rating
loading...

Tutorial: Migrating from Apache to Lighttpd, Saving 200M of ram

Wednesday, May 19th, 2010

Ok, so, after just 2 hours of playing around with my server, I upgraded it from Ubuntu 8.04 to 10.04 (w00t for LTS) and migrated it away from apache to lighttpd. “Whats wrong with Apache?” I hear you ask. Well, my VPS is running on 512MB of ram, and with apache running, it was literally using over 256Mb of ram, and that caused the server to crash 3 times in the last 2 weeks. This, obviously, isn’t a good thing, so I decided to try lighttpd and it turns out that my server now has almost 240Mb of ram free. So, that is a saving of over 200Mb of ram. Fantastic.

“How can I move over to lighttpd?” I now hear you cry. Well, it was actually quite simple, and I plan to show you how I moved my WordPress install over to it.

**NOTE** This  was written for Ubuntu 10.04, but should work in any other version of ubuntu, and should work for most other distros if you just use your respective package manager, and different places where the files are saved possibly

  • Well, lets go, first of all, make sure you are totally up to date with all your packages (sudo apt-get update && sudo apt-get upgrade).
  • Install lighttpd

In Ubuntu this would be “sudo apt-get install lighttpd” – this will install lighttpd, created a default conf file and start lighttpd (however, if you currently have apache running, it will fail to start because apache is already binded to port 80).

  • Edit lighttpd.conf

In ubuntu, you can find this at “/etc/lighttpd/lighttpd.conf”. If you have apache running on port 80 just now then find the line “server.port = 80″ and change it to something else (such as 81). You can keep it like this until you have all your configuration working, and access it at http://www.domain.com:81 to see if it works.

You can edit the root for your website on the line ‘server.document-root        = “/var/www”‘ – just change this to wherever your website is saved.

  • Edit wordpress settings for permalinks

Lighttpd doesn’t work very well with wordpress’ permalinks because it goes for a 404 error. For this, you will have to do 2 things.

First, edit your 404.php file in your wordpress theme and add this to the top “< ?php header("HTTP/1.1 404 Not Found"); ?>“. This will make sure that proper 404 errors will still show up in search engines (which is kinda important).

Second, edit this line in your lighttpd.conf ‘#server.error-handler-404  = “/error-handler.php”‘ and turn that into ‘server.error-handler-404  = “/index.php”‘. If you have virtual hosts set up (and I’ll show you how to do that very soon) make sure you do that in the virtual host rather than the default one.

  • And that is it…

You now have a working wordpress install on lighttpd. If it all seems to work, change the port back to 80, stop apache, and restart lighttpd (sudo /etc/init.d/lighttpd restart). There are obviously many more things you can get to do, such as virtual hosts (which I’m literally just about to tell you about), but you still can have a working install, so enjoy.

  • Virtual hosts

This is one bit of lighttpd that I really love, it is so much easier than apache. Ok, so get to a nice empty bit of you lighttpd file, (make sure it is before the bit at the end of the file that says it must be at the end of the file. Things will break…) and copy this into it:

$HTTP["host"] =~ “(^|\.)domain\.co.uk” {
server.document-root = “/path/to/”
server.errorlog = “/var/log/lighttpd/domain/error.log”
accesslog.filename = “/var/log/lighttpd/domain/access.log”
server.error-handler-404 = “/index.php”
}

Make sure you replace “domain\.co.uk” with your domain (make sure you leave the slash there though) and replace “/path/to/” to wherever your files are. Then restart lighttpd, and you are all sorted. Nice and easy. If you are using an ip address, or a subdomain instead, you don’t need the whole bit before the domain, and you can just have “sub.domain.com” or “192.168.2.1″.

I hope this tutorial has helped anyone free up some RAM on their webserver. If you have any suggestions for this tutorial, or any questions about something that has gone wrong, then please leave a comment :-) I’ll include any corrections to my work (and credit you). Have fun with your lighttpd.

GD Star Rating
loading...

Tutorial: Have an almost processor specific installation of Ubuntu – 100th post

Tuesday, July 21st, 2009

Have you ever wanted the power that you gain from compiling everything from source? But do you run Ubuntu rather than something such as Gentoo? Do you not like compiling, and would like an easy way to compile your installation? Then look no further than apt-build

compiling

Note: this guide is specific to Ubuntu.It should work on most other deb based systems, and may work on other systems using a different packaging system, but some things may be different.


Also note that this will increase the total install space of your operating system quite a bit, as source takes up much more space than binaries. My install is about 8 Gig now.

Now, the installation of apt-build is a wee bit more difficult than just “sudo apt-get install apt-build”. Although that will install apt-build, you will have to do a few other things as well.

Ok, so first of all, install using “sudo apt-get install apt-build”. During the installation, it will ask you to choose the strength of compiling that you use. Basically, you can choose how specific it compiles. If you have a very low-power processor and don’t want to wait for hours, use light or medium. If you have a bog-standard processor, use medium, and if you have a really nice processor (or you don’t mind how long it takes) then use strong.

Then it will ask you to choose your processor. It is important to note that there are very few processors that are listed here just now, so if yours isn’t listed, don’t worry. Choose one that is very similar to your processor, and we will make it more specific later on. For example, I am running an AMD phenom, but it doesn’t currently have that in the list. So I chose Opteron.

If your installer doesn’t ask you what you want to use, then throw this command at it “sudo dpkg-reconfigure apt-build”.

(more…)

GD Star Rating
loading...