在raspbian buster上部署LNMP环境和pi-dashboard

树莓派 | 本篇文章共522字,预计阅读2分钟

本文转自 RaspiSQH 的博客

前言

Raspbian Buster用 PHP7.1(2,3) 替代了 PHP7.0,有很多群友说找不到软件包了。因此我来介绍如何用在树莓派上部署新的 LNMP 环境(PHP7.3),并部署好 Pi Dashboard 的方法。下面假设你已经刷好了 Raspbian Buster 系统。最好是把apt软件源也换过了。

安装 Nginx 和 PHP7

安装软件包

在 Pi 的终端运行以下命令。

1
2
3
4
sudo apt-get update
sudo apt-get install nginx php7.3-fpm php7.3-cli php7.3-curl php7.3-gd php7.3-cgi
sudo service nginx start
sudo service php7.3-fpm restart

如果安装成功,可通过 http://树莓派IP/ 访问到 Nginx 的默认页。Nginx 的根目录在 /var/www/html

让 Nginx 能处理 PHP

sudo nano /etc/nginx/sites-available/default
将其中的如下内容

1
2
3
4
5
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}

替换为

1
2
3
4
5
6
7
8
9
10
location / {
index index.html index.htm index.php default.html default.htm default.php;
}

location ~\.php$ {
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

Ctrl + O 保存再 Ctrl + X 退出。
sudo service nginx restart
最后重启 Nginx 即可,以上步骤在树莓派3B + Raspbian Buster 系统版本上测试通过。4B也可以用的,别瞎想了。不能用一定是因为你漏掉了什么,再仔细检查一下。

安装配置MySQL

安装软件包

sudo apt-get install mariadb-server-10.0 php3.7-mysql

更改密码

执行mysql

1
2
3
4
5
MariaDB [(none)]> use mysql;
MariaDB [mysql]> update user set plugin='mysql_native_password' where user='root';
MariaDB [mysql]> UPDATE user SET password=PASSWORD('你想要设定的密码') WHERE user='root';
MariaDB [mysql]> flush privileges;
MariaDB [mysql]> exit;

重启服务
service mysql restart
mysql配置就完成了。

Pi Dashboard 介绍

请移步项目主页:http://make.quwj.com/project/10

部署 Pi Dashboard

GitHub 部署

1
2
cd /var/www/html
sudo git clone https://github.com/spoonysonny/pi-dashboard.git

即可通过 http://树莓派IP/pi-dashboard 访问部署好了的 Pi Dashboard。

以上步骤在树莓派3B + Raspbian Buster 系统版本上测试通过,每条都亲自验证过。

本文评论请到
https://talk.quwj.com/topic/816

本文作者:Tony

本文链接: https://blog.iamsjy.com/2020/07/01/install_lnmp_on_raspbian_buster/

文章默认使用 CC BY-NC-SA 4.0 协议进行许可,使用时请注意遵守协议。

评论