*If you already have a desktop GUI go ahead and skip this part.
sudo tasksel
The static website blog generator we’ll be using is called Jekyll go ahead and install that onto your machine. Be sure to have all your prerequisites:
sudo apt-get install ruby-full build-essential
Now, let us proceed to download jekyll:
gem install bundler jekyll
Having that installed we can create the static blog:
jekyll new myblog
*Feel free to remove “myblog” and call your site whatever.
With your newly created blog go ahead and change directories by typing the code below:
cd /home/YOUR-RASPBERRYPI-USERNAME/myblog/
go ahead and run this script: bundle exec jekyll serve
You now should now be able to visit http://localhost:4000
*You must visit the directory of your blog files to run jekyll serve
and only need to run bundle exec jekyll serve when first init the build of your jekyll blog.
Creating the Virtual Host on the raspberry pi
Now, lets get the server NGINX up and going. Go ahead and install sudo apt install nginx
The code below will make the link between your localhost and the Nginx server to be visible on port 80 or (http and https). Go create in your terminal sudo nano /etc/nginx/sites-available/jekyll.conf
*Feel free to name the file whatever you like. In the file called raspberrypistatic.conf write out the code below and save file: CTRL + X + CTRL + Y + ENTER
With the file now written, we’ll be creating a symbolic link between where the file was written to the “sites-enabled” directory.
sudo ln -s /etc/nginx/sites-available/jekyll.conf /etc/nginx/sites-enabled/
*This links it to "/etc/nginx/sites-enabled".
Starting the NGINX web server
run sudo nginx -t
If everything is a-okay let us restart the Nginx web server and run sudo systemctl reload nginx
Both nginx and jekyll remind me of a program I used to use back in the day called XAMPP. Ohh, the memories of creating local websites and server applications.
Installing the Cloudflared tunnel service
Now, login to use the service: cloudflared tunnel login
You’ll receive a message in your terminal with a cloudflare link; if it doesn’t open automatically go ahead and copy and paste the link into your browser to authenticate your tunnel. To do so you’re going to need to provide your login credentials for cloudflare.
Once you’ve logged onto cloudflare.com and authenticated with the cloudflare services you’ll receive a message in your terminal if you successfully logged in. Let’s create the tunnel: cloudflared tunnel create TUNNELNAME After running the above command, please copy & save the message of the ID given for the tunnel credentials for later use.
Now, we’re going to be creating a CNAME for the domain and linking it to the cloudflare tunnel.
cloudflared tunnel route dns TUNNELNAME DOMAINNAME.COM
If all goes well, you should receive a message in the terminal INF ADDED CNAME.
Forward the ports through the cloudflare tunnel: cloudflared tunnel run --url localhost:80 TUNNELNAME
You should get in terminal INF STARTING TUNNEL TUNNEL ID=XXXXXXX….. If all is working you should be able to visit your domain on the internet.
Sources:
pimylifeup.com/raspberry-pi-public-static-website
pimylifeup.com/raspberry-pi-cloudflare-tunnel/
selfhostedninja.com/jekyll-the-ultimate-guide-to-self-hosting/
pkg.cloudflare.com/index.html#debian-any
nginx.org/en/linux_packages.html
jekyllrb.com/docs/installation/other-linux/