The newest long term support release of Ubuntu (Trusty Tahr) is finally here! I just spun up a droplet over on DigitalOcean to walk through setting up a LAMP stack for this post.
I also recommend making sure that your system is completely up to date. At the time of this writing there was nothing to upgrade, but that will change in the coming weeks (if not days). To ensure your system is fully up to date you can run the following:
sudo apt-get update && apt-get dist-upgrade
Once that’s completed we can get the AMP in LAMP installed by running the following:
sudo apt-get install apache2 php5 php5-cli php5-mysql mysql-server
This will install the base minimum (and command-line PHP) for a functional LAMP stack. You can always install additionally libraries if you need them but I’m just focusing on the bare bones. Don’t forget to setup a password for MySQL, you’ll be prompted for it during the install.
The great part about Trusty is that is comes with PHP 5.5.x out of the box (5.5.9 at the time of this writing, which is still a few revisions behind). The downside is that they will probably stick with the 5.5.x branch even after 5.6 (and then 5.7) are released. Expect a post on how to upgrade to 5.6.x once it’s out of beta ;)
Once everything is done installing, point your web browser to the IP address of the server (or domain name if you’ve went ahead and set that up) and you will be greeted with a page titled “Apache2 Ubuntu Default Page”. This page doesn’t give a clear indicator that PHP is installed and functioning properly so next we’ll run the following command:
echo '<?php phpinfo(); ?>' > /var/www/html/phpinfo.php
That will create a file named
phpinfo.php that’s populated with the
phpinfo() command so we can see if PHP is functioning. Point your web browser to the same IP or domain as before with
/phpinfo.php appended to it. If everything is set up correctly you will see the familiar PHP logo and a bunch of information about the install.
That’s all there is to it, you now have a bare bones LAMP server set up and ready to go!