Linux as home desktop, why not?

Linux is a free stable and resourcefull operating system yet to prove it’s full potential as a desktop operating system. While the greater part of the market is still Windows based the introduction of the UMPC (Ultra Mobile PC) have turned things upside down for Microsoft. Instead of buying very expensive hardware and install Vista many choose to buy less hardware and get either a Linux distribution or (even worse?) a several years old Windows XP system.  Microsoft was not prepared for this turn of events and have been forced to extend the lifespan of their XP-series which they where planning to phase out in favour of Vista.

This change in consumer behaviour to “not buy the best” anymore, have favoured Linux who with their versatile distributions have a stable modern operating system for just about any new or old hardware out there. My five year old laptop which where being exhausted by running Windows XP in combination with a virus tool runs perfectly smooth with the Ubuntu distribution (well I could theoritically run XP without a virus tool but seeing I travel alot with it that would just be beging for it to crash with all the unsecure networks I connect to).

With the UMPC Linux have gained a small part of the desktop market, but what is holding it back to take an even larger part? Is it the hardware support? Well granted some hardware vendors only supply drivers for Windows systems, but most hardware have at least decent support in Linux. Is it Internet related software? Hardly, Firefox is arguably better than the current version of Internet Explorer (granted Firefox is available on both systems) and also e-mail clients like Thunderbird are just as easy as Outlook Express to setup. Are the office tools sub standard? Open Office and GIMP make a very good competition for their commercial counterparts Microsoft Office and Adobe Photoshop, so except for prior experience in one system there really is no major difference for the home desktop user there. Is it the ease of use? Again, trying out Vista will be just as confusing for a XP user as it would be switching to Ubuntu. Most things have changed places anyway. Also the update feature in Ubuntu is much better than Windows update in my opinion. The ability to upgrade all installed applications through a common interface is very easy to handle for an inexperienced user.

There is one single left over reason that I see quoted time and time again: “I use Windows XP becuase I want to play games”.

Is there any major reason to hold back? Well… I have to say yes. There is one single left over reason that I see quoted time and time again: “I use Windows XP becuase I want to play games”. Almost no PC game whatsoever have Linux-support. There are, often technical, HOWTOs on how to get this or that game running under Linux but it usually involves pages of instructions. If we have everything else, surely games can’t make a major difference for a desktop operating system? Again, I’d have to say yes it does. Why? Simple, the kid in the family who usually is the computer wiz is the one who helps all his family and friends install their computers. If this kid runs XP back home to play computer games on he will install XP on all other machines, because this operating system he knows and can “support”. Furthermore if all else being equal, if there is one major drawback in a single area, whoever wins that will probably win the battle.

Windows XP have DirectX which is supported and used by I would dare say every game manufacturer for the PC market. Linux have no equivalent interface. Linux have “emulated” Windows and even tried to port games individually but the major all-supported interface is not there. Game companys can’t make a release for every distribution out there (since many are so different it would be required), but if a common interface for all distributions could be established that would increase the chances of Linux game releases.

In my opinion, this is one of the major reasons Linux is still held back as a desktop operating system. Far from the only reason, but a major one.

Perl on Apache2 / Ubuntu 8.04.1 JeOS

Perl acctually works “out of the box” in Apache 2 installed on Ubuntu 8.04 JeOS. I found much confusion on this subject while browsing the Internet so I thought I’d post a simple HOWTO to get the first script running.

First you need a Ubuntu 8.04.1 JeOS server with a LAMP installation, see my previous guide on how to make one.

The first thing that can be confusing is where to find the right configuration files for Apache, while not needed for this guide I thought I’d post the current version for this guide here. A good overview of all distributions / versions can be found over at the Apaches wiki.

Debian, Ubuntu (Apache 2):

ServerRoot              ::      /etc/apache2
DocumentRoot            ::      /var/www
Apache Config Files     ::      /etc/apache2/apache2.conf
                        ::      /etc/apache2/ports.conf
Default VHost Config    ::      /etc/apache2/sites-available/default, /etc/apache2/sites-enabled/000-default
Module Locations        ::      /etc/apache2/mods-available, /etc/apache2/mods-enabled
ErrorLog                ::      /var/log/apache2/error.log
AccessLog               ::      /var/log/apache2/access.log
cgi-bin                 ::      /usr/lib/cgi-bin
binaries (apachectl)    ::      /usr/sbin
start/stop              ::      /etc/init.d/apache2 (start|stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean)

Now as I said, Perl is allready working so we just have to find it in our system! As since in the chart above the cgi-bin is located in /usr/lib/cgi-bin. Here we want to put a Perl Hello World script.

sudo nano /usr/lib/cgi-bin/test.pl

In the script I type the following very standard Hello World script:

#!/usr/bin/perl -w
print “Content-type: text/plainnnHello World!n”

We need to make it executable so we chmod it:

