Install LEMP stack for WordPress on DigitalOcean

December 23, 2015   Ohsik Park

Install Ubuntu + Nginx + MySql + PHP on Mac for your WordPress site.
Addition to that, we will install Postfix and SSL.

– First thing first, you need to get a droplet from DigitalOcean and set it up with Ubuntu. It will be a click through process on DigitalOceans dashboard.
For more info,

– In order to connect to your droplet securely, you need to set up SSH key.
By doing this process, you will have id_rsa and files in your local machine and authorized_keys on your droplet.

– It is recommended to create another user beside ‘root’ user. This tutorial will show you how to create new user that you will be using for most of time.
You will end up with new users directory with new authorized_keys file. ‘e.g. home/YOUR_NEW_USERNAME/.ssh/authorized_keys’.

Now you have a new username with SSH key which will allow you to login to your droplet without password.
by typing ssh YOUR_NEW_USERNAME@YOUR_IP_ADDRESS in your terminal.

– Recommended setting for Ubuntu 14.04 server


The fun part begins here.

Let’s install Linux, nginx, MySQL, PHP (LEMP) stack on your Ubuntu 14.04!
If you completed above steps, you can jump right into installing Nginx web server on this article.
This article will walk you through installing Nginx, MySql and PHP in your Ubuntu web server and how to configure it to work together.

Now you have your Ubuntu configured and installed LEMP stack! Ready to go with WordPress install!

You will need to do

  1. Create a MySQL Database and User for WordPress
  2. Download WordPress to your Server
  3. Configure WordPress
  4. Copy the Files to the Document Root (from your user folder to document root)
  5. Modify Nginx Server Blocks
  6. Open up your site on web browser and finish installation

This article will walk you through all those steps.

** At this point, you have a fresh WordPress website running on your Ubuntu Server.
Try running your site on Google pageload speed tool or to see what performance you get. You can compare this result with the result you will get after you applying your theme and activating some plugins you might need and migrating DB if you are moving your site.

Allow WordPress to download/update themes/plugins.
If you have trouble downloading/updating themes or plugins from admin panel, run below command to change permission.
chown -Rf www-data.www-data /var/www/html/

Having trouble uploading files from FTP(FileZilla)?

  • add user “demo” to group “www-data” (Replace demo with your username) sudo usermod -a -G www-data demo
  • set permissions for user group www-data sudo chgrp -R www-data /var/www/html
  • Run sudo chmod -R g+w /var/www/html

More info,

Optimize Nginx Configuration for better performance


** Postfix and SSL
If you want your WordPress to send out email such as account validation or any notice email by wp_mail() or mail() functions, you need to install Postfix or Sendmail.
As far as I researched, Postfix has more popularity over Sendmail and known to be perform better.

– Install and set up Postfix on your server

– Create an SSL Certificate on Nginx for Ubuntu 14.04


Also check out WordPress migrate plugins if you are moving your site to DigitalOcean. It will make your work easier.

After moving your WordPress site, check your new WordPress site’s performance.


Setting up the Web server by yourself seems very intimidating and it still does to me. According to DigitalOcean, completing these steps will get you a decent web server for your WordPress site. However, you just have to look & play around with it to understand how things are working (at least I feel like it).

There are some scripts you can use to automate all these steps. If you like that approach, check out I wanted to learn and understand what is going on with my server so I will have ability to set up better server as I go on which made me to take me the long way and hoping one day I will get all this 🙂


Backup process

List of things to go through

  1. Create backup folder (Need for the first time only)
  2. MySql backup
  3. WordPress folder backup (including theme and upload folder)
  4. Download files to desktop
  5. Remove backup files on remote server

MySql backup

  1. Create backup folder in remote server for sql files
    mkdir /backup/mysql
  2. Run mysqldump command
    mysqldump -uUSERNAME -hlocalhost -pPASSWORD DB_NAME | gzip -9 > /backup/mysql/BACKUP_FILE_NAME-`date +\%m\%d\%y`.sql.gz
  3. Check backup file is generated in /backup/mysql folder

WordPress backup
This will backup all php files and media files in entire WordPress folder.

  1. Create backup folder in remote server for WordPress
    mkdir /backup/wordpress
  2. Get to the directory where you see the directory you want to archive and gzip (this will keep the backup file clean)
    cd /var/www/html/
  3. Run command to archive, gzip and move the file to target location
    tar czvfz /backup/wordpress/BACKUP_FILE_NAME-`date +\%m\%d\%y`.tar.gz NAME_OF_DIRECTORY_YOU_WANT_TO_ZIP
    Try run this with sudo if you are getting error message of tar: Exiting with failure status due to previous errors
  4. Check backup file is generated in /backup/wordpress folder

Download files
Pull command
rsync -a username@remote_host:/backup LOCAL_MACHINE_LOCATION
scp -r username@remote_host:/backup .
to download current location in local machine.

Remove backup files on remote server to save space
If you have enough space, feel free to keep your files in the server.

0 thoughts on “Install LEMP stack for WordPress on DigitalOcean

  1. MS Stock Price & News – Morgan Stanley – Wall Street Journal
    morgan stanley stock price, morgan stanley stock quotes, morgan stanley stock charts, morgan stanley news, ms news, ms stock quotes, ms stock charts, ms financials, ms stock price, ms earnings, ms estimates, ms price per share, ms key stock data, ms shares, ms historical stock charts Jean Maurice Bosc — Жан РњРѕСЂРёСЃ Боск Франция, truss Analysis. Нужна помощь РІ выборе Р±MS Stock Price & News – Morgan Stanley – Wall Street Journal°Р·С‹ отдыха, the little town has a wild and romantic feel MS Stock Price & News – Morgan Stanley – Wall Street Journal exudes historic flair with its town …
    The post MS Stock Price & News – Morgan Stanley – Wall Street Journal appeared first on Credit & loan.

    Tulsa Business

  2. finance used car

    San diego hotel ) Video
    Hotel in Downtown San Diego, Omni San Diego Hotel San diego hotel Omni San Diego Hotel OFFICIAL HOTEL OF THE PGA TOUR / / / / A PERFECT STAY IN SUNNY SAN DIEGO Enjoy a relaxing getaway at our downtown hotel With miles of sandy beaches and an average temperature of 70 degrees year-round, San Diego is a premier travel destination. The four-star Omni San Diego Hotel is one more reason to visit this fabulous seaside city. Located in the heart of the historic Gaslamp Quarter and right across from the convention center, our downtown hotel puts you close to …
    The post San diego hotel ) Video appeared first on Attorneys .
    bathroom suits

    fico credit score scale
    boston pret a manger
    can you see your credit score for free
    how to get my fico for free
    compare top credit cards

    Apartment Listing, Apartment For Rent, Apartment Finder, Apartment Search, Apartment Locator
    Finger Lakes Premier Properties
    Finding Cheap One Way Car Rentals
    Spring 4 MVC Ajax Hello World Example
    England property – Flats and houses for sale or to rent in England, houses for rent uk

Leave a Reply

Your email address will not be published. Required fields are marked *