In this tutorial you will learn to install LEMP in your Linux OS
LEMP is a web stack consist of a bundle of software and frameworks which are used for building full-stack web application.
A Stack usually consist of database, server-side and client-side technologies, web server and Operating System, sometimes back-end technologies are cross platform so there is no specified Operating System.
If you are using Linux Distribution Os, we strongly recommend you to install LEMP in your system.
LEMP stands for
- L Linux Operating System
- E Nginx Server
- M MySQL Database
- P PHP
Login in to your Linux OS as a Root before installing LEMP and make sure that your APT package should be up to date before installing this package. If your APT package is not up to date run the below two commands
sudo apt update
sudo apt upgrade
Ngnix Installation
Install Ngnix
sudo apt install nginx
Run the below command to check Ngnix status
sudo service nginx status
To start your Nginx
sudo service nginx start
To stop your Nginx
sudo service nginx stop
If you want to start Nginx automatically at OS startup use the below command
sudo systemctl nginx enable
If you want to disable the automatic Nginx startup
sudo systemctl nginx disable
Now you are ready to run the nginx on your browser, Type: http://localhost/ or http://x.x.x.x/ (ipadress)
![](https://i0.wp.com/linuxquery.com/wp-content/uploads/2022/05/nginx-php-mysql-lemp-debian-1024x570-1.png?resize=574%2C319&ssl=1)
Mysql Installation
Install Mysql Server
sudo apt install mysql-server
To customize your root password run the below command
sudo mysql_secure_installation
Set your “mysql_native_password” for mysql user (“root”)
First, Enter into your Mysql in Terminal following the below command
sudo mysql
Now, To list all users in your mysql run the below command
SELECT user,authentication_string,plugin,host FROM mysql.user;
Now you can change your Mysql password for a user by using below command
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'
To tell the server to reload the grant tables, perform a flush-privileges operation.
FLUSH PRIVILEGES
After Completing your setup you can exit from the Mysql by running below command
exit
Start your Mysql Service
sudo service mysql start
Stop your Mysql Service
sudo service mysql stop
Reload Mysql Service
sudo service mysql reload
Restart Mysql Service
sudo service mysql restart
PHP Installation
First you have to add PPA Run the below commands.
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
Finally Run the Update and Upgrade Command to Complete the installation
sudo apt update && sudo apt upgrade
PHP Versions
If you want to install required PHP packages use following command
Php -v 5.6
sudo apt install php5.6 php5.6-common php5.6-curl php5.6-dev php5.6-gd php5.6-intl php5.6-json php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-soap php5.6-tidy php5.6-xml php5.6-zip php5.6-fpm -y
Php -v 7.0
sudo apt install php7.0 php7.0-bcmath php7.0-common php7.0-curl php7.0-dev php7.0-gd php7.0-intl php7.0-json php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-soap php7.0-tidy php7.0-xml php7.0-zip php7.0-fpm -y
Php -v 7.1
sudo apt install php7.1 php7.1-common php7.1-curl php7.1-dev php7.1-gd php7.1-intl php7.1-json php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-soap php7.1-tidy php7.1-xml php7.1-zip php7.1-fpm -y
Php -v 7.2
sudo apt install php7.2 php7.2-bcmath php7.2-common php7.2-curl php7.2-dev php7.2-gd php7.2-intl php7.2-json php7.2-mbstring php7.2-mysql php7.2-soap php7.2-tidy php7.2-xml php7.2-zip php7.2-fpm -y
If you have any doubts regarding this articel, you can feel free to ask your doubts through the comment section.