parfait with four layers

How to install a LEMP Stack on Ubuntu 14.04

SecurityCategory
3 min read
Stephani Worts

What is a LEMP Stack? Basically, it’s just a funny sounding acronym for a collection of server-side applications installed together:

Linux
Nginx (pronounced “engine-X” — hence the "E")
MySQL
PHP

These four core components work together to give you complete control over the server on your Ubuntu Linux machine. By starting from a machine running Ubuntu, you've already got the "L" in the acronym; this guide will walk you through installing the rest. Although the installation of a LEMP Stack itself is relatively straightforward, we still recommend that only advanced users tackle the task. You’ll be installing multiple programs and spending a good chunk of time modifying your server.

In order to install perform this task, you’ll need an active Linux server, as well as an SSH client such as PuTTY (for Windows) or Terminal (Mac). We recommend a GoDaddy Virtual Private Server if you’re just getting started, or a full dedicated server if you’re ready to take total control.

[requirements difficulty="8" time="25"]

Installing a Lemp Stack on Ubuntu 14.04

Here’s a quick tutorial on how to install a LEMP Stack on Ubuntu 14.04:

1. Update your system.

Because you'll be installing multiple pieces of software to complete the LEMP Stack on your machine, you should always get into the habit of updating your machine before you continue. You can do this by running the following Terminal command:

sudo apt-get update

2. Install Nginx.

Nginx is currently one of the most popular web servers designed for use with Linux systems. It also represents the main difference between a LEMP Stack and a LAMP Stack (in a LAMP Stack, the Apache web server is installed instead of Nginx). To install Nginx, execute the following command in the Terminal:

sudo apt-get install nginx

3. Install MySQL.

Now you need a database server. MySQL (the “M” in LEMP) has been the default database server for all variants of Linux for many years. It’s even included by default in the Ubuntu repositories. Since it’s already there, you only need to execute the following command to properly install it:

sudo apt-get install mysql-server mysql-client

NOTE: During the installation, you’ll be asked to create a separate root password for the database server that is being created. Once you create and confirm that password, the database will start automatically.

4. Install PHP.

The final step required to get your LEMP Stack up and running involves the installation of PHP, which processes dynamic web content. You can install PHP by executing the following two commands in the Terminal:

sudo apt-get install php5
sudo apt-get install php5-mysql

5. Install optional PHP packages.

Though PHP will be up and running on your machine, you should also install a series of optional packages to improve its compatibility with certain services. Install the additional packages by running the following Terminal commands:

sudo apt-get install php5-curl
sudo apt-get install php5-cgi
sudo apt-get install php5-gd
sudo apt-get install php-pear
sudo apt-get install php5-mcrypt
sudo apt-get install php5-sqlite
sudo apt-get install php5-tidy
sudo apt-get install php5-xmlrpc
sudo apt-get install php5-xsl

So there are the basics. You now have a web server, database and scripting environment set up. Now go create something awesome!

Products Used