Installing Nginx, MySQL, PHP (LEMP) on Ubuntu 16.04
A virtual private server (VPS) is most often used to host dynamic websites and applications. This requires installing and configuring a web server. The LEMP “stack” involves the Linux operating system (L), the Nginx web server (E), a MySQL database (M), and PHP for dynamic webpages (P).
PrerequisitesBefore you start, you need the following:
- A VPS running Ubuntu 16.04
- A regular (non-root) account with sudo privileges. See our SSH keys tutorial for more information.
Step 1: Disabling apache2We need to ensure that Apache (a different web server option) isn’t running. Let’s remove it from the server.
sudo apt-get remove apache2 sudo rm /var/www/html/index.html
Step 2: Installing NginxUbuntu’s
aptpackage management software makes installing nginx quite easy. Running the
updatecommand ensures you get the most up-to-date version.
Nginx will automatically start running at this point. You can double check this by navigating to the IP address of your VPS via a web browser.
sudo apt-get update sudo apt-get install nginx
If successful, you’ll see a default Nginx page.
Step 3: Installing MySQLNext, we’ll install MySQL, which is a database that will be used to store information. Install this with
You will be prompted to input a password for the adminisrative user for MySQL. We recommend a strong, secure password. For additional security, you won’t be able to see the characters as you type them in. Next, run a script to improve the security of the installation.
sudo apt-get install mysql-server
You’ll see the following warning about the
VALIDATE PASSWORD PLUGIN.
This plugin will reject passwords that are not strong enough. It’s not necessary if you’re diligent about using strong, secure passwords. If you choose
VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin? Press y|Y for Yes, any other key for No:
Yes, you’ll be asked to define a policy for strong passwords. You will also be given an opportunity to change the root password if you’d like.
For the remainder of the questions, type in
Using existing password for root. Change the password for root ? ((Press y|Y for Yes, any other key for No) :
Yand then hit
Enter.... Read More