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.

August 29, 2010

Huawei E1550 in Ubuntu 10.04.1

Filed under: Ubuntu — Tags: , — Dougie @ 2:27 pm

Judging by my server logs, there are lots of people trying to use the Huawei E1550 with Ubuntu. I posted a howto around this time last year but have been getting a lot of mail on it recently so thought I’d look at it again. I was going to mention it in the system help, under troubleshooting but can’t remember if I pushed a patch or not.

Mode-switching – method one

Thanks to OdyX (who maintains usb-modeswitch) this is the simplest method.

Open a terminal (Applications->Accessories->Terminal) and type:

sudo apt-get install usb-modeswitch usb-modeswitch-data

Mode-switching – method two

On inserting the device, if you open a terminal (Applications->Accessories->Terminal) and type “dmesg” you’ll see something like this:

The device has a small amount of storage space and identifies itself (on Windows) as a mass storage device, installs the driver and away you go. The problem is Ubuntu does what it is told to, it thinks its a mass storage device. The switch is never made in software because the software isn’t for Linux. We need to manually switch it using a little program that has been installed by default for a while now – “modem-modeswitch”. You need to pass it some parameters but we want the system to do this automatically when we insert the device – so we will configure a udev rule instead.

Open a new file to store the rule by typing “gksu gedit /etc/udev/rules.d/15-huawei-e1550.rules” and paste in the following code:

SUBSYSTEM=="usb",SYSFS{idProduct}=="1446",SYSFS{idVendor}=="12d1",RUN+="/lib/udev/modem-modeswitch --vendor 0x12d1 --product 0x1446 --type option-zerocd"

Save the file and close the editor. Remove and re-insert the device. You should notice that service providers icon has popped up on the desktop – don’t worry about it as it is just the storage part of the device being recognised.

Configuring the connection

If you now click on the network-manager icon in the notification area, you’ll see a new option, “New Mobile Broadband (GSM) connection”

Click it and on the splash screen click “Forward” and choose your country and operator. Mine is 3UK so I’ll pick “Britain (UK)”, “3″ and importantly from the next screen choose “Handsets”. Obviously this will require the correct information, so if your network is not listed and you cannot obtain the necessary values the please contact your provider. Click “Apply” and you should see the connection appear.

August 22, 2010

No shit Facebook

Filed under: Rant — Dougie @ 12:42 pm

A screen grab from Facebook’s recommendations:

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 16, 2010

Fleshing out an idea

Filed under: Ubuntu — Tags: , , — Dougie @ 10:01 pm

Yesterday, I posted that perhaps we should encourage new users to spend more time in the live environment before they install. I suggested that we do this by means of a welcome application.

Generally, people seemed to like the idea of a welcome application – something to highlight Ubuntu’s abilities and to guide through common issues.

Here’s some mock ups that might show more of what I meant.

An introductory video is running [1] along with some short text explaining the application’s purpose [2]. Common tasks are listed [3]. What’s missing from this is two things – a close button and an install button. I’m not sure how to work this because I am trying to encourage it being run – I think a little install tab in the top right along with a small close button might work. I want to encourage not irritate.

The user is interested in getting online and has clicked on a link to get here. The application’s checked for available connections. In this case, there is a wireless connection available, so the context sensitive hyperlink [1] has linked a video/screencast [3] showing the user how to connect. With the failure to detect a wired connection, the context sensitive hyperlink links to a troubleshooting page. Successful connection has resulted in a notification [2] and triggered the “what now” box, guiding the user to what is now available.

I can see a number of issues:

  • Videos and screen-casts have been requested from the doc-team for inclusion in the past but translation and localisation is an issue. I don’t spend a lot of time with screen-cast technology so I don’t know how easy it is to localize. Recording a new video for each release might be relatively straightforward if the tool chain is correctly configured.
  • The feedback mechanism that would permit context sensitive hyper-links. I would like it to be as automated as possible.
  • What to check, what to suggest and how to decide what tasks are most important for inclusion.
  • Size – the Live CD is limited on space, video is large – how possible is this idea?

Of these, I think the size issue is the greatest. It might not be possible at all to have video or screen-casts but it should be possible to have room for images and text. It would also allow easier localisation.

Still – it’s just an idea. Oh and thanks to Pencil – rather impressive OSS mock up software.

Older Posts »

Powered by WordPress