This brief tutorial shows you how to install the LEMP stack on Ubuntu 14.10.  Most tutorials online refers to it as the LAMP stack and that’s because it includes Linux, Apache2, MySQL, PHP.

The LEMP refers to Linux, Nginx (Engine-X), MySQL/MariaDB and PHP. The LEMP stack is a server-side application stack which allows dynamic and powerful web applications to function.

WordPress, Drupal, Joomla and others popular dynamic applications all rely on the LAMP or LEMP stack to function. The L which stands for Linux allows for opensource applications to run.

The A for Apache2 or E for Engine-X is a web server which allow the web content (images, text, videos, etc) to be displayed. The M for MySQL or MariaDB is a database server to store website content and PHP allows to run PHP based applications in your web browser.

This brief tutorial is going to show you how to install this stack in Ubuntu 14.10 if you haven’t already done so.

  • Installing Nginx (Engine-X) on Ubuntu 14.10

Since we already have a Linux operating system installed, lets jump to installing our applications. The first one is Nginx. To install Nginx on Ubuntu 14.10, run the commands below.

sudo apt-get install nginx

Running the commands above will install an older but stable version of Nginx. To install the latest, you will have to add Nginx’s repository to your machine.

To learn how to install the latest version of Nginx on Ubuntu, read this post here or click the link below:

https://www.liberiangeek.net/2014/10/install-latest-version-nginx-ubuntu-14-10/

If you prefer to install Apache2 instead of Nginx, then run the commands below

sudo apt-get install apache2

You should not install both Apache2 and Nginx on the same server. It’s possible, but not recommended.

 

  • Installing MySQL or MariaDB Database server

Then next step is to install MySQL or MariaDB database. MySQL was once the default database server for all Linux distributions.  But now the Linux community is moving away from MySQL and switching to MariaDB. Ubuntu still has MySQL as the default, but maybe not for long.

MariaDB is a drop-in replacement for MySQL which means the only difference between the two is their names. MariaDB should take the place for MySQL with no problem at all.

To install MariaDB on Ubuntu 14.10, you’ll have to add its repository. To do that, run the commands below.

First install MariaDB repository key by running the commands below.

sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db

Then create a repository file for MariaDB and paste the content below in it, then save.

sudo vi /etc/apt/sources.list.d/mariadb.list

Paste the block below in the file and save it.

 deb http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu trusty main
deb-src http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu trusty main

After that, run the commands below to install MariaDB server.

sudo apt-get update && sudo apt-get install mariadb-server mariadb-client

Installing MySQL on Ubuntu is as simple as running the commands below. Unlike MariaDB, MySQL is in Ubuntu default repositories so all you have to do is run the installation commands to install it.

sudo apt-get install mysql-server mysql-client

Doing the installation, you’ll be prompted to create a root password for the database server. Create and confirm a password to continue. The database will be started automatically for you.

To improve the database security, run the commands below

sudo mysql_secure_installation

Next, choose Yes for the rest of the prompts until you’re done.

  • Enter current password for root (enter for none): Type root password
  • Change the root password? N
  • Remove anonymous users? Y
  • Disallow root login remotely? Y
  • Remove test database and access to it? Y
  • Reload privilege tables now? Y

When you’re done, continue below to install PHP

 

  • Installing PHP On Ubuntu 14.10

The final step is to install PHP and other modules. PHP is responsible for processing dynamic web content. PHP connects to the database using a PHP connector so to get PHP functioning properly run the commands below to install it.

sudo apt-get install php5 php5-mysql

Although the two packages above will get PHP to function, it’s also recommended to install these additional PHP modules in order for PHP to function with other important services and scripts.

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

That’s it!

Enjoy!