Introduction: Setting Up Raspberry PI As Webserver


Finally I have decided that sharing my collected notes and put it into
some readable format. Yes, the Raspberry PI craziness that nowdays sweep through the internet touched me as well. I could not just pass it and not get one. I have ordered the RPI Model-B rev-2 version with 512Mbyte of RAM, 4Gb SD card and passive coolers. Actually I wanted to use it as own webserver and creating a blog which running on the machine. Because I thought it would be cool sometimes use it to playing films just wanted to connect it to my Samsung TV through HDMI. Of course not to use it uncomfortable directly keyboard and mouses but get the X layout of RPI from remote desktop.

Motivation and decision

  • Small board, impressive, attractive and cheap computer
  • Hackable Linux based platform provided with ATM chipset
  • Low electricity consumption
  • Silent machine with possible passive cooler
  • Own webserver. It’s not on the other side of world holding a 3th party ownership
  • Mini file server for notes and not too large files
  • Reusable for several projects
  • Hardware and software in one hand

Step 1: Get Simple Box for RPI

I prefer the simple but clever solution. I was seeking something easily accessible box for RPI and surfed the web when I found a creative but easy solution: LEGO. On the net there are lot of cool skins for RPI but just spent some hours to looking for my old LEGO pieces and started to build it. The RPI board fits in a LEGO enclosured box with dimension of 9 x 13 blocks. Perfect. Because Raspberry PI is small still with the box, the best place was it to me put it behind the TV. It can be easily connected to TV through HDMI. Because the on the board there is not any cooling solution I have also bought a passive coolers which ones just had to stick on the chips. In the most RPI stores can be ordered a prepared package contains three passive coolers for every important chip on RPI board.

Step 2: Doing the Software Way..


There is a set of compatible operating system to RPI for different purposes. At first testing I have just installed the most popular Debian Wheezy system with X layout. Because it may exists better OS for my purposes (e.g. running only webserver I would use the faster Risc OS) but I didn't want to reinstall a new one so it remained. Download OS here and how-to burning the image on SD card can be found here:

Let's do the necessary settings, install the softwares and libraries.

  1. passwd # change password from 'pi'/'raspberry' to new one
  2. date +%T -s "20:58:00" # set time
  3. dpkg --get-selections # checking what we may need to have
  4. sudo apt-get update # get recommanded software updates
  5. sudo apt-get install xrdp # server for remote desktop protocol
  6. sudo apt-get remove nano # remove unnecessary sofwares ...
  7. sudo apt-get install vfstpd # secure and fast FTP server
  8. sudo vi /etc/bash.bashrc # write psg="ps -aux | grep" to use psg alias
  9. !FTP 550 permission upload # problem solving
  10. !sudo vi /etc/vtftpsd.conf
  11. !sudo service vsftpd restart

Use this one to know what happens on RPI because the programs are installed here
logging in this file.

  1. tail -f /var/log/messages # always checking knowing problems

VNC Installation

Installing Virtual Network Computing program (VNC) to handle RPI from remote.

  1. sudo apt-get install tightvncserver # get the VNC server to get new X displays
  2. !vncserver :1 -geometry 1280x800 -depth 16 -pixelformat rgb565: # start
  3. !sudo chown pi /home/pi/.Xauthority # problem solving
  4. !vncpasswd view-pass NONONO # recover password
  5. sudo apt-get install x11vnc # get the real X displays
  6. !startx& # start X desktop
  7. !vncserver # start VNC
  8. !x11vnc # start X11VNC
  9. !# From now you can connect with vncviewer on 0 display to get real RPI display

Pendrive topics

Testing pendrive. I had no problem the automount worked well on X display and the a folder came up.

  1. /kernel/sda/sda1 # the path of automounted pendrive

NGINX Webserver

On the net there is a lot of available webserver on different size and for different purposes. Because of RPI is not made of running heavy webservers I wanted to spare with the load and space (my SD card is only 4GB). And earlier I have decided that I want to create so kind of blog that does not need database and as it possible it avoids the dynamically elements. Decision to lightweight webservers. Comparsion of lightweight webservers. Here you can find a cool analysation of lightweight webservers:

May it recommended from RPI community? Nginx (6,2000Kb on my SD card).

  1. sudo apt-get install nginx # get nginx webserver
  2. sudo useradd www-data # user grant to user of webserver(s)
  3. sudo groupadd www-data # group grant to user of webserver(s)
  4. sudo usermod -g www-data www-data # changing user group of user
  5. !/usr/share/nginx/www/ # path to put the pages

