1 Pi 仪表盘

官方安装教程:

https://make.quwj.com/project/10

2 安装依赖

  1. 安装PHP8.0
cloud@server:~ $ sudo apt -y install lsb-release apt-transport-https ca-certificates software-properties-common wget
cloud@server:~ $ sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
cloud@server:~ $ sudo echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
cloud@server:~ $ sudo apt update
cloud@server:~ $ sudo apt upgrade
cloud@server:~ $ apt search php8.0
cloud@server:~ $ sudo apt install php8.0 php8.0-fpm php8.0-cli php8.0-curl php8.0-gd php8.0-cgi php8.0-mysql
cloud@server:~ $ sudo service nginx start
cloud@server:~ $ sudo service php8.0-fpm restart
cloud@server:~ $ php -v

通过 http://树莓派IP 访问到 Nginx 的默认页/var/www/html下的内容

  1. 安装Nginx
cloud@server:~ $ sudo apt install -y nginx 
  1. 配置Nginx
cloud@server:~ $ cd /etc/nginx/sites-available
cloud@server:/etc/nginx/sites-available $ sudo vim default

将内容替换为

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html index.php;

    server_name _;

    location / {
    index  index.html index.htm index.php default.html default.htm default.php;
    }   

    location ~\.php$ {
    fastcgi_pass unix:/run/php/php8.0-fpm.sock;
    #fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }
}
  1. 重启Nginx
cloud@server:/etc/nginx/sites-available $ sudo service nginx restart

3 部署 Pi Dashboard

在 Nginx 目录中通过 GitHub 部署

  1. 安装 git 客户端
cloud@server:/etc/nginx/sites-available $ sudo apt install git
  1. 部署 Pi Dashboard
cloud@server:/etc/nginx/sites-available $ cd /var/www/html
cloud@server:/var/www/html $ sudo git clone https://github.com/nxez/pi-dashboard.git

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

实现效果:

pi.tangke8.com

(*)3. 若页面无法显示,可尝试在树莓派终端给源码添加运行权限,例上传之后的路径是 /var/www/html/pi-dashboard,则运行:

cloud@server:/var/www/html $ sudo chown -R www-data:www-data pi-dashboard