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.
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
- Password or SSH key
Fire up PuTTY and fill in the server IP address. Putty launches directly into this 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.
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.
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. In addition, the communities behind individual components are very active, and they release patches and updates frequently to ensure that everything is in top working order.
Check Updates for Packages
Before going ahead with the LAMP stack installation, be sure to install the latest updates for all the packages available on the server. To do that, use the following commands at the CLI:
$ apt-get update $ apt-get upgrade $ apt-get dist-upgrade
This step is important because the latest version of all the packages ensure that the rest of the process and the subsequent Larval development process goes without a hitch.
Install the Apache Web Server
Apache is an open source web server that hosts approximately 50% of the websites on the internet. To install the Apache server on the DigitalOcean cloud server, use the following command:
$ apt-get install apache2
During the installation process, you might be asked about the requirement for additional disk space. Press "Y" and the Apache installation process will resume.