Powernap – The Server Power Management


I recently moved into a new home and one of the first things that I HAD to do was setup the home media server with a XBMC front end. So I set it up and I have been watching movies and television happily for a month now. All was going well until I got my first electricity bill. Wow was it painful. Of course it include the usage of a fridge and other appliances, but the media server had not been turned off for the whole month even though I only used it maybe 2 hours a day.

To this end I set out to find a way to reduce power consumption. The first thing that I thought of was a simple shutdown script for the XBMC front end that would turn off the server before it turned off. This worked well but there where problems, that sometimes the front end wasn’t turned off for long periods with idle time, or sometimes after I turned off the front end I still wanted to access the server and I still had to manually turn the server on. Clearly this was not a long term solution.

The next concept was to get the computer to be turned on via Wake On Lan. Wake On Lan (WoL) is a method of sending a special command to a computers motherboard via an Ethernet connection. This is easy to setup but hard actually do. Searching around online I found a program Powerwake written by Dustin Kirkland which using a very simple interface can perform as required. On Ubuntu this can be installed and used to wake a computer like so:

sudo apt-get install powerwake

sudo powerwake 10.0.0.12

*Replace 10.0.0.12 with the the address of the computer you want to wake.

This can be used to wake a sleeping computer. I use a simple script built into the front end which when runs wakes the server, waits about 30 seconds and then tries to remount the fstab file. If it the remount fails it waits another 30 seconds and then tries again. When the remount succeeds the computer reloads XBMC – easy.

This leaves only the problem of getting the server to turn off after inactivity. For this I installed the powernap program. This is a great application, again from Dustin Kirkland, which acts much like a screen saver for a server or non-GUI system. It is was quite complex to setup, but once you understand how it works it becomes much simpler.

Unfortunately time has run out and this post must end now. Stay tuned for updates of how I installed Powernap and a better look at how the program works.

As power is becoming a more and more costly and a limited resource (until we switch to renewable energy sources) tools such as powernap and powerwake will become more and more necessary for both hobbyists and professionals alike.

Advertisements

Start using Fuel PHP today


The last few days I have been busy looking at the Fuel PHP framework. And it’s AWESOME. That’s not a great description, its not even very objective, but none the less it is true (you will have to take my word for it now). The framework can be found at fuelphp.com.

Today I am going to give a quick guide for installing and running Fuel PHP on a linux machine and some extra cool tricks to make the setup easier. First what things do you need, assuming that you have a fresh linux install.

  • apache webserver
  • php 5.3 (needs to be at least 5.3)
  • php cli (command line interface)
  • mysql database server
  • command line editor vi or vim (not totally necessary but i will assume that you have one as I believe command line file editing to be the easiest option)
  • wget or curl (fuel documentation uses curl but either could be used)

I will also assume that you have root access and that you are on a home computer using localhost for your domain. Production environments require more careful setup and I will address those issues in a completely different post.

Lets Go

1. install all the necessary components

sudo apt-get update
sudo apt-get install php5 php5-cli apache2 mysql-server phpmyadmin curl vim git-core

2. install the fuel PHP oil installer. (that sounds strange)

curl get.fuelphp.com/oil | sh

3. change into the directory that you want to build you fuel application in and run the fuel PHP oil create script. replace {user} with your username and {app name} with the name you want to give your application. it doesn’t matter what the name is as it wont get used in the website URI

cd /home/{user}/Public/
oil create {app name}

4. Now it that’s as far as the basic section of the documentation on the fuelphp.com documentation website. However you cannot access the app in the browser yet. Before you can do that there are a few steps that you must take. We have to set up the apache virtual host. This greatly varies on you operating system, but for simplicity I will cover just Ubuntu, and will cover different OS’s later. We need to alter the virtual host so that it follows symbolic links and knows what the root directory of the website is. Because the fuel index.php file is in the public folder in the actual top directory we will include the public directory in the website root directory.

sudo vim /etc/apache2/sites-enabled/000-default

Now make the file look like this:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /home/{user}/Public/{app name}/public
        <Directory />
                Options FollowSymLinks
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        <Directory /home/{user}/Public/{app name}/public>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

Restart apache to apply the configuration changes

sudo /etc/init.d/apache2 restart

5. If everything worked you should now be able to go to http://localhost/ and the fuel app page should be visible. It looks a little bit like the codeigniter welcome page. (most of the developers of fuel have or still do contribute to codeigniter).

Conclusion

