LH
  • Projects
  • Build

Pi Zero W: Static Website Configuration

Here is how I configured a quick copy of my website for NGINX - I followed the guide by Joseph Gefroh.

On the Pi:

  • sudo mkdir /var/www/lyndonhill.com
  • cd /etc/nginx/sites-available
  • Create a file called lyndonhill.com as given below
server {
  listen 80 default_server;
  listen [::]:80 default_server;

  root /var/www/lyndonhill.com;

  index index.html;

  server_name lyndonhill.com www.lyndonhill.com;

  location / {
    try_files $uri $uri/ =404;
  }
}

We need to copy the website to the Pi now so on a computer that has a copy of the website,

  • cd website-folder
  • scp -r * <username>@<pi-IP-address>:/var/www/lyndonhill.com

Now to enable the site, so back on the Pi:

  • cd ../sites-enabled
  • ln -s ../sites-available/lyndonhill.com lyndonhill.com
  • rm default
  • sudo systemctl restart nginx

Note that we deleted the link to the default configuration because otherwise there would be a conflict as the above configuration listens on the same port as the default.

NGINX serving my site < Back