IMG-LOGO
Home Course Install Linux, Nginx, MySQL, PHP on Ubuntu 20.04

Install Linux, Nginx, MySQL, PHP on Ubuntu 20.04

by MH RISHAD - 22 Apr 2022
IMG

Starting

The LEMP computer program stack could be a gather of computer program that can be utilized to serve energetic web pages and web applications composed in PHP. This is often an acronym that depicts a Linux working system, with an Nginx (articulated like “Engine-X”) web server. The backend information is put away within the MySQL database and the energetic

 preparing is dealt with by PHP. This direct illustrates how to introduce a LEMP stack on an Ubuntu 20.04 server. The Ubuntu working framework takes care of the primary necessity. We'll depict how to urge the rest of the components up and running.

Prerequisites In arrange to total this instructional exercise, you'll require get to to an Ubuntu 20.04 server as a standard, non-root sudo client, and a firewall empowered on your server. To set this up, you'll be able take after our introductory server setup direct for Ubuntu 20.04.

Step 1 – Introducing the Nginx Web Server

Since this is our first time using apt for this session, start off by updating your server’s package index. Following that, you can use apt install to get Nginx installed:

 

sudo apt update

sudo apt install nginx

To check which UFW profiles are available, run:

sudo ufw app list

 

Enable this by typing:

 

sudo ufw allow 'Nginx HTTP'

 

sudo ufw status

 

If you do not have a domain name pointed at your server and you do not know your server’s public IP address, you can find it by running the following command:

 

ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

 

Browse in this address : http://server_domain_or_IP

 

Step 2 — Installing MySQL

 

 install this software:

 

sudo apt install mysql-server

 

Start the interactive script by running:

sudo mysql_secure_installation

 

When you’re finished, test if you’re able to log in to the MySQL console by typing:

 

sudo mysql

 

To exit the MySQL console, type:

 

Step 3 – Installing PHP

 

To install the php-fpm and php-mysql packages, run:

sudo apt install php-fpm php-mysql

 

Step 4 — Configuring Nginx to Use the PHP Processor

 

Create the root web directory for your_domain as follows:

 

sudo mkdir /var/www/your_domain

 

sudo chown -R $USER:$USER /var/www/your_domain

 

sudo nano /etc/nginx/sites-available/your_domain

 

Activate your configuration by linking to the config file from Nginx’s sites-enabled directory:

sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/

 

Then, unlink the default configuration file from the /sites-enabled/ directory:

sudo unlink /etc/nginx/sites-enabled/default

 

You can test your configuration for syntax errors by typing:

sudo nginx -t

 

When you are ready, reload Nginx to apply the changes:

sudo systemctl reload nginx

 

Create an index.html file in that location so that we can test that your new server block works as expected:

nano /var/www/your_domain/index.html

http://server_domain_or_IP

 

Next Testing PHP with Nginx

Share:

Leave a Comment

Required fields are marked *