May 26, 2015

LEMP on Ubuntu

^ Ad space to help offset hosting costs :D

Learn how to install & configure Nginx, MySQL and PHP on an Ubuntu server.Here are the commands used and run during the video:

Install some basics:

sudo apt-get update
sudo apt-get install -y wget curl vim tmux htop software-properties-common


We'll get the latest stable of Nginx:

sudo add-apt-repository -y ppa:nginx/stable
sudo apt-get update

# Compare versions available
sudo apt-cache show nginx

# Install latest available
sudo apt-get install -y nginx

Check out the default site configured at /etc/nginx/sites-available/default.


See available versions, add a repository for version 5.6, and install:

sudo apt-cache show php5

sudo add-apt-repository -y ppa:ondrej/php5-5.6
sudo apt-get update

sudo apt-get install -y php5-fpm php5-cli php5-mysql php5-curl php5-mcrypt php5-gd

Explore configuration for PHP in /etc/php5, taking note of special configuration for PHP-FPM in /etc/php5/fpm.

Configure Nginx for PHP:

# Edit /etc/nginx/sites-available/default:
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    index index.htm index.html index.php;

    server_name _;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php5-fpm.sock;


Simply install versino 5.6 using:

sudo apt-get install -y mysql-5.6

(There's more overview of configuration in the video, definitely check it out!)


LEMP on Ubuntu

All Topics