2016-12-2323 December 2016

I like to keep a local website for testing my blog changes before I push them to my public server. I have a local nginx running on my development machine which is configured to serve content through local.bipedalprogrammer.com. To get this working quickly you only need to add the following file at /etc/nginx/sites-available.

# Virtual Host configuration for example.com
server {
        listen 80;
        listen [::]:80;

        server_name local.bipedalprogrammer.com;

        root /var/www/local.bipedalprogrammer.com/html;
        index index.html;

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

You will need to create the new directory at /var/www/local.bipedalprogrammer.com/html and add an index.html for testing. Then create a symbolic link in the sites-enabled directory.

Create Directory and Enable Site
$ sudo  mkdir -p /var/www/local.bipedalprogrammer.com/html
$ sudo ln -s /etc/nginx/sites-enabled/local.bipedalprogrammer.com /etc/nginx/sites-available

I added an alias for local.bipedalprogrammer.com to my /etc/host file.

/etc/hosts       localhost local.bipedalprogrammer.com

Now restart the nginx service to enable these changes. Your default index.html should be rendered when the server restarts.

Restart server
$ sudo service nginx restart