Skip to content
Technology News Information & Jobs

Technology News Information & Jobs

Ubuntu Tutorials, Ubuntu How To , Linux Tips, Tech Jobs

  • Work with US
  • Search Jobs
  • Post a Job
  • Contact Us
  • Ubuntu
    • Ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • Themes
  • Linux
  • Laptops
  • Tutorials
  • Job Dashboard
  • Toggle search form
https://itsubuntu.com/upgrade-ubuntu-18-04-lts-command-line/

Install Linux, Nginx, MySQL, PHP On Ubuntu 18.04 : LEMP Stack

Posted on July 14, 2018 By admin No Comments on Install Linux, Nginx, MySQL, PHP On Ubuntu 18.04 : LEMP Stack

In short: Install Linux, Nginx, MySQL, PHP On Ubuntu 18.04 : LEMP Stack

LEMP is a group of software which is used to run the web based application either in a local system or in a remote server.

L: Linux
E: Engine-X or Ngnix
M: MySQL
P: Php
Before moving to installation, we hope you have Ubuntu ( Linux) installed in your system.

Install Linux, Nginx, MySQL, PHP On Ubuntu 18.04 : LEMP Stack

1. Install Nginx On Ubuntu 18.04

Open the Terminal, and run the following command to install Nginx webserver:

$ sudo apt install nginx

After installing Nginx, check if Nginx service is running or not using command:

$ sudo systemctl status nginx

In case if it is not started run the following command:

$ sudo systemctl start nginx

Firewall setting to allow Nginx web server

You won’t be able to access the Nginx web browser from remote systems if you have enabled the UFW firewall in Ubuntu 18.04 LTS. To allow it, you will need to allow connections to Nginx. Run the following command to enable it:

At first, Let us check out the which applications have installed a profile. Use the following command to check.

$ sudo ufw app list
Available applications:
Nginx Full
Nginx HTTP
Nginx HTTPS
OpenSSH

Let’s allow the traffic on port 80.

sudo ufw allow 'Nginx HTTP'

2. Install MySQL On Ubuntu 18.04 LTS

sudo apt update

Then install the default mysql server package:

sudo apt install mysql-server

It will install mysql server in your Ubuntu system without any hassle but this method generally leaves your MySQL open to unauthorized access.

READ More Relevant Stuff:  Ubuntu Budgie 22.04 LTS Released

Let’s run the security script to make MySQL more secure:

sudo mysql_secure_installation

You will be asked to maintain various security option like password for root user. It will also asked you to remove some anonymous users and the test database, disable remote root logins, and more.

Now, In order to use a password to connect to MySQL as root, you need to chance its authentication method  to mysql_native_password from auth_socket.

To configure the root account to authenticate with a password, run the following command to MySQL prompt.

sudo mysql

In MySQL terminal run the following commands:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

Then, Now run the FLUSH PRIVILEGES

FLUSH PRIVILEGES;

Exit the MySQL shell:

mysql> exit

3. Install PHP

To install PHP, run the  following command:

$ sudo apt-get install php-fpm php-mysql

Check PHP-FPM service is running or not:

$ sudo systemctl status php7.2-fpm

As we have installed every required components, now its time to configure Nginx to use the PHP processor.

To do so, let’s open a new server block configuration file within the /etc/nginx/sites-available/ directory.

We will be using server block configuration file is named itsubuntu.comm,  which is a sample name and the name can be of your choice too:

sudo nano /etc/nginx/sites-available/example.com

Note: Most important thing is that we are editing the default server block configuration file.

Add the following content to new server block configuration file:

server {
        listen 80;
        root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name itsubuntu.com;

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }
}

Save and close the file.

READ More Relevant Stuff:  Ubuntu 21.04 Codename Is Hirsute Hippo

Enable new server block by creating a symbolic link:

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/

 

Now, reload the nginx

sudo systemctl reload nginx

Now create a test PHP file called info.php in your document root:

sudo nano /var/www/html/info.php

Type the following lines into the new file, save and close the file onward:

<?php
phpinfo();

Open your browser and visit the saved file or info.php

http://your_domain_or_IP/info.php

eg: http://localhost/info.php

You will see the PHP information page loading up.

It’s done now 😉

LEMP is installed.