Hopefully this is guide is a relatively straight forward explanation of how to set up fuel on a new development environment. Any questions or comments are appreciated. I’m sure I made a mistake somewhere in there or perhaps it just didn’t work on your computer. I would also love to get some suggestions on what you would like to see next.

Selecting Hardware for a Server – Ubuntu Server


Hardware is KEY.

You must have the BEST.

I am here to tell you that ITS ALL LIES. Fed to us through not just the media but big businesses and other corporate goons, bent on taking us for as much money as we can. The truth of the matter is that unless your running windows 7 ultimate packed full of processor heavy programs, you only need the most minimal of hardware setups by todays standards to run a server and even then it will most like be underused. (more…)

Building The Ultimate Ubuntu Home Server


It is my goal to provide the means to create the perfect home server. I have been using Linux for about 1 year now. I started with Fedora for about 3 months, and having grown tired of the look and feel of Gnome in fedora, switched first to Kubuntu then Ubuntu and finally settled on Ubuntu studio (looks cool and comes with all the needed video and audio tinkering tools that I could dream of). I love the functionality that Ubuntu brings and of course the cost!

Beyond using Linux as my desktop, when I purchased a server about 3 months ago, I was completely oblivious as to the power of running a home server. Now all my computers can communicate through an internal mail system, can share a printer, have all my files and folders backed up and in a version control system. Essentially, it provides me with a commercial level of control, without any associated fee.  Which is exactly what I want.
(more…)

Choosing A Version – Ubuntu Server


Arg. So many flavors. Linux comes in many varieties, and then those varieties have versions. It can be so difficult to choose.

At the first level, Linux is broken up into distributions. There are many different distributions, and while on some level that are all fundamentally different, Many have the same general base. For example Ubuntu, Mint and Backtrack are all derivatives of the Debian distribution, an Operating system based upon fundemental principles and a complex package management system (read more about apt here)

For the next two levels of variety i will be referencing the Ubuntu distribution.

On the second level each distribution has a number of release versions of there OS. They are usually the latest release and a long term support release. The latest release is a stable version of the development version that is actively being worked on, and while it is stable, it is the most likely to break. The long term support release (LTS) is version which is more robust and will be supported further into the future.

At the next level down, each release version comes in a number of version for each CPU type. You can get 64 bit and 32 bit architecture OS and a version that supports arm architecture as well as many others. Mostly likely however you will have an Intel CPU and so will either use AMD64 or i386 versions.

Lets look at an example of choosing a Linux OS. For this example i will be selecting a OS for my server.

First off, we have to make a choice on the preference of which distribution we want to use. I love Debian based distributions, and have recently set up a number of Debian based servers for family friends. As Ubuntu is Debian based, and seems to trend well, i am going to stick with Ubuntu.

Now we need to make a decision of which release to choose.

As I primarily and building an experimental server, to run software that is new and need the all the latest builds, I am going to go with 10.10.

Next, you will need to know what hardware you have. Ideally you should choose AMD64. This version uses a 64bit address system and is far more extensible. Its a little bit better for some processes and not quite as fast for others. If you have older hardware, you may have to use the i386 type. It uses a 32bit address system and is perfectly fine for the home sever.

Always go with the AMD64 version. 64bit programming and process is the way of the future. If you are setting up the server on an old computer running a 32bit only CPU such as a Pentium 3 or 4, you will need to use the i386. The 64bit architecture also allows for much more memory, up to 64GB in the Ubuntu kernel (may be different for server edition), while the 32bit architecture only allows 4GB of memory (strictly speaking you can install software to support more).

You also need to choose which system you creating. This is easy now, where creating a server so we will need the server edition. Below is a description of the different system types for later if you need to know the differences

  • server
  • desktop
  • netbook
  • alternate

Server edition has the main difference to all others of a different kernel I/O handler and no GUI by default. despite this you can still install a GUI with apt-get install gnome-meta or KDE-meta packages

Desktop edition is the standard Ubuntu that comes with all the bells and whistles that makes an operating system useful to the primary end users. I has a GUI (Gnome of KDE depending on your choice) and standard applications and accessories.

Netbook edition is a slim and trim version of the desktop edition. As of Ubuntu 10.10 it uses a different graphical rendering program to display the on screen information and has a different layout.

Alternate edition is the same as the desktop edition, however it comes without the live (demo) functionality. This provides a much greater control over the set-up procedure but as a restore disk is more limiting.

My computer is very old. It runs a Pentium 3 and only supports 32bit architecture (I also only have 2GB RAM) so I will be using the Ubuntu below.

ubuntu-10.10-i386-server.iso

This is the version that I will be using throughout the series of setting up a home server.

%d bloggers like this: