文章参考:https://www.jianshu.com/p/0af5389cdb37
一、安装php7.3
1.添加apt源:
sudo vim /etc/apt/sources.list.d/raspi.list
deb http://archive.raspberrypi.org/debian/ buster main
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
deb-src http://archive.raspberrypi.org/debian/ buster main
#deb http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui
#deb-src http://mirror.tuna.tsinghua.edu.cn/raspberrypi/ stretch main ui
deb http://mirrordirector.raspbian.org/raspbian/ buster main contrib non-free rpi
2.更新软件包列表
sudo apt-get update
3.安装php7.3
sudo apt install -y -t buster php7.3-fpm php7.3-curl php7.3-gd php7.3-intl php7.3-mbstring php7.3-mysql php7.3-imap php7.3-opcache php7.3-sqlite3 php7.3-xml php7.3-xmlrpc php7.3-zip
4.测试是否安装成功
pi@raspberrypi:/ $ php -v
PHP 7.3.14-1~deb10u1 (cli) (built: Feb 16 2020 15:07:23) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.14, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.14-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies
二、安装nginx
1.安装nginx
sudo apt-get install nginx
2.测试nginx是否正常运行
curl 127.0.0.1
3.配置nginx,使其能解析PHP
sudo vim /etc/nginx/sites-enabled/default
#在server内加入或修改以下字段
server {
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
}
#在改行后添加index.php
index index.html index.htm index.nginx-debian.html index.php;
4.重载nginx,不报错就可以正常使用
sudo nginx -s reload
5.测试是否可以解析PHP
sudo vim /var/www/html/index.php
<?php
echo time();
pi@raspberrypi:~ $ curl 127.0.0.7/index.php
1590822761pi@raspberrypi:~ $
三、安装Mariadb数据库
1.安装Mariadb
sudo apt-get install mariadb-server mariadb-client
2.初始化数据库
sudo mysql_secure_installation
根据提示输入yes或no以及管理员密码
3.登陆数据库
pi@raspberrypi:~ $ sudo mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 36
Server version: 10.3.22-MariaDB-0+deb10u1 Raspbian 10
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
四、安装pi-dashboard
1.在github首页直接搜索pi-dashboard
2.找到pi-dashboard并进入
3.复制文件链接地址
https://github.com/spoonysonny/pi-dashboard.git
4.下载至nginx中
pi@raspberrypi:~ $ cd /var/www/html/
pi@raspberrypi:/var/www/html $ git clone https://github.com/spoonysonny/pi-dashboard.git
5.在浏览器中输入:树莓派IP/pi-dashboard进行访问