Setting up an NGINX web server on a Raspberry Pi

-- PI Forum -- -- rtmp --

NGINX (pronounced engine x) is a popular lightweight web server application you can install on the Raspberry Pi to allow it to serve web pages.

Like Apache, NGINX can serve HTML files over HTTP, and with additional modules can serve dynamic web pages using scripting languages such as PHP.

Refresh database of available packages

            sudo apt update

Install NGINX

First install the nginx package by typing the following command in to the Terminal:

            sudo apt install nginx

and start the server with:

            sudo /etc/init.d/nginx start

Test the web server

By default, NGINX puts a test HTML file in the web folder. This default web page is served when you browse to http://localhost/ on the Pi itself, or (whatever the Pi's IP address is) from another computer on the network. To find the Pi's IP address, type hostname -I at the command line (or read more about finding your IP address).

                sudo systemctl restart nginx
                sudo service nginx restart
                sudo /etc/init.d/nginx restart

                sudo systemctl start nginx 
                sudo systemctl stop nginx 
                sudo systemctl restart nginx

                sudo service nginx start
                sudo service nginx stop
                sudo service nginx restart

                sudo /etc/init.d/nginx start
                sudo /etc/init.d/nginx stop
                sudo /etc/init.d/nginx restart

                sudo service status nginx   # status
                sudo systemctl status nginx

                sudo nginx -s reload
                sudo systemctl reload nginx
                sudo service nginx reload

                nginx -t -c /etc/nginx/nginx.conf  # to check config file ok?
                systemctl enable nginx             # to enable
                nginx -t                           # to check config ok?
                tail -f /var/log/nginx/error.log   # to see log 

                nano /etc/nginx/nginx.conf         # edit