sudo chmod 755 /usr/lib/cgi-bin/test.pl

To make sure it’s working a good tip is to try it at the command line first to check for any spelling errors (especially in the header, errors there will lead to a 500 internal server error response).

perl /usr/lib/cgi-bin/test.pl

If it runs and returns the content-type line, two new lines and a hello world then we’re set! Browse to the IP of the server, in my case it’s 192.168.0.16 so I enter:

http://192.168.0.16/cgi-bin/test.pl

Hello World!

Virtual Ubuntu 8.04 JeOS LAMP Server

I’ve found the perfect portable development environment for me! First of all I wanted a virtual environment in VMWare since I have access to that software at several locations. Secondly since I would be using it on laptops I wanted the virtual machine to use as little memory and disc space as possible.

Requirements for this tutorial:

First I create a new virtual hardware for the Ubuntu distribution. Standard options straight through except I choose to have a virtual harddrive split into 2 Gb files and only created when needed (to save space, since this is kind of one of the main points of JeOS). Next I choose the ISO-image of the downloaded JeOS distribution as an imported CD-ROM drive for the virtual machine and boot it up.

Throughout the installation I just make the default choices (with only a few exceptions for country and keyboard layout). The installation is fast and the system is up and running, but no graphics of course! Just a waste on a server machine anyway. The first thing I want is the comfort of continueing from my main computer and therefore I install OpenSSH server.

sudo apt-get install openssh-server

After the installation I can freely connect from any other machine on my network which in my case is much more confortable than sitting peeking into a virtual machine on my serverbox.

To logon remotely I need to know the current IP-adress of the JeOS virutal system, to easily get it I write:

ifconfig | grep -w inet

This will show me the current available IP-adresses on the machine, one of them is the loopback (127.0.0.1) and if there are others (there should be only one with the current installation) those are the public IP-addresses. In my case it’s 192.168.0.16. If you are running IPv6 change “inet” to “inet6” to get the public IPv6 IP address.

After I logon (in my case using PuTTY from a Windows machine) I start the process of making it a LAMP server (Linux Apache MySQL PHP5). To make things easy Ubuntu provides a command called “tasksel” that packages an installation togheter into one command:

sudo tasksel install lamp-server

This is suprisingly easy, just wait and the only thing the installation asked me about was what root password I wanted for MySQL.

I use nano to edit text files, you might use something else, either way I need to install it since it’s not included in the standard JeOS distribution.

sudo apt-get install nano

Now we need to make MySQL accessible from remote computers (default setting is to only allow localhost). To do this we need to edit the file /etc/mysql/my.cnf

sudo nano /etc/mysql/my.cnf

Please not that this can be considred unsafe since it exposes the MySQL interface to the whole network! This is only done since I want a development machine that I need to administrate remotely (might be from the same computer but with the server running virtually in the background). To change the bind address you have several options, but first off all find this line within my.cnf:

bind-address = localhost

Instead of localhost you can enter the IP you want it to bind to, if you comment out the line MySQL will by default bind to you’re current IP (which is recommended if you have a dynamic IP-address).

Now we need to create a database and give remote access to it. We need to start MySQL on the command line, so we run:

mysql -u root -p

MySQL will now prompt for your password (the one you supplied earlier in the installation) and then you are in. First I create a new database, the purpose of which is to develop WWW-services so I aptly name it “www”.

create database www;

Next I want to grant myself remote access to this database so I run:

grant all privileges on *.* to ‘magnus’@’%’ identified by ‘passwordgoeshere’ with grant option;

Again, this is UNSAFE for production environment, the above command grants limitless access to the database to any host that identifies itself as me with my password. Consult the MySQL documentation for better limited access and also (if you know which host(s) you will need access from) change the wildcard to a specific IP-number.

I can now access and administrate the MySQL database using whichever tools one favours, I recommend the GUI tools from MySQL.

Another handy tool is phpmyadmin, with this php-based GUI you can administrate the MySQL database through the web browser:

sudo apt-get install phpmyadmin

After the installation simply point the web browser to the /phpmyadmin folder on the webserver of the virtual machine. For example if you’re virtual machine have the IP 192.168.0.50 then the address would be http://192.168.0.50/phpmyadmin

Done! You can now run the virtual server with Apache2, MySQL and PHP5 remotely from any computer in your network and administrate it through SSH. At the end of the installation my virtual machine used 720 Mb discspace which should be compared with the several gigabyte discspace used by a standard Ubuntu installation. Also with the absense of graphical interface the memory consumption is very low and the virtual machine can run on as low as 128 Mb of RAM if needed.

I can add as a bonus that when I later installed a SAMBA server and WordPress 2.6 on the virtual machine the size grew in total to just below 800 Mb and memory set at 256 Mb of RAM. This will have to be a topic for another post though.

Updated 2008-08-02
* added instruction of how to obtain the IP-address of the JeOS virtual machine.
* fixed typo in grant statement