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:
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:
It means php7.4-fpm work.
Comments
Post a Comment