Install and configure Nginx/PHP/SQLite3
Considering that the performance of the Raspberry Pi is relatively weak, if you use MySQL or other databases, it will basically go down every day. Comprehensive consideration is still suitable for the configuration of Nginx + SQLite3. Of course, PHP is essential.
Install nginx:
sudo apt-get install nginx
Install SQLite3:
sudo apt-get install sqlite3
Install PHP (PHP7):
sudo apt-get install nginx php7.0-fpm php7.0-cli php7.0-curl php7.0-gd php7.0-mcrypt php7.0-cgi php7.0-sqlite php7.0-xml
Install PHP-APC optimization:
sudo apt-get install php-apc
After the installation is complete, start the configuration.
start configuration
Configure Nginx:
sudo nano /etc/nginx/nginx.conf
After opening, find the following location and modify it:
user www-data;
worker_processes 1; #修改这里
pid /var/run/nginx.pid;
events {
worker_connections 64; #修改这里
#multi_accept on;
}
Continue to find gzip backward, remove the previous comment and modify it as follows:
gzip on;
gzip_disable “msie6”;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
CTRL+O to save, CTRL+X to exit (it will be directly replaced by save and exit later)
Configure PHP:
sudo nano /etc/php/7.0/fpm/php.ini
After opening, find the following code and modify it:
; Maximum amount of memory a script may consume (128MB)
;http://php.net/memory-limit
memory_limit = 32M #修改这里
CTRL+O (save) CTRL+X (exit)
Configure PHP-FPM:
sudo nano /etc/php/7.0/fpm/php-fpm.conf
Find the code and modify it:
; The maximum number of processes FPM will fork. This has been design to control
; the global number of processes when using dynamic PM within a lot of pools.
; Use it with caution.
; Note: A value of 0 indicates no limit
; Default Value: 0
process.max = 4 #修改这里
Save and exit.
To configure the relevant configuration of the website, it is safer to back up a copy first:
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak
Modify the configuration file:
sudo nano /etc/nginx/sites-available/default
Put the following content in it:
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
Replace with:
location / {
index index.html index.htm index.php default.html default.htm default.php;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
location ~.php(/.*)*$ {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Save and exit.
After the modification is completed, test whether the PHP is working normally, please get iTunes immediately
sudo nano /var/www/html/index.php
The input content is as follows:
<?php
phpinfo();
?>
Restart nginx and PHP7-FPM
sudo /etc/init.d/nginx restart
sudo /etc/init.d/php7.0-fpm restart
Enter the Raspberry Pi IP address in the computer browser to check whether it is successful:
The following interface appears as success:
Deploy Pi Dashboard
Deploy with GitHub
cd /var/www/html
sudo git clone https://github.com/spoonysonny/pi-dashboard.git
You can http://树莓派IP/pi-dashboard
access the deployed Pi Dashboard through .
If the page cannot be displayed, you can try to add running permissions to the source code on the Raspberry Pi terminal, for example, if the path you uploaded is /var/www/html/pi-dashboard
, then run.
cd /var/www/html
sudo chown -R www-data pi-dashboard
After the build is complete, if you see an interface like this
It means that you have built it successfully, so use your dashboard to check the status of your Raspberry Pi.
However, if you have an interface like this
You can right-click to see that these css and js files are not found.
I have also tried many ways, but I still can't find these files, and I can't find relevant explanations when I search on the Internet. So,
I wrote all the css and js files into its index.php file.
You can click to download and use ftp to upload to /var/www/html
the directory to overwrite the previously downloaded files.
When such an interface appears, it means you are successful.