Linux: How to build web server with LEMP stack on Ubuntu

Overview

LEMP is a group of software that can be used to serve dynamic web pages and web applications

The article was made on Ubuntu 18.04

How to configure

Install Linux

Install Nginx

  • To install Nginx, use the command
  • Allow traffic on port 80 with the command
  • Access the IP on the browser, we will see Nginx is installed

Install MySQL

  • To install MySQL, use the command
  • Check the MySQL status
  • Configure MySQL security, you will be asked to configure the VALIDATE PASSWORD COMPONENT, which is used to test password strength
cài đặt MySQL và tối ưu MySQL trên Ubuntu 20.04
  • Next you will be asked to set a password for the MySQL root user

Please set the password for root here

New password:

Re-enter new password:

  • Next comes the command to remove the anonymous user, the command to restrict the root user’s access to the local machine and the command to delete the test database. Choose Y for all answers

Remove anonymous users? y
Disallow root login remotely? y
Remove test database and access to it? y
Reload privilege tables now? y

  • To be able to use password to connect to MySQL as root, you will need to switch its authentication method from auth_socket to mysql_native_password

sudo mysql

ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;

FLUSH PRIVILEGES;

exit

  • Check the authentication method again

SELECT user,authentication_string,plugin,host FROM mysql.user;

Install PHP

Unlike Apache, Nginx does not have built-in support for handing PHP files. So we install a separate application to handle PHP files

  • Install module php-fpm and php-mysql
  • Check php version

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.