Light on Dark -:- User Guides

Install the LAMP Server

Right, here we are. We have a server, whether it be an AWS instance, a virtual server on a machine somewhere, or a physical box sat in the corner, the following instructions will apply equally. We have installed a version of Ubuntu – the images are off version 11.10 (Obscure Ocelot – or something like that), but the instruction should work for anything from Karmic Koala onwards.

Login to your server using SSH. If you have a local server, you can also use an attached monitor,it should look exactly the same.

The first time you use the sudo command, you will be asked for your password – unless you are logged in as the Ubuntu user which is set up to not require a password. The password to use is the same one who used to login initially, it is not the root user password or anything like that. sudo remembers the password for 15 minutes, so you may need to enter it again later on.


Ensure your server has all the latest security updates, by running the following two commands. Answer yes to any prompts which it shows.

sudo apt-get update

sudo apt-get dist-upgrade

There is a bug in some versions of Ubuntu which generates spurious e-mails – run the following to ensure this is not an issue.

sudo dpkg-reconfigure popularity-contest

popularity contest survey

You may answer yes or no to this, as you prefer.


Now start installing the LAMP server and other required packages. These installs will generally ask you to confirm that you want the packages installing, with the default being yes; you can just hit the enter key when these pop-up.

This list is based on the ResourceSpace wiki (  Opens in new window), modified from personal experience.

There is no significance in the order these are installed or the way they are split across multiple lines- you could put each one on a separate line if you want. apt-get install is the bit that actually does the work, and anything after that is the name of the package being installed.

We will start with some basic operating system components – it may come up to say these are already installed, don't worry about that

sudo apt-get install nano cron wget

Next, we install the A, M and P parts of our LAMP server

sudo apt-get install apache2 mysql-server php5 php5-mysql

We need to set a root password for MySQL so we can login to it later


Enter the password for the MySQL root user, and remember it as we will need it later. The MySQL root user is a potential security threat, so make this a strong password unless you intend disabling the root user as described later.

Next, we install subversion and the mail server (postfix)

sudo apt-get install subversion postfix

set up postfix as an internet site, and give it a host name – we will tweak it later.

Finally, we install the graphics and file handling software which is needed by ResourceSpace.

sudo apt-get install imagemagick php5-gd ghostscript antiword xpdf ffmpeg libimage-exiftool-perl

You should now have all the packages you need to run ResourceSpace, but there is a little bit of setting up to do first.

Set up PHP

We need to set up PHP to allow larger file uploads, as the default is very small. The 200 MB limit set here is adequate for most images and sound files, if you wish to upload larger movies you will need to use an uploader such as the Java uploader which will break up the file into smaller chunks.

These settings are based on the ResourceSpace wiki (  Opens in new window), modified for current standards and from experience.

If you are more familiar with Vim or gedit, please use them, personally I prefer Nano.

sudo nano /etc/php5/apache2/php.ini

find (ctrl-w) and set:

  • memory_limit = 200M
  • post_max_size = 200M
  • upload_max_filesize = 200M
  • max_file_uploads = 50
  • display_errors = on

Ctrl-x and save the file

Stop Directory Browsing

The default installation of Apache allows directory browsing, which means that any directory which does not have an index or default page will show a listing of all the files in the directory. This is a major security risk, for example if we install ResourceSpace and then go to the include folder, we can see the config file which has the MySQL password in it:
directory browsing

there are several ways to fix this, but the easiest - if you are going to install it - is to use WebMin, click here for instructions.

If you do not plan on installing WebMin, you can make the change through SSH:

sudo nano /etc/apache2/httpd.conf

Add the following and then save httpd.conf:

<Directory /var/www/>
Options -Indexes
AllowOverride All
Order allow,deny
Allow from all

You may see other ways of doing this in other documentation, as I say there are a lot of ways of doing it.


Comments starting with '#' are deprecated

If you get an error message at any time saying 'Comments starting with '#' are deprecated', it means you are not using the latest version of whatever file it mentions. This can be a problem if you are running on Lucid, as some library '.ini' files were not upgraded to match PHP5.3

An example of this is if you try to run static_sync from the command line:

php /var/www/RSitC/RS/pages/tools/staticsync.php

This returns the error:
    PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0

If we look in the file

sudo nano /etc/php5/cli/conf.d/mcrypt.ini

we see the first line says

# configuration for php MCrypt module

You can delete this line altogether, or simply replace the # with a ; (semi colon)

; configuration for php MCrypt module

and save it.

Test it

We now have a LAMP server set up, so let's try it. Firstly we will restart Apache to ensure it has picked up all our changes. We will use of the service command, which is a modern replacement for the old techniques.

sudo service apache2 restart

if you are working on a very old version of Linux, you may need to use 'sudo /etc/init.d/apache2 restart' instead, or you could always upgrade to the latest version.

Now fire up your browser and point it at the IP address or DNS setting you used earlier, and you should see something like this:

it works

What next?

We now have a standard LAMP server running, ready to install whatever application you desire. We know that everything so far works, by the simple fact that you are sat reading this – this page is coming from the server we have just built. Everything you see on (including the PHP BB forum) is running on a micro instance in the AWS cloud.

once again, if you are doing a public access server, there are a number of security issues you may wish to address, for example changing the permissions for the root user in MySQL. You will find this easier if you first install PHPMyAdmin which gives you a graphical interface for managing MySQL.

If you are not familiar with the intricacies of the Linux command line you may also wish to install WebMin to give you a browser-based, GUI interface to your server.

And finally, you might wish to set up and test the mail server (postfix) to ensure this is working correctly, and set up aliases so error messages get correctly delivered.

OK, we have spent quite a while setting up our LAMP server, ready to install ResourceSpace (or any other app). We now want to save our work, just in case anything goes wrong. We do this by re-imaging - making a new image of our server.

Once we have our image, it's time to install ResourceSpace.

just making sure we have a vertical scroll bar, otherwise it jitters sideways.