Installing Apache
sudo apt-get install apache2
Testing Apache
Once that’s finished installing, we can start up Apache to test it by typing…
sudo /etc/init.d/apache2 start
Now open up your browser (or if you’re a time saver,) and point it to…
http://localhost
If you’re cleanly installing Apache, you’ll see the default installed folder index, or you’ll see your normal server pages if you’ve updated.
Installing PHP
Now that Apache is installed, PHP is next…
sudo apt-get install php5
Once PHP has finished installing, if we restart Apache…
sudo /etc/init.d/apache2 restart
Testing PHP
To test PHP, we’ll make a new PHP document with any editor you want…
sudo gedit /var/www/phpinfo.php
And paste the following code into the file to run PHP’s phpinfo() function, which will show us a myriad of information about PHP…
<?php phpinfo(); ?>
Now we can save the file, and browse to…
http://localhost/phpinfo.php
To see all of the information about your PHP installation. For security reasons, you should remove this page when you’re done with it. If you want to do that quickly…
sudo rm -rf /var/www/phpinfo.php
Assuming you named the file phpinfo.php.
Installing MySQL
To install MySQL, in our terminal window…
sudo apt-get install mysql-server
If this is a clean installation of MySQL, it will prompt you to set your root password. Make sure that you type it correctly, as it will only ask you once. If you’ve upgraded, or installed MySQL before, it may not prompt you for a password.
Testing MySQL
Once MySQL is finished installing, we can test MySQL by connecting to it, using…
mysql -uroot -pyourpassword
After filling in your own password after -p, you’ll see a MySQL prompt.
That’s it, you’re done! You can type ‘exit’ to get out of MySQL.