Preparing Ubuntu 14.04 for Web Hosting (LEMP installation)

edited August 2014 in Proposed How-Tos


In this tutorial, you’ll learn how to install WordPress on fresh created instance. I'll demonstrate you the installation on Ubuntu 14.04 server. It should work well for older versions of Ubuntu and for Debian too, but I’m not 100% certain about this.
So, let’s start.

Step One: Update existing packages

apt-get update && apt-get upgrade

Step Two: Install Nginx

Nginx is a high performance lightweight web server designed with the purpose of delivering large amounts of static content with efficient use of system resources. In contrast to the Apache, nginx uses an asynchronous event-driven model which provides more predictable performance under load.

Let’s add third-party repository to install the latest version of Nginx (1.6.1).
sudo apt-get install python-software-properties
add-apt-repository -y ppa:rtcamp/nginx
sudo apt-get update
sudo apt-get install nginx
service nginx start
Now, let’s test if the server is up and running.
It should take you to Nginx's default landing page:

Step Three: Install PHP 5.5

PHP is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.
Let's install the latest version of PHP on our server.
sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
sudo apt-get install php5-common php5-mysqlnd php5-xmlrpc php5-curl php5-gd php5-cli php5-fpm php-pear php5-dev php5-imap php5-mcrypt

If you want to check PHP version, run the following command:
php -v
You will see something like this.
PHP (cli) (built: Aug 25 2014 10:24:59)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
withZendOPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
Now, we'll make a slight configuration change to make our setup more secure.
Open the main php5-fpm configuration file with root privileges:
sudo nano /etc/php5/fpm/php.ini
Press Ctrl+W and search for “cgi.fix_pathinfo=”
Uncomment it (delete ;) and change 1 to 0.
After changes, this line should look like this:
Save (Ctrl+O) and close the file (Ctrl+X).
Now, we just need to restart our PHP processor by typing:
sudo service php5-fpm restart

Step Four: Install MySQL

To store and manage databases, we need to install MySQL. You can easily install it by typing the following in the console:
sudo apt-get install mysql-server
During the installation process, you will be asked to set a root password for MySQL.

After that, we will have to tell MySQL to generate the directory structure where it will store databases.
sudo mysql_install_db
Let’s finish it up by running a security script that will modify some default insecurities.
Just type the MySQL root password and type “n” if you don’t want to change it. After that, type “y” to every question.

Set Timezone (conditional)

By default, the timezone of your server is UTC. If you're living in a different timezone, you can change it by typing in the following command:
sudo dpkg-reconfigure tzdata

That’s it! Your LEMP server is up and running now.


  • +1

    I'm not a Linux user, but that has to be one of the clearest and well presented/formatted how-to's (not just here, but anywhere) I've ever seen.

    Give that guy/gal a job!
  • Thank you for your nice words, you're way too kind. :)
  • That is a very sexy format and I have no idea how you've done it. Well done lol!
    This will be very useful as i will be setting up something similar soon, thanks. :-)

    Oh and by the way;
    I'm sure you can see an obvious problem with that command ;)
Sign In or Register to comment.