Verified and Tested 02/26/15

Introduction

In this How-To, we will walk you through the LEMP install on your Debian 7 Cloud Server.

LEMP is simply a software bundle that consists of 4 components. L (Linux) is the core of the platform, which will sustain the other components. E(Nginx)will be used for the web service. M(MySQL)will be used for database management, and P(PHP) will be the programming language. It is making the platform a LEMP.

Prerequisites

A cloud server with Debian already installed (which will take care of the L(Linux) aspect of the LEMP install).  If you do not already have a server, why not spin up a Linux VPS Server from Atlantic.Net

Installing LEMP on Debian 7

Install Nginx with the following command to begin the install:

apt-get install nginx

Start nginx with the following command:

service nginx start

Verify if all is working by typing HTTP: //YOUR.IP.ADD.RESS

Installing LEMP in Debian-1

Install MySQL with the following command to begin the install and set a MySQL root password:

apt-get install mysql-server

Installing LAMP in Debian-1

Secure MySQL from the default settings with the following command:

mysql_secure_installation

Note: You will be prompted with a series of questions. Type N for the change root password and Y for yes on all of them, see the screenshot below:

Installing LAMP in Debian-2

Install PHP with the following command to begin the install:

apt-get install php5 php5-fpm php5-mysql

Then we must move the original sites file for backup purposes to a new file name:

mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.old
nano /etc/nginx/sites-available/default

Copy the following into your text editor:

server {
listen 80;
server_name your_site_name.com;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;

location / {
try_files $uri $uri/ =404;
}

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;

location = /50x.html {
root /var/www/html;
}

location ~ \.php$ {
try_files $uri =404;

fastcgi_pass unix:/var/run/php5-fpm.sock;

fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

Create a simple PHP page to test by using a text editor of your choice:

nano /var/www/html/info.php

Insert the following code in the space, then save and exit:

<?php
phpinfo();
?>

We will need to restart Nginx, so all changes are updated.

service nginx restart

Installing LAMP in Debian-3

Congratulations! You have just installed LEMP on your Debian Cloud Server. Thank you for following along in this How-To, and check back with us for any new updates.

Learn more about our VPS hosting services and VPS hosting price.