To install Apache open the command terminal and enter the following command:
sudo apt-get install apache2

click to enlarge
Once this is installed, you want to make sure Apache is up and running. So fire up your browser and point it to http://localhost, or you can type servers’ IP address into the address bar). If you get the message “It Works!” you are good to go.
With Apache installed, let’s move on.
The next step is to install PHP. This will need to be installed so it will have everything needed to integrate with Apache. To do this, issue the command:
sudo apt-get install php5 libapache2-mod-php5
Restart Apache with the Command Terminal with the following command:
sudo /etc/init.d/apache2 restart
Now, it's time to test to make sure PHP is working. Create a file within /var/www/testphp.php with the following contents:
< ?php phpinfo(); ?>
Save that file in /var/www/ and then point your browser to that file. If all is well you will see the text, “Test PHP Page.” If you see that, you can move to to…
The next step: MySQL.
To install the necessary tools, issue the command:
sudo apt-get install mysql-server
This is where it gets just a bit tricky. You have to first set a password for MySQL. To do this, run the first command in order to get to the mysql prompt and the second to set the password:
mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('YOURPASSWORD');
Where YOURPASSWORD is the actual password you want to use for the root user.