Categories

The Perfect Tools for the Linux Geek's Blog

Written by Guillermo Garron .
Date: 2011-08-29 07:50:00 -0400

You have decided it is time to start your blog, and you are not just any person. You are a Linux geek, so which is the best platform for your blog?

Before answering that question let’s consider these other things:

  • You want to be the owner of your content
  • You want your server be able to handle the load if a post of you get listed in /., Reddit or Hacker News.

Now, as we know, you are a Linux geek, you are not going to host your blog at posterous, tumblr or wordpress right? Of course not!.

You are going to host your own blog, in your own server, and you are not going to use Ubuntu, right? You are going to host your blog on Gentoo Linux.

I’m going too fast, let’s first mention all the tools your are going to use, and that way answer the question on the top of this post:

  1. Gentoo Linux
  2. Nginx
  3. Jekyll

Let’s start setting up your geeky blog platform.

  • Disclaimer: This is not going to be a full how-to and only guide -

First you’ll need to setup a Gentoo base system, as it is impossible to write a better guide to Gentoo than the official one, here is the link to Gentoo Handbook, once you have Gentoo installed, it is time to install Nginx.

First set the USE flags to use only what you’ll really need from Nginx

www-servers/nginx  http http-cache ipv6 pcre vim-syntax -aio -debug -libatomic -ssl nginx_modules_http_access nginx_modules_http_auth_basic anginx_modules_http_utoindex nginx_modules_http_browser nginx_modules_http_charset nginx_modules_http_empty_gif -nginx_modules_http_fastcgi nginx_modules_http_geo nginx_modules_http_gzip nginx_modules_http_limit_req nginx_modules_http_limit_zone map -nginx_modules_http_memcached nginx_modules_http_proxy nginx_modules_http_referer nginx_modules_http_rewrite -nginx_modules_http_scgi nginx_modules_http_split_clients -nginx_modules_http_ssi nginx_modules_http_upstream_ip_hash nginx_modules_http_userid nginx_modules_http_uwsgi -nginx_modules_http_addition -nginx_modules_http_cache_purge -nginx_modules_http_dav -nginx_modules_http_degradation -nginx_modules_http_ey_balancer -nginx_modules_http_flv -nginx_modules_http_geoip nginx_modules_http_gzip_static -nginx_modules_http_headers_more -nginx_modules_http_image_filter -nginx_modules_http_passenger -nginx_modules_http_perl -nginx_modules_http_push -nginx_modules_http_random_index -nginx_modules_http_realip -nginx_modules_http_secure_link -nginx_modules_http_slowfs_cache -nginx_modules_http_stub_status -nginx_modules_http_sub -nginx_modules_http_upload -nginx_modules_http_xslt -nginx_modules_mail_imap -nginx_modules_mail_pop3 -nginx_modules_mail_smtp

Now run:

emerge nginx

Now you have Nginx installed, let’s create the configuration file:

worker_processes  4; # Default 1
events {
worker_connections  512; # Default 1024
}
http {
include       mime.types;
default_type  application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"' ;
access_log /var/log/nginx/access.log main;

## Compression
gzip              on;
gzip_buffers      16 8k;
gzip_comp_level   5;
gzip_http_version 1.0;
gzip_min_length   1100;
gzip_types        text/plain text/css application/x-javascript;
gzip_vary         on;
gzip_static       on; #Needs compilation with gzip_static support
gzip_proxied      any;
gzip_disable      "MSIE [1-6]\.";
server {
listen [::]:80;
gzip on;
server_name site.com;
expires +1h;
access_log /var/log/nginx/access.log;
root /srv/http/nginx;
location / {
index index.html;
charset utf-8;
proxy_set_header Accept-Encoding "";
}
}
}

Now you have Nginx ready to host your site, let’s prepare Jekyll to help you generate your site. Follow this Jekyll installation guide, and you will be ready to start creating content.

I’m here assuming you will create your content on your own server using vim you are a Linux geek remember? So every time you create new content you can run this small script to have your site updated.

jekyll
sudo rsync -av --delete --size-only _site/ /srv/http/nginx/
sudo find /srv/http/nginx -name "*.css" -type f -exec /bin/sh -c "gzip -c '{}' > '{}.gz'" \;
sudo find /srv/http/nginx -name "*.html" -type f -exec /bin/sh -c "gzip -c '{}' > '{}.gz'" \;
sudo find /srv/http/nginx -name "*.js" -type f -exec /bin/sh -c "gzip -c '{}' > '{}.gz'" \;
  • The first line generates your site
  • The second line copy only the changed files to Nginx root folder.
  • The last three lines create gzipped copies of all compressible files.

We only update de changed files, because we need to keep the dates of the old ones, that way proxy servers around the world will help improve your site. You’ll also want to serve already gripped versions of your files.

If you need to learn about Jekyll, read the Jekyll’s wiki pages

permalink

If you enjoyed the article, please share it

twitter | facebook | google+ | linkedin | email | reddit