pi-dashboard 测试
centos7 安装php7.3
yum install epel-release
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install yum-utils
yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xmll
systemctl enable php73-php-fpm
systemctl start php73-php-fpm
[root@localhost html]# php73 -v
PHP 7.3.22 (cli) (built: Sep 1 2020 09:44:58) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.22, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.22, Copyright (c) 1999-2018, by Zend Technologies
php-fpm 启动后,默认的服务端口号为9000端口。
[root@localhost php-fpm.d]# systemctl status php73-php-fpm
● php73-php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php73-php-fpm.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2020-09-27 02:50:10 EDT; 14min ago
Main PID: 10998 (php-fpm)
Status: "Processes active: 0, idle: 5, Requests: 10, slow: 0, Traffic: 0req/sec"
Tasks: 6
Memory: 21.7M
CGroup: /system.slice/php73-php-fpm.service
├─10998 php-fpm: master process (/etc/opt/remi/php73/php-fpm.conf)
├─10999 php-fpm: pool www
├─11000 php-fpm: pool www
├─11001 php-fpm: pool www
├─11002 php-fpm: pool www
└─11003 php-fpm: pool www
Sep 27 02:50:10 localhost.localdomain systemd[1]: Starting The PHP FastCGI Process Manager...
Sep 27 02:50:10 localhost.localdomain systemd[1]: Started The PHP FastCGI Process Manager.
查看 /etc/opt/remi/php73/php-fpm.conf
和 /etc/opt/remi/php73/php-fpm.d/www.conf
文件,发现是在 /etc/opt/remi/php73/php-fpm.d/www.conf
中对 php-fpm的服务端口进行配置的。
[root@localhost php-fpm.d]# cat /etc/opt/remi/php73/php-fpm.d/www.conf |grep 9000
listen = 127.0.0.1:9000
配置 nginx
编写 phpinfo() 测试文件
在 /usr/local/nginx/html/ 目录下,编写 phptest.php 文件 。
<?php
phpinfo()
?>
配置nginx
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
root /usr/local/nginx/html/;
location / {
#root html;
index index.html index.htm index.php default.html default.php;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
#root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# 注意一下 SCRIPT_FILENAME 这个参数的配置
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
启动 nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx-pidashboard.conf -s stop
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx-pidashboard.conf
在 centos7 上测试运行pi-dashboard
从 github 上面获取 pi-dashboard的源代码,pi-dashboard。
这是一个使用php编写的树莓派web监控平台,我们也可以将这套代码尝试着运行在x86的centos7上面,查看其前端web实现。
将github上下载的源代码全部拷贝到 /usr/local/nginx/html/
目录下。
修改 index.php 为 pi.php。
mv index.php pi.php
浏览器访问测试
部署完成后,整个目录文件如下所示。
[root@localhost html]# pwd
/usr/local/nginx/html
[root@localhost html]# tree
.
├── 50x.html
├── assets
│ ├── bootstrap.min.css
│ ├── bootstrap.min.js
│ ├── dashboard.js
│ ├── dashboard.min.js
│ ├── devices
│ │ └── raspberry-pi.png
│ ├── exporting.js
│ ├── highcharts.js
│ ├── highcharts-more.js
│ ├── jquery-3.1.1.min.js
│ ├── logo.png
│ └── solid-gauge.js
├── bigdata.html
├── device.php
├── favicon.ico
├── index.html
├── phptest.php
├── pi.php
├── subreq
└── subreqco
2 directories, 20 files
浏览器访问web路径 http://192.168.7.73/pi.php
,即可看到如下界面。