Default Green Orange
Swifty's Blog
James Irving-Swift's portfolio and random blogging
RSS
  • Home Page Home
  • My CV

Quick Start guide to install LEMP server on Ubuntu 12.04 (Linux + Nginx + MySql + PHP )

Linux, Ubuntu Add comments

I have seen some online guides about this but really was after one specific to Ubuntu 12.04. So here goes:

Step 1 – Installing Nginx

First we need to add the Nginx source

sudo add-apt-repository ppa:nginx/stable

Next, as we always do after adding a source, we need to update

sudo apt-get update

And now we install it

sudo apt-get install nginx

Next, we must start the Nginx service.

sudo /etc/init.d/nginx start

To check if it is successful, try going to http://localhost/ in your browser. If you see a Welcome to Nginx page, it has been successful.

Step 2 – Installing PHP5:

Install PHP and any required extensions

sudo apt-get install php5-cli php5-cgi php5-fpm php5-mcrypt php5-mysql

Edit the default Nginx site config (if you are not familiar with vim, try entering ‘nano’ instead)

sudo vim /etc/nginx/sites-available/default

The changes you will need to make are as follows:
1)

index index.html index.htm;

to

index index.html index.htm index.php;

2)

root /srv/http/nginx;

^this path may be different in your install, it doesn’t matter as we are changing it!
to:

root /var/www;

3) uncomment the following lines

 location ~ \.php$ {
     fastcgi_pass 127.0.0.1:9000;
     fastcgi_index index.php;
     include fastcgi_params;
  }

Now quit vim (‘:wq’) and restart the nginx service.

sudo /etc/init.d/nginx restart

If the folder /var/www/ doesn’t exist, create it

sudo mkdir /var/www/

Step 3 – Install MySQL

And finally,

sudo apt-get install mysql-server

Step 4 – Check it works!

Create a test file

vim /var/www/test.php

Add this line

<?php phpinfo();?>

Save and quit vim (:wq) and go to http://localhost/test.php in your browser.
If you see a page displaying all your PHP settings, then it works!


May 2nd, 2012  
Tags: LEMP, Linux, Mysql, nginx, Ubuntu

6 Responses to “Quick Start guide to install LEMP server on Ubuntu 12.04 (Linux + Nginx + MySql + PHP )”

  1. jiro
    May 17th, 2012 at 08:00

    Thanks !

    You saved my life ^^


  2. Alex W
    July 4th, 2012 at 13:45

    Small amendment, but for…

    sudo add-apt-repository ppa:nginx/stable

    …you need to have first installed python-software-properties.

    sudo apt-get install python-software-properties


  3. Swifty
    July 4th, 2012 at 13:55

    I thought they came with Ubuntu, but I might be mistaken. Thanks for the tip though. :-)


  4. marcio
    July 6th, 2012 at 00:44

    Olá amigo.
    Preciso de ajuda.
    ja tentei de tudo segui as instruções á risca mas o nginx não instala.
    dá a mensagem abaix:
    Lendo lista de pacotes … Pronto
    Construindo arvore de dependencias
    Lendi a informação de estado …pronto
    nginx ja é a versão mais nova.
    0 pacotes instalados, 0 pacotes novos instalados, 0 a serem removidos e 31 não atualizados,,,,, dai dá uma serie de erros e o erro abaixo
    ERROR: Module usblp does not exist in /proc/modules

    Pode me ajudade nisso/

    Valeu!


  5. Domenic Fiore
    July 9th, 2012 at 10:35

    Hey man,

    Maybe you should put a little PHP code to make sure that the MySQL server works and will work with PHP. I’ve followed tons of guides like these over and over and MySQL has been a bitch.


  6. Christoph
    July 20th, 2012 at 23:31

    Thanx for the guideance. I spend about 30 minutes to figure out why ngnix does not accept my changes in ../sites-available/default.
    I fact i did something i always do. I made a backup of the configfile and put it under /sites-available/default_bak. Unfortunatly I forgot that ngnix includes all files in that directory, which leads to strange results. After removing my backup configfile everything worked fine.


Leave a Reply

  • Search

  • Calendar

    May 2012
    M T W T F S S
    « Mar    
     123456
    78910111213
    14151617181920
    21222324252627
    28293031  
  • My Twitter

    • @skyatlantic why is sky atlantic HD the only channel that apparently can get signal?!? 4 days ago
    • @miniviolette it was… I realised that I was to drunk to continue when I only got one kill in battlefield3 in 30 mins!!!! epic fail! 1 week ago
    • @miniviolette yeah! i just stay in an played xbox and didn't pay attention to how much I was drinking at the same time! Amateur Mistake! 1 week ago
    • This sums up my Saturday morning! http://t.co/yBuMQ0afMy 1 week ago
    • @Rich_McCartney I'm still on Lion, i really need to sort out mountain lion so that my thunderbolt display stops being buggy! 1 week ago
  • Categories

    • Development
    • Development
    • JISCMail
    • Just for fun
    • Linux
    • Magento
    • Mailtalk
    • Mutiny
    • Random
    • Thomas Murr Art
    • Ubuntu
    • Websites
    • Wordpress
  • Archives

    • May 2012
    • March 2012
    • November 2011
    • May 2011
    • October 2010
    • September 2010
    • July 2010
    • April 2010
    • March 2010
    • SN205662 Samsung digital camera
    • SN205661 Samsung digital camera
    • SN205660 Samsung digital camera
    • SN205658 Samsung digital camera
    • SN205659 Samsung digital camera
    • SN205657 Samsung digital camera
    • SN205656 Samsung digital camera
    • SN205655 Samsung digital camera
    • SN205654 Samsung digital camera
    • SN205653 Samsung digital camera
    • SN205651 Samsung digital camera
    • SN205652 Samsung digital camera
    • SN205650 Samsung digital camera
    • SN205649 Samsung digital camera
    • SN205648 Samsung digital camera
    • SN205644 Samsung digital camera
    • SN205625 Samsung digital camera
    • SN205639 Samsung digital camera
    • SN205626 Samsung digital camera
    • SN205636 Samsung digital camera
Copyright © 2013 Swifty's Blog
XHTML CSS Log in