Now that we have Ubuntu set up on our computer, we want to get our LAMP Server set up. LAMP stands for Linux Apache MySQL Php. We want this because it allows us to write and test web code on a localhost.

Step 1: Install Apache

Apache is a widely-used web server that is open-source and free. This is the "web server" portion of LAMP, but we still have to install the other portions of LAMP as well.

To install Apache, open a terminal (ctr+alt+t) and enter the command

sudo apt-get install apache2

Each install won't take very long on a reasonable internet connection. (Less than 5 minutes).

Step 2: Install MySQL

After Apache is installed, we want to install MySQL. Like Apache, MySQL is an open-source product, it is used as an "open-source relational data-base management system". MySQL is used as the Database portion of LAMP.

MySQL installation is similar to Apache, in the terminal enter the command

sudo apt-get install mysql-server

After installation, a purple screen called "package installation" will pop up, you can chooose a password, or leave it blank. This happens multiple times during installation, so don't worry when it pops up again.

Step 3: Install PHP

Now we need to install the "P" of LAMP, or PHP. Other "P"s can include Perl or Python, but for our case, we are going to use PHP. PHP is a server-side scripting langauge for web-development, it can also be used for other types of programming if you prefer PHP over other programming languages.

Just like the other two installations, we go into a terminal to install. We are going to enter the command

sudo apt-get install php5 libapache2-mod-php5

to install PHP.

Step 4: Make /var/www Writable

Now that we have all our libraries downloaded, we need to make the "www" folder writable.

This will take three seperate commands in the terminal, but none are extremely complicated.

  1. "sudo adduser www-data"
  2. "sudo chown -R www-data:www-data /var/www"
  3. "sudo chmod -R g+rw /var/www"

After you enter these, save your work and log-out, log back in and go to the "www" folder:

  1. Open up files.
  2. Click "Computer" in the devices section.
  3. Open up "var" (folders are sorted alphabetically, so should be near the end).
  4. Open "www".
  5. Right click inside "www" section, and the options "New folder" and "New Document" should be available!

Step 5: MySQL Secure Installation

Before we can finish up everything we need to run the MySQL Secure installation.

In the terminal enter:

sudo mysql_secure_installation

Installation will ask sever questions, first we must enter the password (if you didn't enter a password just hit enter). The following are what options I chose, but of course you can pick others.

  1. Set root password? (No)
  2. Remove anonymous users? (Yes)
  3. Disallow root login remotely? (Yes)
  4. Remove test database and access to it? (Yes)
  5. Reload privilege tables now? (Yes)

After installation has finished you can run the commands:

sudo service mysql start

sudo service mysql stop

to start and stop MySQL.

Step 6: Configuration and Status

If you want to check the configuration of PHP, MySQL, and Apache: you can go back to the Computer and etc file.

Each are in different folders etc, here are the three config files (and their locations)

  1. etc/apache2/apache2.config (Apache)
  2. etc/mysql/my.cnf (MySQL)
  3. etc/php5/apache2/php.ini

If you want to check the status of the "services", which includes more than just the items we've been working on, enter the command:

service --status-all

Step 7: Finishing Up

Now for us to test to make sure everything installed correctly, open up your favorite web-browser and type

"localhost" as the address. A page titled "Apache 2 Ubuntu Default" should load.

We want to check one more thing before we're finished.

  1. Go back to the var/www folder in Computer.
  2. Create a new file (by right-clicking) inside of the html folder.
  3. Name it info.php
  4. In info.php, copy the script:



Go back to your browser and enter localhost/info.php, a page containing info about the current PHP version should come up!

You can use tasksel to install everything, good instructable though!<br><br>Simply &quot;Sudo tasksel&quot; then select LAMP Server

About This Instructable




More by joshwoldstad:Uploading Firmware to your chipKIT boards Fixing your Car keys Using the PmodCON3 with chipKIT  products 
Add instructable to: