How to install Nginx web server on a Raspberry Pi using sources

For a long time Apache has been the software choice for admins and developers wishing to setup a web server. It is therefore no surprise, that Apache dominates when it comes to the most deployed web server on the Internet today. Take a look at Netcraft’s survey as of January 2015.

I have used Apache since the early days of the Internet, but lately, I’ve noticed its become very bloated. In fact for any embedded developers out there, Apache is these days frown upon, when it comes to arm based devices such as the Raspberry Pi. Here is where Nginx comes in. It is very light weight and fast, and can easily be installed in your embedded and other web server projects. Try it, and you may find yourself liking it so much, that you’ll switch from running Apache in your enterprise or hosting environment.

Nginx is an open source high performance HTTP and reverse proxy server. It is very scalable and very suitable for production environments that need to serve many requests. Compared to Apache, Nginx handles requests using an asynchronous event-driven approach. Apache uses a process/thread oriented approach which makes it unpredictable when it comes to very high loads.

While installation via packages managers such as yum or apt is possible, I chose to install Nginx on a Raspberry Pi using sources. Going the source-install route has some benefits, one of which is that you get the latest version of Nginx, which usually takes sometime to make its way to distribution package repositories. Lets get started with the install.

Download sources:

cd /tmp

wget -c

tar zxvf /tmp/nginx-1.7.10.tar.gz -C /usr/src

cd /usr/src/nginx-1.7.10

./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --with-perl_modules_path=/usr/lib/perl5/auto/nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/ --lock-path=/var/run/lock/subsys/nginx --user=nginx --group=nginx --with-http_addition_module --with-http_auth_request_module --with-http_degradation_module --with-http_perl_module --with-http_flv_module --with-http_geoip_module --with-google_perftools_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_image_filter_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module --with-http_xslt_module --with-file-aio --with-ipv6 --with-mail --with-mail_ssl_module --with-ld-opt="-Wl,-E"

Notice that I added several optional modules, which means any dependencies need to be resolved before you proceed. You can read about built-in and optional modules at: On Fedora 20 I ran into errors starting nginx, so I added the configure option –with-ld-opt=”-Wl,-E” to resolve it

make && make install

Create the server user and group:

On Red Hat based systems like Fedora, run the following command to add a user and group for the webserver:

useradd -M -r -c "Nginx Web Server" -s /sbin/nologin -d /var/spool/nginx nginx

Setup directory permissions:

Give nginx user the permission to use directories

chown -R nginx:nginx /usr/share/nginx

chown -R nginx:nginx /var/log/nginx

Add the start up script

In order to automatically start nginx at boot time, you will need to setup an init script. Luckily, the folks over at Nginx have put together several star/stop scripts depending on your Linux distribution. You can collect them at:

Since Am using Fedora and hence systemd, the following is the start up script:

Description=The nginx HTTP and reverse proxy server

ExecStartPre=/usr/sbin/nginx -t
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID


Save this file at: /usr/lib/systemd/system/nginx.service.

Enable it to start automatically at boot.

systemctl enable nginx.service.


Start Nginx:

systemctl start nginx.service

check to see if Nginx is listening on port 80

lsof -i :80 (You need the package lsof, if not use netstat)

Open your browser and go to:

You will be greeted by a welcome HTML page.

That’s it for now. Next time, I will take a look at how to configure Nginx, and even enable PHP, so you can install most Content Management Systems (CMS) like wordpress on your web server easily.

How to Migrate to Digital TV in Uganda – A consumer’s Experience

Are you still puzzled by Digital TV Migration? Are you wondering how to start watching Free-to-Air DTV broadcasts in your area? Help is here inform of a consumer’s experience. Julian Mwine has put together a seven minute video, explaining the process involved in migrating to Digital TV in Uganda. Keep in mind, despite the deadline being 4 months away, we are still in early stages.

Connect to 3G networks in Uganda using the Linux command line

If you are a Linux user living in Uganda and use 3G internet, you may want to try out my tools to connect to the Internet. These are a couple of scripts I created a while back, however, I’ve now updated them to allow for the following:

  • You can now connect to Airtel, Orange/Africell, MTN, UTL, and Smart telecom.
  • I have added the capability to use your PC (or device such as a raspberry Pi) as a router, this way several devices can access the Internet using one 3g dongle. You can create a MiFI of sorts if you’re inclined to.
  • Query your modems for: EMEI, Serial, IMSI numbers, Lock status, Model/firmware version, etc.
  • A few BUG fixes and script clean ups.

Want to try it out? Visit my Github repository

How to stream FM Radio using the Command Line in Linux

With all the advancements in IT, one piece of technology has persisted and seems not ready to die yet: FM radio. Unlike its companion AM, FM radio continues to be the primary source of information and entertainment. For example, in the United States, FM radio is still alive, and is used by many as a discovery medium. Most people especially teenagers will tell you that they first heard a song on terrestrial FM radio, before they went on to streaming sites such as YouTube, Spotify etc. In Uganda, like elsewhere in Africa, expect traditional FM radio to continue being king of information. Our limited Internet infrastructure is still very limited to a small section of the population, speeds are still horrible, so on-line radio is still not an option for many.

As I work on my upcoming digital product, I debated a lot about whether to include FM radio as a feature on this device. With all the above said, there was no doubt, FM radio would quickly become one of the most requested for features. So I got down to playing, recording, and streaming Live FM radio using the Linux command line. The cool bit is that you can stream a live FM radio show to all your devices in the house or office. No need for you to buy a radio.

What you need:

a) Analog Video for Linux (V4L2) FM radio tuner. You can either use a USB stick or PCI-E based card.

b) Linux distribution – Am using Fedora 20. But any Linux distro will work, although you will need to adjust the install commands where necessary.

Available Linux CLI tools:

There are a whole lot of GUI based applications that you can use to play radio in Linux, For example Gnomeradio, Kradio, gradio etc. However, using the command line gives you much more flexibility, as the following commands illustrate. You can control an FM radio tuner using CLI tools like MPlayer (which is installed on most Linux distros), ivtv-radio, and fmtools. In this ‘how to,’ I use the latter, fmtools, which comes with a set of tools (fm and fmscan) for controlling V4l2 based tuners.


1. Install fmtools

yum install fmtools (On Red-Hat based Distros such as Fedora, CentOS)

2. Install SoX

yum install sox (On Red-Hat based Distros such as Fedora, CentOS)

3. Install VLC

yum install vlc (On Red-Hat based Distros such as Fedora, CentOS)

FM Radio Commands

The basic arguments for the fm command line tool are:

fm -d [device] -T [time] [freq] [on|off] [percentage]

-d The radio device created by your USB or PCI based tuner
-T The duration of play
-q quiet | No verbose
[Freq] The radio channel
[on|off] Turn on or mute radio
[Volume] The desired volume

Tune and play FM 91.3

fm -q -d /dev/radio0 -T forever 91.3 100%


fm -q -d /dev/radio0 off


fm -q -d /dev/radio0 on

Recording FM Radio

To record FM radio, use parec a utility that is packaged with pulseaudio, the default sound subsystem on most Linux distros.

1. First tune to the desired radio station as shown above.

2. Capture the audio:

parec -d alsa_output.pci-0000_01_01.0.analog-stereo.monitor | sox -t raw -r 43000 -e signed -L -b 16 -c 2 - /var/tmp/fmradio.wav

NOTE: You will need to change the variable -d i.e. output pulse device for your system. To find yours, just run the command:

pactl list | grep -A2 '^Source #' | grep 'Name: .*\.monitor$' | awk '{print $NF}' | tail -1

The recording will be stored at /var/tmp/fmradio.wav. You can change that to another location if you wish.

Stream FM Radio to other PCs or devices (such as smart phones)

Start the capture process as shown above, and proceed immediately to the stream command below:

vlc -I dummy -I http --daemon --no-video --no-sout-display-video --verbose 2 /var/tmp/fmradio.wav --sout #duplicate{dst=standard{access=http,mux=asf{title='JambulaRadio',author=FM-91.3-Radio-Kampala(Uganda),copyright=2015-2016-Joseph-Zikusooka-All-rights-reserved,comment=Broadcasting-Live-from-Kampala-Uganda,rating=PG14},dst=},dst=standard{access=http,mux=asf{title='FM-Radio',author=FM-91.3-Radio-Kampala(Uganda),copyright=2015-2016-Joseph-Zikusooka-All-rights-reserved,comment=Broadcasting-Live-from-Kampala-Uganda,rating=PG14},dst=}"}

NOTE: Here, I’m streaming on both wired and wireless LAN, and my machine IP addresses are, and respectively. The http stream port is 8080. Change these to suit your environment.

If you are using a wired connection, use VLC on your client PC or mobile phone to access the stream as follows:


If on Wireless, use vlc on your client PC or mobile phone to access the stream as follows:



Uganda’s digital TV Migration – A status update

With only 5 months left before the international deadline for analogue TV switch off, here is where Uganda stands in the move from analogue to digital TV broadcasting.

