How to install LEMP (Linux, Nginx, MySQL, PHP) stack on Ubuntu | Debian in 10 minutes

Hey folks, in this tutorial I will explain how to install LEMP stack in 10 minutes. Technologies we are going to use are Ubuntu 18.04, Nginx (custom build), MariaDB(an optimized version of MySQL), PHP7.x. Let’s jump into the tutorial. But the OS is not limited to Ubuntu 18.04. You can use Ubuntu 19.04 or Debian 9 (Debian 10 is supported but haven’t tested yet).

Advertisement
Udemy 100% FREE COUPON CODES

I’m pretty much sure that you know what LEMP stack is. Since the reason, you found this article is you need to know how to install LEMP stack. Anyway, here’s a brief introduction those who don’t familiar with this stack.

Advertisement

What is LEMP stack?

This is an acronym that describes a Linux operating system, with an Nginx (pronounced like “Engine-X”) webserver. The backend data is stored in the MySQL database (in this tutorial, we are going to use MariaDB ↱) and PHP handles the dynamic processing.

Sounds familiar? Perhaps, you have heard about LAMP stack ↱. It’s pretty much a similar stack of components as LAMP, except the Apache is being replaced by Nginx. There are some advantages and disadvantages when comparing both of these technologies. I will compare these two technologies in a future article.

Installing LEMP stack

Installing and configuring (fine-tuning) a server is not an easy task even for experienced developers. Thanks to awesome open source community, we can install the whole stack in few lines of commands. Big thumbs up hard work 👍.  We are going to use WordOps ↱ to setup LEMP stack. There are so many features available in WordOps toolset. You can find out more information from their documentation ↱ page. Some parts of the docs haven’t updated yet for the latest version so you’d better follow my steps for proper installation. WordOps is originally developed for WordPress websites but we going to use it to host any PHP, MySQL website.

Prerequisites

Hardware Requirements

Minimum

  • ~100MB of storage
  • 512MB RAM

Recommended

  • Multi-core CPU
  • 20GB SSD storage
  • 2GB RAM

You can use any service provider that you like. I can recommend DigitalOcean or Vultr as an affordable and decent option for both beginners and experts. You can get FREE $50 using below offers.

Other than that, you are more than free to walk around GCP, AWS, and Azure.

Advertisement
Digitalocean Deploy SSD VPS FREE 100 free

Software Requirements

Distribution Release Architecture 
Ubuntu 18.04 LTS (bionic) x86_64
19.04 (disco) x86_64
Debian 9 (Stretch) x86_64

Installation

  1. Open up your terminal/putty window using SSH or you can use the integrated web terminal.
  2. Update your repositories
    sudo apt update
  3. Make sure that you have installed wget ↱
    type wget --version and hit enter, if you get a message like “Command ‘wget’ not found” first of all you have to install wget. If you can see wget description and version number, just skip this step.
    sudo apt install wget -y this command will install wget on your server.
  4. Enable UFW to enable necessary ports. (ufw might be enabled by default) Use sudo ufw status to check the status. If the status shows “inactivated” use the following command to enable sudo ufw enable it.
    install lemp stack, check ufw status
    You might see more than two records. If you see HTTP and HTTPS(Port 80 and 443) rules, you can skip step 5.
  5. Add HTTP and HTTPS rules
    sudo ufw allow 80/tcp
    sudo ufw allow 443/tcp
  6. Restart UFW
    sudo systemctl restart ufw
  7. Setup is almost completed now we need to download and install WordOps installer
    wget -qO wo wops.cc && sudo bash wo
    After you hit enter the script will ask your name and email. Provide those details and wait for the installation. It will take up to 5 minutes.

Wola! You have successfully installed LEMP stack on your Ubuntu VPS. It wasn’t hard. Right? 🙂

Advertisement

Create a Webspace

You have done an amazing job so far. Let’s create your PHP 7.3 and MySQL webspace.

  1. Replace ‘site.tld’ with your domain name.
    sudo wo site create site.tld --mysql --php73
    This command will automatically configure Nginx and create a database for you.

Easy enough? 😇

Things to note :

  • Make sure to point your domain to the server IP.
  • Webspace location (htdocs) /var/www/site.tld
  • MySQL information /var/www/site.tld/wo-config.php
  • If you navigate to your ‘site.tld’ it will show ‘403 Forbidden’ message until you add index file to ‘htdocs’.
  • Need to learn more about WordOps CLI? Check their awesome Docs.

Conclusion

LEMP stack is very popular around the world and most of the popular websites powered by this powerful stack. Even my The Inspired Dev website uses the same stack. Everything made so easy thanks to WordOps team.

Let me know if you have any questions about this article in the comment section. Also, suggestions are warmly welcome.

Advertisement
0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x