A quick script to build and deploy hugo site on VPS
I had been using GitHub and Netlify for this site but lack of some features such as access to server logs finally got too much. So I decided to move this blog to my VPS.
One thing I really love about using Github is CI/CD and Github Actions. But I wanted something even simpler with less dependencies. So I decided to use a simple bash script to build and deploy the site.
Here is the script:
#!/bin/bash git add . git commit -m "Commit before deployment" git push rm -rf public/ && hugo rsync -avz --verbose --delete public/ USER@HOST:/path/to/deploy/dir ssh USER@HOST << 'ENDSSH' chown -R USER:www-data /path/to/deploy/dir chmod -R 750 /path/to/deploy/dir ENDSSH
View server Logs
I am moving away from 3rd party analytics due to privacy concerns. But it is useful to know that people are visiting my site and what they are finding useful.So I use server logs to get this information.
First, make sure each virtual host has its own log file. Update your virtual host configuration file to include the following lines:
ErrorLog /var/log/apache2/example.com-error.log CustomLog /var/log/apache2/example.com-access.log combined
Then the simplest way to look at logs is to use GoAccess. I just view stats in terminal with:
goaccess access.log -c
It doesn’t keep history but it is good enough for me.