As of January 2015, the following areas have access to the Over-the-Air digital TV signal: Kampala, Entebbe, Bombo, and Mityana. Basically only a small part of central Uganda is covered. Also DVB-T tuner tests indicate that depending on your location, you may still not be able to access the DTV signal which is being transmitted from Kololo. For example in areas East of Naalya an Outdoor Antenna may be required.

Also, only a few TV stations are currently broadcasting in Digital TV. For example,
NTV Uganda, Bukedde TV 1, WBS TV, Urban TV, UBC etc. For a specific status on each of the local TV channels, take a look at the Digital TV Migration Status page

With regards to equipment, some merchants in Kampala have already started to sell analogue-to-digital TV converter boxes, which is what the majority of household with require. However, at prices of up to 150,000/=, this might still be prohibitive for the majority of homes in the country.

With the the looming deadline, Uganda Communications Commission (UCC), has promised to start rolling out Digital transmission to other areas of Uganda. We look forward to that.

Getting started with Docker on Linux

Docker containers are all the rage these days. However, if you’ve used Linux for a while you’ve come across LXC. For FreeBSDĀ users, docker containers will remind you of jails. Docker is essentially the same, but with a better tool chain that makes it easy to build system images and move them around different environments. Docker is also lightweight and very fast when compared to LXC for example.

With traditional office servers increasingly being moved to the cloud, it is easy to see why docker is popular. The ability to deploy and scale easily, makes docker a must-learn tool for IT administrators.

Here are a few notes to get you started with docker. For a detailed instructions, see the official docker user guide.

Getting started with docker

Install docker
yum install docker-io
(On Red Hat based systems)

Start the docker service
systemctl start docker

Pull docker image from the repository
docker pull fedora
(Ensure your Internet speed can handle the size of this image)

List all images available
docker images

Run docker image (interactive mode)
docker run -i -t fedora /bin/bash
(Type exit, to get out and leave container running)

Show containers current running
docker ps

To reconnect to the docker instance after exiting:
docker attach [CONTAINER ID]

To start an existing docker container:
docker start [CONTAINER ID]

To stop a docker container
docker stop

How to ship your first container
Reconnect to the container as shown above.

Show all the changes that were made since initial creation
docker diff [CONTAINER ID]

Commit your changes
docker commit [CONTAINER ID] [TAG]

Then to see the newly created image, run
docker images

You can now share your image. Please note that for the public docker repository, you need to follow the proper naming conventions when picking a tag for your image. Then push the image as follows:
docker push [USERNAME]/[TAG]

As you begin to create images using docker, you may want to read documentation on dockerfiles and how to use them to quickly deploy your containers.

Toggle between two or more Digital TV channels that are simultaneously playing

With the advent of Over-the-Air (OTA) Digital TV in Uganda, I have found myself watching two or more TV channels simultaneously. This is true especially during the 9 O’clock hour when most local TV stations in Uganda broadcast the evening news (OK, now you know: I am a news junkie).

While recording TV shows solves this itch as is the case with an upcoming media product I have been working on, it is still great to watch the news live. You could manually mute a currently audible TV channel, and unmute the next desired one – but that’s no fun.

A while back, I whipped up a script that helps you toggle between all the available audio sources you are listening to. It essentially switches between all the available sound sinks. In my case, I use VLC to watch OTA digital channels with podcasts on some occasions. What is neat, is that you can bind this script to any key on your keyboard, remote, or even Bluetooth device.

If you are using a Linux based device and you are interested, I am making this tool available at: my Github repository

Customize your Linux desktop using the command line

With most Linux distros now using GNOME 3.10+, here are a few commands on changing the look and feel of your desktop using gsettings. Other CLI methods exist such as the popular GNOME tweak tool and Dconf.

Add apps to favorites bar
$ gsettings set favorite-apps "['google-chrome.desktop', 'evolution.desktop', 'nautilus.desktop', 'libreoffice-writer.desktop', 'libreoffice-calc.desktop', 'firefox.desktop', 'gnome-terminal.desktop', 'vlc.desktop', 'jitsi.desktop', 'gedit.desktop', 'gcalctool.desktop']"

Change show date and clock format
$ gsettings set org.gnome.desktop.interface clock-show-date true
gsettings set org.gnome.desktop.interface clock-format '12h'

Change background picture
$ gsettings set org.gnome.desktop.background picture-uri 'file:///usr/share/backgrounds/gnome/Sandstone.jpg'

Those are just but a few of the settings available for you to tweak. To see all of them, type:
$ gsettings list-keys .

Easily convert from VirtualBox to KVM in Linux

I have been converting some of my old VirtualBox images to KVM, which is the virtualization standard in Linux.

Its really easy, although, if you run into booting issues of the converted image, the last tip here will save you some time.

