Sailing Boat Logo

LAMP on Ubuntu Linux (Desktop Version)

Disclaimer: This is a log of how I set up my machine. I am not a security expert or even a Linux expert. It might be OK for non mission critical use.

Install Ubuntu Linux

Carry out a default installation of Ubuntu Desktop Edition (Download). This allows you to use desktop applications as well as running the machine as a LAMP server. The LAMP server components need to be added as described below ...

A live internet connection is needed.
The commands are typed into a terminal session that is started like this ...

    Applications - Accessories - Terminal


Install Apache2

    sudo apt-get install apache2


Determine the IP address of the server

    ifconfig

My LAN IP address was 192.168.1.67

Point a web browser at this address.
You should see some sort of content.
In my case it was a folder contents listing of apache2-default/


Edit the default website configuration file.

I used VI. You might prefer a different editor.

    sudo vi /etc/apache2/sites-available/default

Alter DocumentRoot to point to your own home directory, something like this ...

    DocumentRoot /home/nbauers/web

Instead of using /home/nbauers/web, use a folder that matches your own user details and preferences.


Edit apache2.conf.

I used VI. You might prefer a different editor.

    sudo vi /etc/apache2/apache2.conf

Alter the DirectoryIndex line to include index.php and possibly index.htm

    DirectoryIndex index.php index.htm index.html ...

Restart Apache2

    sudo /etc/init.d/apache2 restart

Ignore the possible error message about fully qualified domain names.


Create a simple web page in /home/nbauers/web

Create this file in your own directory and not /home/nbauers/web

My test file contained the single word "hello" without any <html> tags.

Save the file as index.html

Refresh wour browser window. You should see your new home page.


Install PHP5

A live internet connection is needed ...

    sudo apt-get install php5-common php5 libappache2-mod-php5

To test PHP, rename your home page from index.html to index.php

    mv index.html index.php

Edit index.php and add PHP code such as ...

    <?php
      echo "PHP is running.";
    ?>

Refresh your browser window. You should see the PHP output.


Add the PHP GD library to allow web based image processing.

    sudo apt-get install php5-gd

Restart Apache2

    sudo /etc/init.d/apache2 restart


Install MySQL

A live internet connection is needed ...

    sudo apt-get install mysql-server mysql-client

    sudo apt-get install php5-mysql

MySQL should start up automatically. It can be re-started as follows ...

    sudo /etc/init.d/mysql restart

IMPORTANT for security: Set the MySQL root passwords as follows ...

    sudo mysqladmin -u root password newrootmysqlpassword

    sudo mysqladmin -u root -h localhost -p password newrootmysqlpassword


Configure PHP to work with MySQL.

    sudo apt-get install php5-mysql php5-mysqli


Install and Configure vsftpd

This allows you to use FTP to upload your website files.

    sudo apt-get install vsftpd

The server should start automatically.

Configure vsftpd by editing vsftpd.conf. I used VI. You might prefer a different editor.

    sudo vi /etc/vsftpd.conf

Verify and if necessary, add/alter the following lines so they look like this ...

    anonymous_enable=NO
    local_enable=YES
    write_enable=YES
    file_open_mode=0705
    local_umask=0022

Restart vsftpd

    sudo /etc/init.d/vsftpd restart

NOTE: This documented method of restarting vsftpd did not seem to pick up the changes in the conf file so I ended up restarting the entire computer.


Install SSH to allow remote administration

    sudo apt-get install ssh


PuTTY

Download PuTTY. This runs on Windows machines and allows you to log into your Linux box remotely. It uses the SSH protocol. This is more secure than telnet. It works well and has saved me hours of running backwards and forwards.

© 2006 - 2007 - C Neil Bauers  nbauers at samphire dot demon dot co dot uk

 Valid XHTML 1.0 Transitional