Today I'm going to show you how to set up a popular open source software stack for building websites and web applications. This stack is called LAMP which is short for:
- Linux - the operating system
- Apache - the web server
- MySQL - the relational database
- PHP - the scripting language for dynamic websites
Although there are many possible stack combinations, LAMP is probably the most popular and is well tried and tested. It is also a very good choice if you're doing Drupal development.
For the GNU/Linux OS, I've chosen Ubuntu 14.04 LTS. Ubuntu is a great choice as a desktop OS as it has a user-friendly interface, great support and everything pretty much works out of the box. I won't go into the details of how to set up Ubuntu as there are many tutorials already out there on this. The only advice I'd give is to make sure the system has sufficient computing resources, so setting it up in something like Virtualbox with limited memory isn't recommended. Also, if you wish to set up Linux as a dual boot (a good way to go), I'd recommend this particular structure explained by Matthew Moore Dual Boot the non-traditional way.
The first thing we are going to do is install Tasksel, a Ubuntu/Debian tool for installing multiple related packages. This will allow us to install the entire LAMP stack in one simple process.
- Open a terminal session from the Ubuntu desktop (ctrl-alt-t).
- Type in
sudo apt-get install taskseland follow the prompts.
Once Tasksel is installed, we then install the LAMP stack.
- type in
sudo taskselto start the Tasksel application.
- Use the arrow key to navigate down to "LAMP server", hit the spacebar to select this option and then Enter to start the installation process.
During the install process you will be prompted to create a password for the mySQL root user. You should do so (and don't forget to record it for future reference).
We can do a quick check that the Apache webserver is working by opening
a browser (Firefox is pre-installed with Ubuntu) and
localhost into the address bar and pressing Enter. This should
open up the Apache2 Ubuntu Default Page.
It is also very useful to look at the configuration of the stack by doing the following:
- Navigate to the default website's location by entering the following command:
- Create a new file with default text editor by entering the following command:
sudo nano phpinfo.php
- Type the following into the newly created file:
<?php phpinfo(); ?>
- Save the file by pressing ctrl-x, then Y and Enter.
- Open the browser, type
localhost/phpinfo.phpinto the address bar and press Enter. This should display all the php configuration information.
The final step in setting up the basic stack is to install phpMyAdmin.
This is a handy GUI for managing your MySQL databases. To install, type
in the following command:
sudo apt-get install phpmyadmin
There will be a number of prompts throughout the installation process. The first one is as follows:
Check that Yes is selected and press Enter. You will then be prompted for a password and to confirm it (and don't forget to record it for future reference).
Next you should be prompted for the web server you want configured with phpMyAdmin.
You should select Apache2 by pressing the spacebar (note it won't be selected just because the red hightlight is focused on it. The asterisk must appear.) and press Enter.
Once installed you should open your browser and enter the following into
the address bar:
The following log in screen should appear:
Log in using the mySQL root user password you entered when installing the LAMP stack. This will get you into the main database management screen.
Congratulations, you've now completed the basic LAMP setup. Next we will look at setting up virtual hosts so you can set up and run multiple websites/domains on your machine.
Note: on the odd chance you run into problems with the phpMyAdmin
install, you will need to completely uninstall it and then reinstall it
and try again. A good sign that the install hasn't worked is if you
don't get the prompts shown above during the install process. If you
find you can't properly uninstall it with
sudo apt-get -f remove phpmyadmin then follow the advice from this
forum Can't Remove