Install LEMP on Ubuntu Linux(20.04)

Install Nginx

$ sudo apt update
$ sudo apt install nginx 
$ sudo service nginx start
   * Starting nginx nginx                                                  [ OK ]
 
Enter Ubuntu Linux ip in the browser for example http://192.168.1.18, and then:
nginx work
It means nginx is running.

Install MySQL

$ sudo apt install mysql-server
$ sudo service mysql start
$ sudo mysql_secure_installation

When prompted, type  y , and then ENTER.

Check MySQL:

$ sudo mysql
mysql>
Done. Then exit.
mysql > exit

Install PHP

$ sudo apt install php-fpm php-mysql

Configuring Nginx to Use the PHP Processor

 

PHP's configuration


$ sudo vim /etc/php/7.4/fpm/pool.d/www.conf 
 
Uncomment the line below, save and quit.
listen = /run/php/php7.4-fpm.sock

Nginx's configuration


$ sudo vim /etc/nginx/sites-enabled/default
 

Add index.php to  /var/www/html  folder.
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
 
Uncomment below fastcgi_pass should use the corresponding way with /etc/php/7.4/fpm/pool.d/www.conf:
location ~ \.php$ {   
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}

Restart nginx and php7.4-fpm

$ sudo service php7.4-fpm restart 
$ sudo service nginx restart

Check php.

Create a file /var/www/html/index.php as following:

<?php phpinfo();?>

If the page is as follows:

php_work

 

It means php7.4-fpm work.


 
 
 

Comments

Popular posts from this blog

BdsDex: failed to load Boot0001 "UEFI BHYVE SATA DISK BHYVE-OABE-20A5-E582" from PciRoot(0x0)/Pci (0x2, 0x0)/Stat(0x0,0xFFFF,0x0) : Not Found

How To Install Nginx, MySQL and PHP (FEMP) Stack on FreeBSD 13.0

Install samba on FreeBSD(on VMware Workstation) to share files with Window.