Espressobin – install nginx and php

Espressobin is my new toy which eventually be my new bridge to the internet while it hosts my connected home. Eventually it will be hosting Home Assistant, OpenVPN and be the WLAN Access Point.

The Espressobin has all the “horse power” i need, it is equipped with 1 gigabyte of ram and a dual core ARM Cortex A53 processor with a clock speed up to 1.2GHz. Which will be plenty enough for my setup. Technical details about the Espressobin is available on their homepage: http://espressobin.net/tech-spec/

I have already installed ubuntu 16.04 on the Espressobin.

The first thing that i am aiming for is to create a graphical interface for the network setup using nginx and php. This guide shows how to install it on the espresso bin.

  1. First, do update and upgrade using apt:
    # apt update && apt upgrade
  2. Install nginx and php-cgi:
    # apt install nginx php-cgi
  3. Enable nginx during startup:
    # systemctl enable nginx
  4. Next edit /etc/nginx/sites-available/default:
    server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;
    index index.html index.htm index.nginx-debian.html;
    server_name _;
    location / {
    try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
    }

    Everything is default from the configuration file, only the php settings is new.
  5. Create init php-cgi init script  From: https://www.nginx.com/resources/wiki/start/topics/examples/fastcgiexample/ or copy/paste it from here: #!/bin/sh
    ### BEGIN INIT INFO
    # Provides: php-cgi
    # Required-Start:
    # Required-Stop:
    # Default-Start: 2 3 4 5
    # Default-Stop:
    # Short-Description: php-cgi daemon
    ### END INIT INFO
    BIND=127.0.0.1:9000
    USER=www-data
    PHP_FCGI_CHILDREN=15
    PHP_FCGI_MAX_REQUESTS=1000
    PHP_CGI=/usr/bin/php-cgi
    PHP_CGI_NAME=`basename $PHP_CGI`
    PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
    RETVAL=0
    start() {
    echo -n "Starting PHP FastCGI: "
    start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS
    RETVAL=$?
    echo "$PHP_CGI_NAME."
    }
    stop() {
    echo -n "Stopping PHP FastCGI: "
    killall -q -w -u $USER $PHP_CGI
    RETVAL=$?
    echo "$PHP_CGI_NAME."
    }
    case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    restart)
    stop
    start
    ;;
    *)
    echo "Usage: php-fastcgi {start|stop|restart}"
    exit 1
    ;;
    esac
    exit $RETVAL
  6. Paste the content into a file called: /etc/init.d/php-cgi
  7. Make it executable:
    # chmod +x /etc/init.d/php-cgi
  8. Create a symlink in runlevel 5:
    # cd /etc/rc5.d/ && ln -s ../init.d/php-cgi S01php-cgi
  9.  Update the rc-d script:
    update-rc.d php-cgi enable

Good to go! Nginx and php should now be successfully installed. Try rebooting to see if it works correctly!

Leave a Reply

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