Mplayer, settings sound

Playing films and music or just listening to radio, do the compulsory settings.

  1. sudo apt-get update
    sudo apt-get upgrade
  2. sudo apt-get install mplayer mplayer-gui alsa-base alsa-utils pulseaudio mpg123
  3. sudo usermod -aG video pi
  4. sudo amixer cset numid=3 #
  5. mplayer -fs xy.avi # fullscreen mplayer from consol
  6. mplayer -ao alsa -playlist "" # FM online radio

Step 3: Blogging Motor


On this section I don’t want to waste the time to reason why it’s good keeping the things as simple as possible but one of the possible way to do it with static blog generator. My requirement was a quite high performance blog platform, track content changes easily, writing posts (using Markdown), publish them in easy format but still holding posts in logic structure like a blog. I wanted to eliminate the complex and large webservers (as I did it with nginx) so being on this way wanted to do it with blogging method as well. There is no need dynamic websites, frameworks systems (CMS), database request and other overheads, instead of them just using static HTML pages.

The other reason is when once I would like to move on or whatever editing the contain I just simple handle it. No database requests from several tables, no different technology chaos to put the contain in readable format, no dynamic pages, no annoying porting necessaries. Small size, python script, more than enough to my purposes. A simpatic static generator: Mynt. Mynt supports custom date, tag-based archives, Markdown posts, Jinja templates and YAML front matter.

First I had some problem with different mynt versions and got python compile errors. Because I could not find the solution on forums, in IRC channel Anomareh the developer of mynt helped me to fix it. I was using mynt 0.2.2 instead of 0.2.3 with jinja 2.7.

  1. sudo apt-get install nedit # get text editor with highlightings
  2. sudo apt-get install git sudo apt-get
  3. install python-dev sudo apt-get
  4. install python-pip sudo pip
  5. install mynt # get static site generator

Static address for global access

Okey! We got webserver, blogging platform and so static HTML pages. Open
the door and make it available from internet. If you want to use free DNS, register at on of the free dynamic DNS service and get a simpatic domain name. I’ve used this one:

Install ddclient client used to update dynamic DNS entries for accounts on Dynamic DNS Network Services' free DNS service. When it is done and the settings are correct, go to settings menu of your router (e.g: and create an open port (do port forwarding) that allow a connection in to your home network from the Internet. To get to know your external IP and port using RPI, here is a site (port 80 for webserver).

More details about the port forwarding at specific router check this site.

  1. sudo apt-get install ddclient # get ddclient
  2. sudo vi /etc/ddclient.conf # protocol=dyndns1,, login and password
  3. sudo vi /etc/default/ddclient # run_deamon="true", run_ipup="true"

Commands make sense

Some commands I was using during the installation process, they may be helpful.

  1. mynt --version # current version of mynt
  2. mynt init ~/src # initializing new site
  3. mynt watch -f src/ res/ # automatic regeneration after site modification
  4. du -ch # current files total in readble format (Kb, Mb, etc.)
  5. df -h # filesystem disk space usage in readable format
  6. shutdown -r now # restart rpi
  7. shutdown -h now # halt rpi
  8. /opt/vc/bin/vcgencmd measure_temp # GPU temperatur
  9. /sys/class/thermal/thermal_zone0/temp # CPU temperatur (is the first two digit)
  10. sudo apt-get install vnstat # network traffic,
  11. vnstat --dumpdb
  12. sudo cat /var/log/nginx/access.log # nginx log about visitors
  13. netstat -t -u # TCP and UDP connections

Step 4: Experience

My RPI had been ran for 15 months without problems. Sometime I’ve checked and cleaned the dust around the box that was until now the maintenance. The webserver is also working well but of course it is not sized to heavy-load. I think to get the passive coolers was also a good idea. Sometime I’ve checked the temperature of chips (or just touched them with finger) and after a film watching, of course an active using it was really hot with the passive coolers as well. What’s else would be without them?!

To powering RPI I use a typical Samsung charger and had never problem with that. (On forums it can be read about some cheap and after made charger which is not working appropriate e.g.: problems reading pendrive or not powering the RPI.)

Websites: /

Microcontroller Contest 2017

Participated in the
Microcontroller Contest 2017