Streeme on debian with nginx / php-fpm
Mar 21st, 2013 by morpheus
In this tutorial, I’ve documented a step-by-step how-to for installing streeme on debian and getting it to work with nginx.
Streeme is an open source, html5 based personal (private) music server. If you wish to store your music at one place, and listen to it from virtually any internet connected device – Streeme is a right for you.
If you’re just looking for nginx configuration of streeme, click here to jump straight to that section.
-
Let’s start off by adding the repository that will give us debian multimedia packages (http://deb-multimedia.org/):
Edit the file /etc/apt/sources.list with your favourite text editor, and add the following line:deb http://deb-multimedia.org squeeze main non-free
If you want the most up-to-date versions of other web related packages (nginx, php, mysql etc.), I suggest you also add the dotdeb (http://www.dotdeb.org/) repository to your sources list.This is what my sources.list looks like :
deb http://ftp.us.debian.org/debian squeeze main contrib non-free deb http://security.debian.org squeeze/updates main contrib non-free deb http://packages.dotdeb.org squeeze all deb http://packages.dotdeb.org squeeze-php54 all deb http://deb-multimedia.org squeeze main non-free
-
Update your package cache & Install the packages required by streeme:
apt-get update && apt-get install mysql-server \ php5-cli php5-fpm php5-gd php5-mysql php5-curl \ php-pear curl nginx-light ffmpeg libmp3lame0 subversion pear install HTTP_Download
-
Get streeme code:
mkdir -p /var/www/virtual/streeme ; chown www-data:www-data /var/www/virtual/streeme cd /var/www/virtual/streeme svn checkout http://streeme.googlecode.com/svn/trunk/ . cp config/databases.template.yml config/databases.yml cp apps/client/config/app.template.yml apps/client/config/app.yml chmod 777 log cache
-
Create a mysql database & user for streeme:
mysql -u root -p -e "create database your_mysql_database;\ grant all privileges on your_mysql_database.* to \ 'your_mysql_username'@'localhost' identified by \ 'your_mysql_pass';"
change the your_mysql_database, your_mysql_username and your_mysql_pass, of course.
-
Edit /var/www/virtual/streeme/config/databases.yml, in the section titled “all:”, edit the following two lines and put in the correct database information:
username: your_mysql_username password: your_mysql_pass
-
Edit /var/www/virtual/streeme/apps/client/config/app.yml, edit the following sections and put in the correct values:
watched_folders: - "/home/user1/dir1" - "/dir2" - and so on ... add all directories that hold your mp3 files
ffmpeg_executable: "/usr/bin/ffmpeg"
music_proxy_port: 8096
-
Clear symfony cache:
/var/www/virtual/streeme/symfony cc
-
Check your configuration:
php /var/www/virtual/streeme/check_configuration.php
-
Initialize your music library:
/var/www/virtual/streeme/symfony doctrine:build --all --and-load
-
Scan your watched_folders for music (mp3 files) and for album art (cover.jpg or front.jpg):
/var/www/virtual/streeme/symfony scan-media --type=filesystem /var/www/virtual/streeme/symfony scan-art --source=folders
-
Create a user account:
/var/www/virtual/streeme/symfony guard:create-user your_username your_password
-
You can always update the password for an existing account like so:
/var/www/virtual/streeme/symfony guard:change-password your_username your_new_password
-
Create a nginx config for streeme virtual hosts (/etc/nginx/sites-available/streeme):
upstream php { server unix:/var/run/php5-fpm.sock; #dotdeb php5-fpm listens on this socket by default } #Frontend server { listen [::]:8095; root /var/www/virtual/streeme/web; location ~ (/\.|^/(config|test)) { deny all; } gzip on; gzip_vary on; gzip_types text/plain text/xml text/css text/javascript application/javascript; rewrite ^/art/([a-zA-Z0-9]+|all)/([a-zA-Z0-9]+|all)$ /proxy_art.php?hash=$1&size=$2 last; rewrite ^/client_dev.php/art/([a-zA-Z0-9]+|all)/([a-zA-Z0-9]+|all)$ /proxy_art.php?hash=$1&size=$2 last; location ~ ^/(index|proxy_art)\.php$ { include fastcgi_params; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass php; } location / { index index.php; try_files $uri /index.php?$args; } location /sf/ { root /var/www/virtual/streeme/lib/vendor/symfony/data/web/sf/; } location ~* \.(ico|jpg|jpeg|png|gif|css|js|swf)$ { expires 86400s; add_header Cache-Control "max-age=86400, private, must-revalidate, proxy-revalidate"; } } #Music-proxy server { listen [::]:8096; root /var/www/virtual/streeme/web; location ~ (/\.|^/(config|test)) { deny all; } rewrite ^/play/([a-zA-Z0-9.]+|all)$ /proxy_play.php?unique_song_id=$1 last; rewrite ^/client_dev.php/play/([a-zA-Z0-9]+|all)$ /proxy_play.php?unique_song_id=$1 last; location ~ ^/(proxy_play)\.php$ { include fastcgi_params; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass php; } location / { index index.php; try_files $uri /index.php?$args; } }
The config above has been created using the “Symfony Framework example” config @ nginx wiki.
I’ve converted the redirects that streeme requires & other directives … from .htaccess into equivalent nginx rewrite rules. -
Enable the streeme sites:
ln -s ../sites-available/streeme /etc/nginx/sites-enabled/streeme
-
Restart nginx to load the new config:
/etc/init.d/nginx restart
-
Visit http://<your-server>:8095/ , login and start listening to your music !
Please feel free to leave comments if you have any.
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Leave a Reply