Share this tutorial to Install Linux, Nginx, MySQL, PHP On Ubuntu 18.04 with your friends

Ubuntu Tags:LEMP, ubuntu

Post navigation

Previous Post: How To Install Moka Icon Theme In Linux
Next Post: Install Facebook Messenger On Ubuntu 22.04 LTS

Related Posts

Linux Kernel Update Major Linux Kernel Update for Ubuntu 18.04 LTS Is Out Now Ubuntu
Useful Multimedia Applications For Ubuntu 18.04 LTS Useful Multimedia Applications For Ubuntu 18.04 LTS Ubuntu
10 Best Linux Screen Recorder On Ubuntu For 2023 10 Best Linux Screen Recorder On Ubuntu For 2023 Ubuntu
Download Ubuntu 18.10 “Cosmic Cuttlefish” Beta Ubuntu
Ubuntu 21.04 Codename Is Hirsute Hippo Ubuntu
Best Download Managers For Ubuntu Operating System Best Download Managers For Ubuntu Operating System Ubuntu

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Enable Hibernate in Ubuntu 22.04 LTS May 20, 2024
  • Popular Ubuntu Games: Top 5 Games To Play March 17, 2024
  • WordPress | Your site doesn’t include support for the “generateblocks/container” block GenerateBlocks Plugin February 11, 2024
  • Ubuntu Autoremove Command Debian Autoremove Command February 10, 2024
  • How To Mount Windows 11 Shares on Debian Linux December 7, 2023
  • Anonymous Browsing 101: A Deep Dive Into Residential Proxies November 20, 2023
  • How To Correctly Install Uninstall Linux Ubuntu Nvidia Drivers Fast October 31, 2023
  • Ethical Web Design: The Dos and Don’ts October 28, 2023
  • Understanding the Role of Security Operations Center October 25, 2023
  • The Positive Effects of AI Tools and Online Services on Students Successful Essay-Writing Skills October 3, 2023
  • Linux Wget Examples September 27, 2023

Categories

  • Android
  • Apple
  • Blogs
  • Debian
  • Fix
  • Gadgets
  • Game
  • Google
  • How To Ubuntu
  • Internet
  • Laptops
  • Linux
  • Linux Commands
  • Linux Game
  • Linux Mint
  • News
  • Operating Systems
  • Security
  • Technology
  • Themes
  • Tools
  • Tutorials
  • Ubuntu
  • ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • Windows 11
  • Wordpress
  • Search Jobs
  • Post a Job
  • Job Dashboard
  • Contact Us
  • About US
  • Cookie Policy
  • Terms and Conditions
  • Privacy Policy
  • Sitemap
  • Write For US

Tags

android apps centos ChatGPT command Commands Debian deepin Desktop docker Fedora fix game games Gaming gnome google kernel linux linux commands linux kernel Linux laptops Linux Mint Linux themes minecraft NVIDIA Python Raspberry Pi sysadmin themes ubuntu ubuntu 18.04 Ubuntu 18.04 LTS Ubuntu 20.04 ubuntu 20.04 lts Ubuntu 22.04 LTS Ubuntu games Ubuntu kernel ubuntu themes ubuntu tutorial VirtualBox Windows Windows 11 Wine WSL
itsubuntu.com is an Equal Opportunity Employer. For Advertisement, Jobs, Guest posts, and any other thoughts, email us at [email protected]
  • TV Writer

    • New York, NY
    • SPECTRUM
    • Full Time
  • Technical Writer

    • Chantilly, Loudoun County, VA
    • ManTech
    • Full Time
  • Technical Documentation Specialist

    • Peoria, IL
    • EPITEC
    • Full Time
  • Technical Writer

    • Swiftwater, PA
    • Cynet Systems Inc.
    • Full Time
  • Senior Technical Writer

    • San Diego, CA
    • Compunnel Inc.
    • Full Time
  • Technical Writer

    • Crane, IN
    • Bowhead / UIC Technical Services
    • Full Time
  • Senior Data Scientist

    • Waltham, MA (Remote)
    • Global Partners LP
    • Full Time
  • Communications Writer

    • Lynchburg, VA
    • Patrick Henry Family Services Operations, Inc.
    • Full Time

Copyright © 2025 Technology News Information & Jobs.

Powered by PressBook Grid Blogs theme