Lynx Blog

September 2, 2010

Install web applications locally on Ubuntu

Filed under: Computing,Ubuntu — Tags: , , — Dougie @ 11:46 am

I was talking with someone yesterday who is hacking a WordPress theme together. If you work with web sites, being able to run a site locally allows testing, experimentation, developing new themes and even just checking that a software update isn’t going to break your site. You might want to keep a web application on a local network and away from the Internet – such as StatusNet, a Wiki or a project management application. All we need is to install a LAMP stack – Linux Apache MySQL and PHP. We’ve already got the “L”!

Synaptic (System->Administration->Synaptic Package Manager) lets you install common groups of packages (Edit->Mark packages by task…) in this case a LAMP server. You can do the same from a command line using “sudo tasksel install lamp“. Once the components are installed, you’ll be asked for a root password – this is used by MySQL and is not the system’s root password.

The default web root is /var/www – if you check it now there is an index.html. Open a browser and enter the system’s address (usually http://localhost/), you’ll be greeted with the contents of that file so we know the system is working. So how do we get our own files up?

Apache uses virtual hosts – we can have multiple sites on the same server. Each site is defined by a configuration file in /etc/apache2/sites-available. If you look there now, you’ll see the default site, we can use this as a template for a new site:

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/wordpress
gksu gedit /etc/apache2/sites-available/wordpress

You need to change DocumentRoot and Directory to point to the folder your site is going to be in. So lets say you want to use a folder called “wordpress” in your home folder, change “DocumentRoot /var/www” to “DocumentRoot /home/USERNAME/wordpress” and “<Directory /var/www/>” to “<Directory /home/USERNAME/wordpress/>“. We can also give an alias, so we access individual sites by name, to do this add the following “ServerAlias wordpress“.

You can then add “wordpress” to /etc/hosts (change the line that reads 127.0.0.1 localhost to 127.0.0.1 localhost wordpress) and use the address “http://wordpress” to access your site.

Ubuntu has a utility to add the site to Apache which will also need restarted:

a2ensite wordpress; sudo /etc/init.d/apache2 reload

If you’re only going to be using one site it would be easier to use the default site (which is already configured). Ubuntu adds the first user to the www-data group, so you can either change the ownership of /var/www or add a sub-folder with either the user’s ownership or membership of www-data (note you’ll need to change the group permission too). I’m adding a folder I own:

sudo mkdir /var/www/dougie;
sudo chown dougie:dougie /var/www/dougie

This can be accessed by http://localhost/dougie. I’ve seen a few forum posts saying that people have issues with folder permissions and there are some misconceptions. I’ve even seen it suggested to edit everything with “sudo nautilus”!

Now with the letter “A” out of the way we can deal with the “M”. Most web applications need at least one database. Remember that MySQL password?

mysql -u root -p

A good example is installing WordPress. Download and extract the contents to your web folder (in my case /var/www/dougie). Create a new database called “wordpress“, with a user called “wordpress” and a password of “wordpress” by entering each command at the prompt:

create database wordpress;
grant usage on wordpress.* to wordpress@localhost identified by 'wordpress';
grant all privileges on wordpress.* to wordpress@localhost;

Type “\q” to exit then open a browser and go to your site, for me that’s http://localhost/dougie.

So lastly we get on to the “P” – PHP. Apache will recognise and run PHP, however be aware of a caveat I’ve noticed in Ubuntu. If you try to use your system hostname instead of localhost in Firefox, it will try to download rather than run PHP files. I believe this is due to the system hostname resolving to 127.0.1.1, a solution to Debian bug #316099.

PHP applications often have their own installation scripts, which WordPress does. Enter the database details we just created on the WordPress install screen:

Once the rest of the screens are complete, you’ll have WordPress installed.

So to recap, all we need to do to add an application is create a virtual host so Apache can serve it up; create a database for it to store data; and configure the application – often via a browser interface. Now you can hack away at those WordPress themes to your heart’s content.

More information is available from the Ubuntu Server Guide.

June 17, 2010

NM problems on Linpus Linux Lite

Filed under: Computing — Tags: , , — Dougie @ 2:18 pm

I haven’t touched this distribution in at least a year but someone asked me to look at one earlier today. The symptom – “it wont connect to the Internet – there’s not even an icon in the system tray”.

Linpus is pretty restrictive, I opened Nautilus by clicking “Documents” on the home screen, then a terminal using “File->Terminal”. Running nm-applet from the command line reveals a segfault. Running “sudo nm-applet” doesn’t cause a segfault and allows a connection, obviously lacking access to the keyring. Once connected to a network, running the update application shows a new version of nm-applet available. I ran the updates, rebooted and the issue is solved. It must have been broken in the last set of updates, ran before the user lost nm-applet.

Hope this helps someone. It does illustrate the downside of obfuscation – in this case the user has no feedback as to why there is no network connection.

June 2, 2010

Advocacy by not advocating

Filed under: Computing,Ubuntu — Tags: , , , — Dougie @ 12:31 pm

We have Ubuntu installed on two of the machines at home and recently, after losing a Windows restore disc, I suggested installing Ubuntu 10.04 on her Dell 1545 after my suggestion.

As installations go, it was relatively painless – certainly better than reinstalling Windows. Don’t get me wrong, Dell is better than most in this respect as they gave us OEM install discs for Windows Vista, bundled software and the drivers.  As strait forward as this is with Dell’s resource CD (it mostly tells you what you need), it doesn’t know any more than what model you own. This is problematic with the wireless card for example as there are two revision states and the drivers are incompatible with each other – one crashes Windows.

(more…)

May 28, 2010

Aspire One flat battery

Filed under: Computing — Tags: — Dougie @ 9:06 pm

I have been away for nearly five months. In that time my Aspire One’s battery has, unsurprisingly, gone totally flat. However it wont charge. This device’s power supply seems to have issues, it has gone through more fuses than any device I’ve had. The battery life is not really good enough for a netbook (mind you my Samsung NC-10 doesn’t get much over six hours after the six months I’ve owned it). The weirdest thing is that it will not turn on when the battery is connected – on mains power with no battery it boots fine.

So I stuck the battery in after it was booted and it charges… I’m at a loss to explain this. I’d have thought charging was carried out at hardware level.

January 2, 2010

Blogging platforms

Filed under: Computing,Rant,Ubuntu — Tags: , , , , — Dougie @ 1:54 am

Has anyone else noticed a large amount of ping backs to link farms from Planet Ubuntu feeds over the last few days? I’m getting a fair few. I’d give an example but if I link to a site that takes my posts from a syndicated site and creates posts that are syndicated on other sites I might create some sort of perpetual motion blog post and consume the Internet (it might seem far fetched but what if Robert Morris had stopped to think).

I find these objectionable though – they appear to be WordPress and I guess are using a plugin to pull feeds in and publish as articles. They’re not as bad as flat out plagiarism – which I’ve experienced. Mind you even that isn’t the worst, I once wrote a howto which was CC licensed and I realised it had been ripped off when someone posted a comment on it suggesting (quite strongly) that I had taken it from the thief!

So it occurs to me that maybe this is a WordPress thing. Then again maybe not. Like so many of us I get stuck in my ways and WordPress is like a pair of comfy shoes. Maybe I should try a new platform, so I wondered what was popular out there in Ubuntu-land.

I’ve tried Drupal (I don’t like it, sorry Emma), Serendipity and Pixie (I quite liked that but baulked at the theming system). Mind you I also have quite a lot of time to myself over the next four months, maybe I should roll my own, I’ve hacked around in PHP but have never developed a large project using it.

So let me know, suggestions on a postcard. Maybe just a comment here will suffice.

Older Posts »

Powered by WordPress