In this article we will walk you through the steps on how to install LEMP (Linux, Nginx, MySQL and PHP-FPM) on a Debian 8 VPS.
A LEMP stack is a synonym of LEMP server or LEMP web server. It refers to a set-up which includes Linux, Nginx, MySQL (MariaDB) and PHP.
REQUIREMENTS
We will be using our SSD 1 Linux VPS hosting plan for this tutorial.
UPDATE THE SYSTEM
Make sure your server is fully up to date using:
INSTALL NGINX
To install Nginx on your Debian 8 server, you need to execute the following command:
After the installation is complete, you can start Nginx with:
Enable Nginx to start on boot:
Possible issues:
If during the Nginx installation you encounter error such as:
then, you can fix this by opening the default Nginx configuration file and comment the listen [::]:80 default_server; line. Enter the below command:
Locate the listen [::]:80 default_server; line and comment it by putting # in front of the line. Restart Nginx for the changes to take effect and run the install Nginx command so the package manager finishes the Nginx configuration:
Verify that Nginx is running by opening a web browser and visiting your server IP address (http://server_ip) . You should get the Nginx welcome page like the one below:
INSTALL MYSQL
Now let’s install MySQL. Issue the following:
During the installation, you will be asked to enter a password for the MySQL root user. Do not enter an easy to crack password. It should contain at least 8 characters mixed with upper and down cases.
Now that MySQL is installed, we recommend you to do the MySQL secure installation by running:
Enter your root password and answer with ‘n’ when you are asked to change your MySQL root password. Below is the entire procedure that you can follow:
Enable MySQL to start on boot:
INSTALL PHP-FPM
Install PHP-FPM by running the underneath command:
Next step you need to do is to modify the Nginx configuration file. But to avoid looking for lines that need to be edited or commented out through the default Nginx file, let’s rename the file and create a new one. The below command do exactly that:
Now, that you have a new default file opened, paste the following content:
Save and exit the file.
Now, let’s make a simple PHP page test. Create a PHP info page so you can check your PHP version, modules activated etc…
Create a file, let’s call it info.php into the /var/www/html directory:
Paste the following into the file:
Restart Nginx for the changes to take effect:
Now, open your favorite web browser and navigate to http://your_server_ip_address/info.php . You will be welcomed by a web page similar to the one below:
That’s it. You have successfully installed the LEMP stack on your Debian 8 VPS.
Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install the LEMP stack for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
I am using VPS 512MB and articles help me get better performance with Nginx & PHP-FPM
Thank you!
Thanks!
Helped me building my site :)