Installing Nginx + PHP7.0 + Pi Dashboard on Raspberry Pi

Installing Nginx + PHP7.0 + Pi Dashboard on Raspberry Pi

Previously, we introduced the method of “Setting up an LNMP environment on Raspberry Pi” and “Installing a dashboard to monitor the Raspberry Pi’s operating status”. Recently, users have reported that the latest version of the Raspberry Pi system can no longer find the PHP5 package. This is because the new version has replaced PHP5 with PHP7, and the configuration method for PHP-FPM under Nginx is slightly different from PHP5. Therefore, we plan to update this article “Installing Nginx + PHP7.0 + Pi Dashboard” to introduce how to deploy the new Nginx and PHP environment on Raspberry Pi and set up the Pi Dashboard. Below, it is assumed that you have already flashed the Raspbian Stretch system.

Installing Nginx and PHP7

Run the following commands in the Pi’s terminal.

sudo apt-get update
sudo apt-get install nginx php7.0-fpm php7.0-cli php7.0-curl php7.0-gd php7.0-mcrypt php7.0-cgi
sudo service nginx start
sudo service php7.0-fpm restart

If the installation is successful, you can access the default page of Nginx through http://RaspberryPiIP. The root directory of Nginx is /var/www/html. Perform the following operations to enable Nginx to process PHP.

sudo nano /etc/nginx/sites-available/default

Replace the following content

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

with

location / {
index  index.html index.htm index.php default.html default.htm default.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;
}

Press Ctrl + O to save and Ctrl + X to exit.

sudo service nginx restart

Finally, restart Nginx. The above steps have been tested on the Raspberry Pi 3B+ with the Raspbian Stretch system version.

Introduction to Pi Dashboard

Pi Dashboard is an open-source IoT device monitoring tool released by the Raspberry Pi Lab, currently primarily targeting the Raspberry Pi platform, but also compatible with other Raspberry Pi-like hardware products as much as possible. You only need to install the PHP server environment on the Raspberry Pi to easily deploy a Pi Dashboard, which allows you to monitor the status of the Raspberry Pi through a cool WebUI!

The monitoring projects currently included are:

  • Real-time data on CPU basic information, status, and usage rate

  • Real-time data on memory, cache, and SWAP partition usage

  • SD card (disk) usage status

  • Real-time load data

  • Implementation process data

  • Real-time data on network interfaces

  • Basic information such as Raspberry Pi IP, uptime, operating system, HOST, etc.

Project homepage: http://maker.quwj.com/project/10GitHub address: https://github.com/spoonysonny/pi-dashboard

Video Preview

Deploying Pi Dashboard

Here are two methods to deploy Pi Dashboard on Nginx.SFTP UploadDownload the source code of this project from GitHub. Use FTP software like FileZilla to upload the extracted directory to the Raspberry Pi’s /var/www/html directory. You can then access the deployed Pi Dashboard at http://RaspberryPiIP/pi-dashboard.

If the page does not display, you can try to add execution permissions to the source code in the Raspberry Pi terminal. For example, if the path after uploading is /var/www/html/pi-dashboard, run:

cd /var/www/html
sudo chown -R www-data pi-dashboard

GitHub DeploymentIf you are familiar with basic GitHub operations, it will be very convenient to download this project to the Pi via GitHub.

#If you have already installed the git client, you can skip the next line
sudo apt-get install git
cd /var/www/html
sudo git clone https://github.com/spoonysonny/pi-dashboard.git

You can access the deployed Pi Dashboard at http://RaspberryPiIP/pi-dashboard.

Similarly, if the page does not display, you can try to add execution permissions to the source code in the Raspberry Pi terminal. For example, if the path after uploading is /var/www/html/pi-dashboard, run:

cd /var/www/html
sudo chown -R www-data pi-dashboard

The above steps have been tested on the Raspberry Pi 3B+ with the Raspbian Stretch system version.

Common Questions about Pi Dashboard

Q: On which terminals can the Pi Dashboard’s WebUI be viewed? A: Any terminal with a browser can view it, whether it’s a computer, tablet, or smartphone on an internal or external network. The Pi Dashboard has a responsive layout for different devices and is well compatible with mobile browsing.

Q: What should I do if I can’t access it through the external IP? A: Many ISPs in China do not provide independent external IPs. You can use tools like Peanut Shell to achieve external access. For users who already have an independent external IP, try changing the Nginx server port from 80 to another port number, and then access it by adding the port number after the IP address. This is because ISPs in China generally block port 80.

Q: I have a domain name, how do I bind it to the Raspberry Pi? A: You can refer to the DNSPod dynamic IP resolution update program and the LNMP environment setup on Raspberry Pi. After pointing the domain name to the Raspberry Pi IP, you need to modify the servername in the Nginx site configuration to your domain name.

The resource links mentioned in the text can be viewed in the original article at the end.

Installing Nginx + PHP7.0 + Pi Dashboard on Raspberry Pi

More exciting content

Pi-Micro: A handheld computer made with Raspberry Pi Zero W

Comparative speed of Raspberry Pi IO operations in different languages

Building a low-cost VOIP server and phone system with Raspberry Pi

Implementing real-time face recognition with Raspberry Pi

Dingdong: An open-source Chinese smart speaker project based on Raspberry Pi

Creating an RTMP streaming server with Raspberry Pi, which can push to Douyu Live

Installing Nginx + PHP7.0 + Pi Dashboard on Raspberry Pi

Leave a Comment

Your email address will not be published. Required fields are marked *