To convert from VirtualBox to KVM, look for your VDI images.

qemu-img convert -f vdi -O qcow2 [VBOX-IMAGE.vdi] [KVM-IMAGE.qcow2]

e.g. qemu-img convert -f vdi -O qcow2 FreeBSD-7.2.vdi FreeBSD-7.2.qcow2

You can now import the converted image using virt-manager or the CLI tool virt-install.

In Virtual Machine Manager, go to Disk 1 >> Advanced options and change ‘Storage format’ to qcow2.

This prevents boot errors like ‘boot failed: not a bootable disk’ when you launch the VM.

WebRTC – Why Skype will become less dominant

If you know me, then you know that am not much of a Skype fan. If I have to make Internet based calls, my go to app is Jitsi, which uses my own managed Asterisk server as its proxy. Asterisk allows for all types of calls including SIP-to-SIP, and international calls terminated by regular phones.

But that’s me. For most people Skype is the dominant app for Internet calls. So when people ask me whether I am on Skype, my answer in most cases is ambivalent. While I have a Skype ID, I rarely use it. Why you ask? It is a long story. Really – its a long story. Bottom line, I no longer use Microsoft software, and most of my work is done using open source software.

It is important to note that Skype data and calls are handled via proprietary channels and routed to servers we really don’t know about. Also, keep in mind that while it might not matter to you, Skype has become a surveillance tool for many Governments. Take a look at this article. And yes, the NSA is also in on it.

Google Hangouts

The current popular alternative to Skype is Google Hangouts. Hangouts is really good and does a good job when you need to do one-to-one voice and video calls, and even conferencing. The only requirement is that all the participants must be signed into the Google ecosystem. The latter statement kind of points to why, I still have a hard time using Hangouts. What’s the problem, you may ask? Well, for one, you are still tied to Google’s infrastructure. Just like the Skype situation, all calls go via Google’s servers. Also, Google has a very terrible record of axing services – Take the example of Google Reader, Google Buzz/Wave, Google Voice’s XMPP implementation to name but a few.

Open source VoIP software

Currently, there’s no open source software that perfectly replaces Skype. OK, may be it exists, but may not be as simple to use as Skype. In the open source world, traditionally, you’d use PBX systems such as Asterisk (See my previous article on setting up asterisk). These servers would bridge internal and external calls.

The problem though is that most networks are heavily militarized (i.e. firewalls) – Most block the commonly used Voice over IP (VoIP) protocol of SIP. So if I have to setup a video or voice conference for four company users, assuming two are in Nairobi, and the other two are in Kampala, I would have to ensure that the company’s PBX server they will use to connect is on a network that has SIP ports open. For a techie, this is not hard to setup, as you only need to ensure that port forwarding for VoIP services is enabled. However, this process tends to be cumbersome.

The other hurdle is that the four users each have to install a SIP client on their PCs (in case they are not using hard phones). Skype solves this issue, by simply having users install from a central repository, and then users sign up all in one place. In the open source world, its not as simple as that, as users need to first pick a SIP client. Many examples exist, but my favorites are Jitsi and Linphone. Then, the server administrator needs to provide the users with a username/password or extension. Again, for the savvy, there are always ways to automate and make this simple, but not for the typical user.

I believe, this is why Skype has been the go to place for VoIP services. However, things are about to change with the recent introduction of a technology known as WebRTC

WebRTC – Real-Time communications


WebRTC, is a free and open source project that allows real time communication using web browsers. That’s right – You can now make calls using your web browser! It enables peer to peer audio, video and data communications between web browsers. Recent versions of Chrome, Firefox, and Opera now support WebRTC.

WebRTC solves the challenges of open platforms I mentioned above by allowing the web browser to act as a sip client during video and voice calls. In fact, the original server is needed only during the initialization stage, thereafter, the client browsers, will communicate with each other directly.
So here’s how it would work: My four users in Nairobi and Kampala would go to a website URL that I would send to them, and simply sign in and immediately start the conference. No drama, No fuss.

WebRTC, while a very young technology, promises to revolutionize the way we communicate. For one, the communication will no longer rely heavily on middle men.

It is now possible to have ‘Call or Chat with us’ links on web pages allowing for website visitors to directly talk to the web managers. Think of it as a kind of support desk.

WebRTC, also means users do not need to be bothered with installing software or plugins on their PCs or mobile devices in order to chat or talk. Just use the existing web browser where most users already spend most of their time on the Internet.

Of course, Skype will continue to be with us for some time, but the proliferation of mobile platforms will see more and more software vendors turn to WebRTC to do cool things on these devices.