-----------------------------------------------------------------------
-- PREREQUISITES --
-----------------------------------------------------------------------
These instructions assume that you are already running php5 under 
apache2 with MySQL 5.0 or later.  This site has not yet been tested
under Windows or IIS.  I have written these instructions for
Ubuntu 8.10, but they will easily work with other debian distributions.

For help, check out the forums: http://www.getlifebox.org/forums

Just to make sure you have the prerequisites, you should probably run:
	sudo apt-get install apache2 mysql-server-5.0 mysql-client-5.0 php5-mysql

-----------------------------------------------------------------------
-- STEP BY STEP INSTRUCTIONS --
-----------------------------------------------------------------------
1. Download and extract the files to the web root.
	cd /var/www/
	sudo wget http://www.getlifebox.org/latest.tar.gz
	sudo tar -xzvf latest.tar.gz

2. Make sure the files are readable and have the appropriate permissions. 
	
	sudo chmod 755 lifebox -R
	sudo chown username.root lifebox -R # <-- REPLACE WITH YOUR USERNAME

3. Add lifebox to apache2 so it knows where the web server is

	sudo vim /etc/apache2/sites-available/001-lifebox

	<VirtualHost *:80>
	        DocumentRoot /var/www/lifebox/html/
   	     ServerName photos.example.com # <-- REPLACE WITH YOUR SITE NAME
 	       <Directory />
 	               Options FollowSymLinks
 	               AllowOverride All
        	      </Directory>
	</VirtualHost>

	sudo a2ensite 001-lifebox

	Make sure modrewrite is enabled and installed.  On debian or ubuntu, do:
	sudo a2enmod rewrite

	Then, restart the apache server
	sudo /etc/init.d/apache2 restart

4. Install the required packages:

	#Start installing from your home directory
	cd ~

	-------------------------------
	- mediainfo v0.7.9 or greater
	-------------------------------
	http://mediainfo.sourceforge.net/en/Download
   	Download all 3 packages: libzen0 libmediainfo0, CLI
	At the time of writing this, it was a little tricky
	to find the exact filenames through sourceforge.  But
	they should look something like the below:

	Once downloaded, install them (Your package names may differ):
	sudo dpkg -i libzen0_0.3.8-1_i386.Debian_5.0.deb
	sudo dpkg -i libmediainfo0_0.7.11-1_i386.Debian_5.0.deb
	sudo dpkg -i mediainfo_0.7.11-1_i386.Debian_5.0.deb

	-------------------------------
	- imagemagick 6.3.7.9 or greater
	-------------------------------
	This package requires a bunch of dependencies.  
	If you're using debian or ubuntu, 	
	apt-get makes this really easy:

	sudo apt-get install imagemagick

	-------------------------------
	- ufraw 0.13-1build2 or greater
	-------------------------------
	This is required if your site is required 
	to process RAW images.  Probably a good idea
	to have just in case.

	sudo apt-get install ufraw

5. Enable video support
	
	Wouldn't it be nice if you could just type
	apt-get install ffmpeg
	and call it a day?  Unfortunately that's not
	possible since the binary version of ffmpeg
	does not include support for h.264 compression.
	So, we have to download and compile all the 
	packages ourselves.  But don't worry, follow
	these instructions and you should be fine.

	#First, remove all existing binaries of x264
	#and ffmpeg.
	sudo apt-get purge ffmpeg x264 libx264-dev

	#Now, install the dependencies we'll use for
	#the following steps.
	sudo apt-get install build-essential subversion git-core \
		checkinstall texi2html libfaac-dev libfaad-dev \
		libmp3lame-dev libtheora-dev libxvidcore4-dev

	-------------------------------
	- yasm assembler
	-------------------------------
	There is a package for this, but instead
	of using generic c binaries we're going to
	compile this, since it can greatly improve
	performance

	cd ~/
	wget http://www.tortall.net/projects/yasm/releases/yasm-0.7.2.tar.gz
	tar xzvf yasm-0.7.2.tar.gz
	cd yasm-0.7.2
	./configure
	make
	sudo checkinstall --pkgname=yasm --default
	sudo dpkg -i yasm*.deb

	-------------------------------
	- x264 developer's library
        -------------------------------
	This is the codec we'll later be
	referencing from ffmpeg.  

	cd ~/
	git clone git://git.videolan.org/x264.git
	cd x264
	./configure --enable-shared
	make
	sudo checkinstall --fstrans=no --install=yes --pkgname=x264 \
		--pkgversion "1:0.svn`date +%Y%m%d`-0.0ubuntu1" --default
	sudo ldconfig
	sudo dpkg -i x264*.deb

	-------------------------------
        - Install ffmpeg with h264 support
        -------------------------------
	Finally, we're ready to download and
	install ffmpeg

	cd ~/
	svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
	cd ffmpeg
	./configure --enable-gpl --enable-postproc --enable-pthreads \
		--enable-libfaac --enable-libfaad --enable-libmp3lame \
		--enable-libtheora --enable-libx264 --enable-libxvid
	make
	sudo checkinstall --fstrans=no --install=yes --pkgname=ffmpeg \
		--pkgversion "3:0.svn`date +%Y%m%d`-12ubuntu3" --default
	sudo dpkg -i ffmpeg*.deb

	-------------------------------
	- qt-faststart
        -------------------------------
	When videos are streamed from the site, we need
	to make sure the information bit is at the front
	of the video so we get the nice progress bar and
	can play while downloading.  We have to re-arrange
	most videos to do this, and this application does it
	really nicely.
	
	#From inside the ffmpeg directory from the step above
	make tools/qt-faststart
	sudo cp tools/qt-faststart /usr/local/bin/qt-faststart


6. Set write permissions for the directories where lifebox will
store its template cache, thumbnail cache, and database cache.

	#Set permissions for the above
	sudo chmod 775 /var/www/lifebox/dump/* -R
	sudo chown root.www-data /var/www/lifebox/dump/* -R

7. Configure the database

	#Create the database
	mysqladmin -p -u root create lifebox

8. Launch the lifebox installer to configure the rest.

	http://photos.example.com/
