1. Fever RSS - Raspberry Pi

    With the pending demise of google reader I like many others began a search for a new RSS syncing service / solution. 

    I have always been intrigued by Fever but never took the plunge because it was just simply easier to stay with google. For the uninitiated, Fever requires you run your own server.

    As I started to think about using Fever as my new RSS service I wondered what the best hosting solution might be. I considered a hosting provider, hooking up an old loud PC, buying a mac mini…… All of those options just weren’t appealing. (cost, space, noise) 

    Enter the Raspberry Pi

    image

    Super cheap, super small and completely silent. Perfect! I had been pining for an excuse to get a Pi. This seemed like a great reason to grab one.

    As I began researching the Pi as a webserver I came across a bevy of tutorials but nothing specific and detailed for setting one up for Fever. 

    Below are the steps I took to get my own Fever installation on a Raspberry Pi home webserver. Hit me up on twitter if you stumble upon this and have questions.

    —Fair warning this is kind of a long post.—

     ____

    Step 1: Buy a Pi!

    I purchased mine through reseller MCM Electronics http://www.mcmelectronics.com

    They had rev b boards in stock, were fast and everything was in good condition on arrival.

    To run the webserver with fever you need an SD card at least 4GB in size.

    Step 2: Prepare the Pi

    • The main Raspberry Pi page has a good tutorial for prepping your SD card on a PC. For OS X I found the ‘Pi Filler’ applescript to do a very nice job of making the process friendly: http://ivanx.com/raspberrypi/
    • Hook your Pi up to your network. — You don’t need to connect it to a display or mouse/keyboard as all the configuration will be done remotely
    • Find the IP address of your Pi on the local network. There are many ways to do this, but probably the easiest is to open up the configuration tool of your router. From there steps will vary, but try looking for a new IP on your internal network under the “NAT” or “Network” section.
    • SSH is on by default with the raspbian installation. Use an SSH client of your choosing to connect. Windows users probably want to use “Putty”. Mac users can use the terminal. 
    • Your command to connect will be: 

    ssh pi@xx.xx.xx.xx

    (where xx.xx.xx.xx is your Pi’s IP address on the local network)

    • When prompted your password will be:

    raspberry 

    • If everything has gone smoothly you should be given an option to start the raspbian configuration utility. If not, you want to enter the following into the command line:

    sudo raspi-config

    Step 3: Prepare the OS

    image

    • Update Rasp config utility by selecting the last option in the list for:

    update

    • Ensure that the Linux partition is using all available space on your SD card by selecting: 

    expand_rootfs

    • The Pi system on a chip allows allocation of memory between GPU and system. Since the webserver is being run “headless” you can reallocate and set the GPU to 16MB with the option:

    memory_split

    • Set your timezone:

    change_timezone

    • Set the boot behavior to always start on desktop:

    boot_behavior

    • I will show you how to change the default root user, however in case you don’t want to take this step. Change the PW of the root user by selecting: (really, please do this step)

    change_pass

    • Exit the config utility and reboot the system with the following command:

    sudo reboot

    • Log back into the Pi
    • Next we will create a new user and grant it root privileges with the following 2 commands (“MyUser” is replaced with the username of your choosing.) You will be prompted for a PW after entering the first command. The less obvious the username and password the more secure your server…. Do not use dictionary words. If you do, you will easily be brute forced. This server will be visible to the big bad internet. Be safe. Please note, this step can be skipped if you want to simply retain the original pi user.

    sudo adduser MyUser
    sudo adduser MyUser sudo

    • Log out of the Pi user and log into your new user account via SSH
    • Delete the default root user and all directories: (skip this step if you want to retain the pi user)

    sudo deluser -remove-home pi

    • Update your system software:

    sudo apt-get update

    Allright! The operating system is tuned up. Next we move to prepping your network and then begin installation of your webserver.

    STEP 4: Prepare your local network

    This section heavily depends on your home router and I can’t really help with specific steps here. This is really important so that you can get to your Fever installation from anywhere outside of your home network. The two main things you are trying to accomplish are the following:

    1. Assign a static internal IP to your Pi by using the Pi’s MAC address
    2. Open up port 80 for the Pi’s IP only

    STEP 5: Install the Apache webserver

    • Run the following command which will let you act as root for the following installations

    sudo bash

    • Next we will install Apache, PHP and support packages with the following two commands:

    apt-get install apache2 apache2-doc apache2-utils

    apt-get install libapache2-mod-php5 php5 php-pear php5-xcache

    STEP 6: Install mysql database and phpmyadmin

    • Run the following commands to install your database (these take a while, be patient)

    apt-get install php5-mysql
    apt-get install mysql-server mysql-client

    • During the process you will be asked for a root password for the MySQL DB. Again, don’t use a dictionary word. Make this really strong.

     image

    • Install phpmyadmin which will allow you to administer your DB from a friendly GUI.

    apt-get install phpmyadmin

    • You will be prompted with some configuration questions. Choose

    "apache2" for the autoconfig prompt

    "yes" to the DB installation prompt

    Enter the root PW you choose as part of the MySQL install earlier

    Create a PW for your phpmyadmin account (differing from your MySQL root account is wise….

    image

    image

    image

    • Configure apache to work with the phpmyadmin installation enter the following command to edit the apache config file:

    nano /etc/apache2/apache2.conf

    • Scroll to the end of the document (control V)
    • Add the following on a new line:

    Include /etc/phpmyadmin/apache.conf

    • Save the file (control X and follow the prompts to overwrite)
    • Reboot:

    sudo reboot

    STEP 6: Dealing with a dynamic IP

    If you are running this server from your home network you almost certainly are assigned a dynamic IP address from your service provider. Running a webserver with a dynamic IP requires a few extra steps.

    This is required by the fever installation. Fever will not allow configuration with only an IP address.

    Next we will need to install “ddclient” which will keep your dynamic IP up to date with dyndns. This will allow you to always connect via the hostname while the server manages always keeping your IP up to date. 

    • Log back into your pi via SSH
    • Install ddclient with:

    apt-get install ddclient

    • When prompted to run the configuration utility, answer “no”. We will do this manually.
    • Install SSL support for transmission of your dyndns account credentials.

    sudo apt-get install ssh libio-socket-ssl-perl 

    • Sign in and run the ddclient configuration utility here:

    https://account.dyn.com/entrance/?return=%2Ftools%2Fclientconfig.html

     image

    • After clicking “generate” you will be given the config parameters we need. Copy these.
    • Edit the configuration file with the following command:

    sudo nano /etc/ddclient.conf

    • Paste the text we copied from the dyndns config tool (replace all other text)
    • Update the placeholder password with the password for your dyndns account
    • Add one additional line at the bottom of the configuration. This will stop your password from being submitting in the clear.

    ssl=yes

    STEP 7: Installing Fever

    • Navigate to your web directory and create your fever directory

    cd /var/www

    mkdir -m 777 fever

    • Next you need to copy your fever install onto your server. The Fever installation video can help with this step. Be sure to place the files in the directory we created above.
    • Login to phpmyadmin in your web browser by navigating to:

    http://yourdomain.dyndns.org/phpmyadmin

    UN: root

    PW: yourpassword (created when phpmyadmin was installed)

    • Create a new DB (remember what you name it)

    image

    • Naviate to the fever “boot” process in your web browser

    http://yourdomain.dyndns.org/fever/boot.php

    • At the following prompt follow the screen shot and enter your MySQL DB password:

    image

    Nice! Fever is installed. The final step is to set up the automatic refresh job

    • Run the following command to edit your “cron” jobs

    crontab -e

    • You can find the proper string to use from your “extras” section in the fever UI
    • You may need to update the default cron string to something like:

     00,15,30,45 * * * * curl -L -s http://yourdomain.dyndns.org/fever/?refresh

    Congratulations. That’s it! Catch me on twitter if you have any questions. I’ll be back on this this blog with further security hardening steps for your apache install.