Skip to content

Instantly share code, notes, and snippets.

@MohammadShawon MohammadShawon/LEMP
Created Dec 18, 2016

What would you like to do?
Install LEMP-(Linux Nginx MySQL PHP ) stack on Ubuntu 16.04
#The LEMP software stack is a group of software that can be used in dynamic websites and web Application. This is an acronym that describes a Linux operating system with an Nginx Web Server. MySQL database stored the data and dynamic data handled by PHP.
#Imstall Nginx as web server
$ sudo apt-get update //update our local index packages
$ sudo apt-get install nginx
# If ufw firewell running we need to allow cooection to nginx.We can enable this by this
$ sudo ufw allow 'Nginx HTTP'
# MySQL Installation
$ sudo apt-get install mysql-server
#To secure root connection
$ sudo mysql_secure_installation
# Install PHP for Processing
$ sudo apt-get install php7.0-fpm php7.0-mysql
// Fix the settings of php.ini
$ sudo nano /etc/php/7.0/fpm/php.ini
***Find the cgi.fix_pathinfo and put out semicolon and set the value 0
# Restart the PHP Processor
$ sudo systemctl restart php7.0-fpm
// Configure Nginx to use PHP Processor
$ sudo nano /etc/nginx/sites-available/default
# Write this-
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name localhost;
# pass the PHP scripts to FastCGI server listening on
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
# Test the Connection
$ sudo nginx -t
# Reload the nginx settings
$ sudo systemctl reload nginx
Go and Enjoy !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.