Introduction: Raspberry Pi Movie Server

Picture of Raspberry Pi Movie Server

This guide will let you turn your Raspberry Pi and any external hard drive into a fully functioning media server!

This is a great way to digitize your own DVD collection.

I will assume that the following is already configured on the Pi:

1. An SD card at least 8GB with Raspbian installed

2. SSH, FTP (and network connectivity)

This tutorial will take at least two days. We will be building MongoDB for ARM from the source, which can take up to 12 hours to complete.

Step 1: Setting Up the Pi - MongoDB

Picture of Setting Up the Pi - MongoDB

First we will install MongoDB for the Raspberry Pi. This is without a doubt the longest step, as we will build Mongo from the source.

1. SSH into your Pi and then execute the following commands to install some dependencies (It didn't work for me when executed in one line, but individually it worked fine).

$ sudo apt-get install git-core
$ sudo apt-get install build-essential
$ sudo apt-get install scons
$ sudo apt-get install libpcre++-dev
$ sudo apt-get install xulrunner-dev
$ sudo apt-get install libboost-dev
$ sudo apt-get install libboost-program-options-dev
$ sudo apt-get install libboost-thread-dev
$ sudo apt-get install libboost-filesystem-dev

2. Clone this Github repo, a MongoDB port for Raspberry Pi.

$ git clone git://

3. Build Mongo (this takes a looooong time).

$ cd mongopi

$ scons

4. Install MongoDB

$ sudo scons --prefix=/opt/mongo install

5. Add MongoDB to your PATH variable

$ PATH=$PATH:/opt/mongo/bin/

$ export PATH

6. Clean up

$ scons -c

7. Create the /data/db/ directory required by MongoDB

$ sudo mkdir -p /data/db/

$ sudo chown $USERNAME /data/db/

8. Fire up MongoDB using the following command:

$ mongod --fork --logpath /var/log/mongod.log

9. In a new terminal window, enter the mongo shell:

$ mongo

10. We will now create our MongoDB database called 'media' and populate it with a collection called 'movies':

$ use media

$ db.createCollection("movies")

Step 2: Setting Up the Pi - Apache Web Server

Picture of Setting Up the Pi - Apache Web Server

Next we will install Apache Web Server and PHP5.

1. Install Apache.

$ sudo apt-get install apache2 -y

2. Install PHP

$ sudo apt-get install php5 libapache2-mod-php5 -y 

3. Now let's test to see if Apache is up and running. Execute the below command to find the IP address of the Pi (Of the format Once you have obtained the IP of the Pi, go to that address in a browser. You should see the Apache default page.

$ ifconfig | grep -e "inet addr"

4. To display your PHP info, execute the following and then go to, where is the IP address of your Pi.

$ echo "<?php phpinfo(); ?>" > /var/www/html/info.php

5. Modify your httpd.conf file, which controls the behavior of your web server.

$ sudo nano /etc/apache2/httpd.conf

6. Insert the following into httpd.conf, inserting the root username for admin privileges.

ServerName localhost
DocumentRoot /var/www

<Directory "/var/www">
    DirectoryIndex index.php

    AuthType Basic
    AuthName "Please Login."
    AuthUserFile /etc/apache2/.htpasswd
    <Limit GET>
        require valid-user

<Directory "/var/www/scripts">
    Options -Indexes

<Directory "/var/www/styles">
    Options -Indexes

<Directory "/var/www/tv">
    DirectoryIndex /tv/tv.php

<Directory "/var/www/movies">
    DirectoryIndex /movies/movies.php

<Directory "/var/www/movies/play">
    DirectoryIndex /movies/play/play.php

<Directory "/var/www/media">
    Options -Indexes

<Directory "/var/www/admin">
    DirectoryIndex /admin/admin.php
    AuthType Basic
    AuthName "Please Login."
    AuthUserFile /etc/apache2/.htpasswd
    <Limit GET>
        require user $YOUR_ADMIN_USERNAME

7. Restart Apache:

$ sudo service apache2 restart

Step 3: Setting Up the Pi - Media Server (reelr)

Picture of Setting Up the Pi - Media Server (reelr)

Now we will finally install the movie server!

1. Clone the media server from Github into /var/www :

$ cd /var/www

$ git clone

Step 4: Setting Up the Hard Drive

Picture of Setting Up the Hard Drive

Next we will set up the external hard drive. reelr requires a very specific file organization to operate that follows the scheme below:

~/HDDMount/Movies/Toy Story/TOY_STORY_1995.mkv

In other words, the parent directory /Movies contains children folders that are the literal name of the movie as it would appear in IMDb. Inside those children folders are the media files, which can have any name.

1. Plug your hard drive into your Raspberry Pi and mount it. This command will list all connected drives. Use it to locate the path of your external drive. In my case, the drive was located at /dev/sda1

$ df -h

This command mounts the drive at ~/HDDMount

$ sudo mount /dev/LOCATION_OF_DRIVE ~/HDDMount

2. THIS STEP WILL ERASE ALL DATA AND REFORMAT YOUR HARD DRIVE. If you don't want to reformat, skip this step.

$ sudo umount /dev/LOCATION_OF_DRIVE


$ sudo mount /dev/LOCATION_OF_DRIVE ~/HDDMount

3. Create a movie directory on your external drive.

$ mkdir -m 777 ~/HDDMount/Movies

4. Organize your movie files inside the Movies directory according to the tree above.

5. Make a symbolic link in /var/www to ~/HDDMount. We will call it /var/www/media which will point to ~/HDDMount

$ ln -s ~/HDDMount /var/www/media

Step 5: Final Configurations

Picture of Final Configurations

1. Change the two fields in /var/www/config.json to /var/www/media/Movies and the name by which you want to call your server respectively.

2. Go to the IP of the Pi in your browser. You should see a black screen which displays recently played movies. Now navigate to that IP /movies (ie. You should see all of your movies!

3. To add user accounts, use the following commands:



$ htpasswd /etc/apache2/.htpasswd USERNAME_YOU_ARE_ADDING

4. To view the administrator page and edit media without going into MongoDB directly, go to and enter the admin user you inserted into httpd.conf (Step 2).