How to Create a Laravel-Based LAMP Stack on Ubuntu

Laravel, has become the most used PHP Framework for projects of all scopes (there are other PHP frameworks too like CodeIgniter, Symfony, Yii, and Zend). Whether you're working on a simple web app or a huge corporate Portal, Laravel is up for the task. The robust framework is very versatile and is supported by a very passionate community of developers and users. Another good thing about Laravel is how easy installing and launching a Laravel project is in all development environments.

One exception to this rule is the installation of Laravel framework on cloud servers. In this tutorial, you'll go through the steps required to set up a Laravel-powered LAMP Stack on Ubuntu. For the purpose of this tutorial, you'll be using a DigitalOcean-based cloud server running Ubuntu 16.04.2. DigitalOcean is a cloud infrastructure provider out of New York City. You don't need to use DigitalOcean, you just need access to an Ubuntu server, which could be located on your own network or in the cloud on one of the many services that compete against DigitalOcean (for example, Amazon).

Creating Digital Ocean Server

Go to the DigitalOcean sign up page and sign up with your ID. An email will be send to your ID, and you should verify it and log in to your DigitalOcean account. Once you're logged in, go to Create a New Droplet. Choose your distribution, size and the data center of your server, as shown in the following GIF.

Creating Digital Ocean Server


Connect to the DigitalOcean Cloud Server

In order to install the Laravel PHP framework, you'll need access to a server's command line interface (CLI). The most common and convenient way of connecting to a Linux-based cloud server's CLI is with the Secure Shell (SSH) application. This shell offers a secure communication channel for connecting to and executing commands on the cloud server.

As an application, SSH comes pre-built into Linux and Mac OS X environments. If you want to access the server's CLI with Windows, download and use PuTTY. In this example, you'll use PuTTY. To connect to the cloud server, you must have the following credentials:

  • Server IP address
  • Username
  • Password or SSH key

Fire up PuTTY and fill in the server IP address. Putty launches directly into this dialog box.

 PuTTY dialog box

Click Open. You'll see a security alert notifying that you've not connected to this server before. If you're sure that you've got the IP address right, click Yes.

PuTTY security alert

Next, you're prompted for your login credentials first thing in the terminal window. Insert the login credentials (username and password) for the server.

Note: You won't be able to see the password in the console screen.

Login credentials prompt in in the terminal window

Now, you're successfully connected to the server.

Introduction to the LAMP Stack

A LAMP stack is an integrated and interconnected setup of open source software. The setup comprises of Linux, Apache web server, and PHP. The M traditionally refers to MySQL, an open source relational database management system (RDBMS).

At least when it comes to Linux-based servers, the LAMP stack is for the most part what's minimally needed to run a website. For this reason, it's perhaps the most common solution for setting up servers for web development. An important reason for this universal choice is the cost factor — all components of the LAMP stack are open source and, therefore, are free to use.

Be sure to read the next Cloud article: Why Monitoring Cloud Computing Costs is Crucial