Raspberry Pi learning (3) LNMP server configuration

1: Install Nginx;

sudo apt-get install nginx

If you need to uninstall:

sudo apt-get --purge remove nginx
sudo apt-get --purge remove nginx-common
sudo apt-get --purge remove nginx-core

2: Install PHP7 and plug-ins

sudo apt-get install php7.3
//安装插件,如果安装失败可能是版本不对,网上搜索下,安装最新的版本,更改命令的版本号就行了
sudo apt-get install php7.3-fpm
sudo apt-get install php7.3-mysql
sudo apt-get install php7.3-common

3. Install MYSQL (MariaDB)

sudo apt-get install mariadb-sever
sudo apt-get install mariadb-client

4. Configure Nginx

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

Find this part

Insert picture description here


and replace it with: note that the space must be typed correctly;

Insert picture description here


after finishing Ctrl+O, press Enter to save, Ctrl+X to exit;
5: restart the service

sudo /etc/init.d/nginx restart
sudo /etc/init.d/php7.3-fpm restart
上面这两个命令执行完都会出现【OK】;没有就出错,就是上面的配置文件改错了;
sudo service mysql restart
sudo service nginx restart

6: Perform Nginx and PHP testing
Authorization:

sudo chmod -R 777 /var
sudo chmod -R 777 /var/www/
sudo chmod -R 777 /var/www/html

Create a new file index.php under /var/www/html,
open and enter

<html>
	<head>
		<title>PHP测试</title>
	</head>
	<body>
		<?php echo '<p>Hello World</p>';?>
	</body>
</html>

Save and exit; delete the other two HTML files;
open the browser, enter the IP address of the Raspberry Pi, and press Enter;

Insert picture description here


if this appears, the test is successful;