This guide will show you (yes show, it has pictures) how to configure a standard Ubuntu 7.10 install to act as a LLMP (Linux Lighttpd MySQL PHP) server. I will also show you how to install the Cacti statistics and server status software package.

Right away, open up a terminal (Applications > Accessories > Terminal) as everything we do will be in the terminal

First, make sure you have set the password to your root account. If you have not, do:

$ sudo passwd root

You will be asked to type in a root password, so come up with a password for the ‘root’ account and press enter. Confirm the password, press enter again, and your set.

Note: I know some people don’t like activating the root account, and thats fine. You can instead place a sudo in-front of every command if you want to, or do a sudo su it doesn’t matter to me.

Now that your root password is set, do:

$ su -
Password

And you should be at a prompt that looks something like this (note the # sign):

Now we will want to update our apt-get packages. Apt-get is the Ubuntu/Debian Package Delivery System for installing new packages from remote servers onto your system. Run:

# apt-get update

And you should see output similar to below:

Installing the Lighttpd Web Server

Your output may be more elaborate if you have never run apt-get update before but it will be relatively the same. Now that we are all up to date, we will install the Lighttpd web server. Follow the steps (what I typed is displayed after the # sign, remember that):

Press Y at the prompt below:

Once it is done installing you should see something similar to (note the Starting web server lighttpd [ OK ]):

At this point the web server is installed, and working. Going to a web browser and going to the URL: http://localhost/ SHOULD give you this page:

If you do not see a page like the one above, and get something like this, you encountered a problem:

Now that we have Lighttpd working, here are a few commands to control it:

The first command: killall lighttpd will kill the server (stop lighttpd from running). Thus, when you go to localhost you get the server problem page. To start the server up again you use lighttpd -f /etc/lighttpd/lighttpd.conf which forces the server to start using the config file found in /etc/lighttpd. It really is that easy.

Installing PHP

PHP is what almost every server has running. PHP is an engine that processes PHP code into browser-readable content. Because PHP is so powerful, we will be installing it onto our server. Lets get started. Perhaps you can guess what the command is, if not:

Then:

And:

And:

Now we have PHP installed, with CGI mode, MySQL, and CLI supported. Now we need to enable fastcgi mode in lighttpd:

And restart lighttpd (like the direction in the terminal says) using # /etc/init.d/lighttpd force-reload and we should see:

(Notice the 2 [ OK ]‘s, thats good). Now we can test and make sure PHP is working. Lets move into the www folder where our webpages will be stored:

# cd /var/www

And type: # pico test.php and you should get a blank editor window. Fill it in like shown below:

Then press Control O to save it and Control X to exit. Now go to your web browser and go to the URL http://localhost/test.php and you should see something similar to:

If you see something similar to the image above, you are doing great so far! The wording will be different but it should in general look similar. Congrats, you now have PHP and Lighttpd running together. The final step is getting MySQL going.

Installing MySQL

Much like how we installed PHP and Lighttpd, do:
# apt-get install mysql-server-5.0

It is going to download ~33MB of data so be patient as apt-get works its magic. You are going to want to setup a root password as well. After it is complete, you should see something similar to:

Note that if you were never prompted to set your mysql password you can use the command (if you have set the password, skip this set):

# sudo mysqladmin -u root password "YourPasswordGoesHere"

To check your mysql server, type (# mysql -u root -p):

If you get something like the image above, it works. \q will exit mysql. Now we will make a new database called trial:

To make sure the database was created we can try to delete it:

So we are able to create and delete databases! Yay. Now lets install phpmyadmin so we can easily manage our databases. Type:

# apt-get install phpmyadmin

You will get a screen like below, just go to OK, do not check any boxes:

Once it is done installing, we will need to move it to /var/www:

Now restart lighttpd (the commands are above), and in your browser try to go to http://localhost/phpmyadmin The output should look similar to the one below:

Wow, we have accomplished a lot so far. MySQL, PHP, and Lighttpd all working with phpmyadmin to manage databases. Whats left? Well, nothing really, However if you want to install cacti (server status and statistics) follow the steps below.

Installing Cacti

Cacti is a complete network graphing solution designed to harness the power of RRDTool’s data storage and graphing functionality. Cacti provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box. All of this is wrapped in an intuitive, easy to use interface that makes sense for LAN-sized installations up to complex networks with hundreds of devices
.

Start with the following command:

When you reach the screen below, select ‘None’:

At the screen below select ‘Yes’:

At the screen below type in your MySQL root password (which you set above) and select ‘Ok’:

At the screen below, enter the same password as your MySQL root password and select ‘Ok’:

Then confirm the password:

Now we need to link the cacti folder to our web directory folder:

We can now go to http://localhost/cacti/site/ in our web browser and you should see a screen like below:

Follow the promps and you will get to the login screen. The username and password are both admin

Once you are logged in, you can manage the graphs. I will not go in depth about that as you can read the manual.

We are now done! Congrats, you have a WORKING Linux server running Lighttpd, MySQL 5, PHP 5 with phpmyadmin and Cacti installed! It really is that simple, all of that can be completed in under 30 minutes!

If you enjoy this tutorial, please say thank you and do not rip it off, I spent quite a bit of time going through the steps, checking my work, and making sure it was easy to follow by taking many screenshots and would like to receive a little credit. Enjoy the tutorial and the new server!