This is the recommended sequence to get HSS up-and-running quickly and easily.
Please take the time to read the material on these website pages and to perform the
steps in the sequence 1 through to 4.
1. Requirements
This section explains about
networks, the extra nodes you need to install for Node-RED and some guidance on
cameras
that work well with HSS.
2. NGINX <<< You are here
This section explains how
to install NGINX, a web server, if you haven’t got one already running on your computer.
3.
Install
This section is a step-by-step guide for the installation sequence of
HSS (using the out-of-the box config file)
4. Config file
This section is a detailed
step-by-step guide, explaining how to customise HSS to accept your cameras, etc..
NGINX
This section is optional. If you already have Apache2 running as a server on
your computer and you are using it to serve web pages or other material, then you
can skip this section.
If you have Apache2 installed and you are NOT using it, then you might want to consider changing it for NGINX.
NGINX is a lightweight, high performance server ideally suited to tasks like handling requests from HSS.
If you decide to use NGINX, then you need you need to STOP Apache2 and DISABLE it.
Disable Apache2 and stop it from auto-starting at boot time.
sudo /etc/init.d/apache2 stop
sudo systemctl disable apache2
This gives you the option that you could restart Apache2 if in the future you wanted to revert back to using it.
Alternatively, you could change the port Apache2 is using to say 81 or 82 and let NGINX run on port 80.
If you really do want to REMOVE Apache2 then use the commands...
sudo apt-get purge apache2*
sudo apt-get autoremove
sudo rm -rf /etc/apache2
or
sudo apt-get --purge remove apache2
sudo apt-get autoremove
sudo rm -rf /etc/apache2
Installing NGINX
Step 1. Bring your Pi up-to-date.
sudo apt update
sudo apt full-upgrade
Step 2. Install NGINX and PHP.
sudo apt install nginx php-fpm php7.4-fpm php7.4-gd
sudo /etc/init.d/nginx start
Step 3. Check if NGNIX is running.
Go to your Pi's URL e.g. 192.168.1.152
You should see a web page saying... Apache2 Debian Default Page
Don't worry if it says Apache2 as this is just a default page.
Step 4. Enable PHP in NGINX.
cd /etc/nginx/sites-available
sudo nano default
Find the line that starts with index and change it to this...
index index.php index.html index.htm;
Scroll down further and remove the # characters in the location block so the lines looks like this...
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
Press Control and X and then Y (to save the edited file).
Step 5. Reload NGINX configuration file.
sudo /etc/init.d/nginx reload
Step 6. Test that PHP will interpret a PHP script by creating a new PHP script.
cd /var/www/html <<< It is assumed that this is the document_root as setup by NGINX
sudo nano info.php
<?php
echo phpinfo();
?>
Press Control and X and then Y (to save the edited file).
When you execute the file you have just created it will show the various parameters used by the web server
Step 7. Check if the server runs the PHP script you have just created.
Go to your Pi's URL e.g. 192.168.1.152/info.php
You should see a page listing all the parameters for the PHP interpreter and web server.
Step 8. Add the pi user to group labelled www-data
Note:
Replace <insert-user-name> with your user-name.
If you are logged-in with the
default user-name then it will be… pi
sudo usermod -a -G www-data <insert-user-name>
e.g. sudo usermod -a -G www-data pi
Step 9. Secure the area where the server will serve files.
sudo chown -R <insert-user-name>:www-data /var/www/html
e.g. sudo chown -R pi:www-data
/var/www/html
sudo chmod -R 775 /var/www/html
Step 10. Set-up NGINX so it auto-starts whenever the Pi is booted-up.
sudo systemctl enable nginx
sudo /etc/init.d/nginx restart
The next step is to get HSS (Node-RED flows) installed on your computer.
Go to… 3. Install