「Streeme」HTMLで音楽共有、ストリーミングサーバの構築 PHP,MySQL

MySQL
Table of Contents

Streemeは、Linux をはじめ、 Mac OS や Windows など、クロスプラットフォームで動作します。

今回は、CentOS release 6.2 に構築します。事前にMySQLとPHPは、インストール済みとして進めます。

Google Code Archive - Long-term storage for Google Code Project Hosting.

 

でははじめます。

RPMForge リポジトリを追加する、まずダウンロード

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

 

RPMforgeリポジトリインストール

rpm -ivh rpmforge-release-*.rpm

 

rpmforge-releaseアップデート

yum -y update rpmforge-release

 

必要なパッケージのインストール

yum --enablerepo=rpmforge install php-gd php-xml php-pecl-apc ffmpeg

 

mysqlのユーザーを作成

mysql>CREATE USER streeme;

streeme パスワードを password

Streeme が利用する streeme, streemetest という 2 つのデータベースへのアクセス権を付与します。具体的には次の SQL を発行します。

mysql>GRANT ALL PRIVILEGES ON streeme.* TO 'streeme'@'localhost' IDENTIFIED BY 'password';
mysql>GRANT ALL PRIVILEGES ON streemetest.* TO 'streeme'@'localhost';

 

Streeme のインストール

mkdir /usr/local/streeme
cd /usr/local/streeme
svn checkout http://streeme.googlecode.com/svn/trunk/ .

 

データベース用の設定ファイルを変更

cd /usr/local/streeme/config
mv databases.template.yml databases.yml
vim databases.yml

 

/usr/local/streeme/.htaccess.template を .htaccess にリネーム

cd /usr/local/streeme
mv .htaccess.template .htaccess
chmod 777 log cache

/usr/local/streeme/apps/client/config/app.template.yml を app.yml にリネームし、動作に必要な設定を変更

cd /usr/local/streeme/apps/client/config
mv app.template.yml app.yml

 

基本的な設定は完了です。同梱されている check_configuration.php を使って確認

cd /usr/local/streeme
php check_configuration.php

 

apcとpgsqlのWarningが発生

./symfony guard:create-user user password
PHP Warning:  PHP Startup: intl: Unable to initialize module
Module compiled with module API=20090626
PHP    compiled with module API=20100525
These options need to match
 in Unknown on line 0
PHP Warning:  Module 'apc' already loaded in Unknown on line 0
PHP Warning:  Module 'pgsql' already loaded in Unknown on line 0


PDO Connection Error: SQLSTATE[42000] [1049] Unknown database 'streeme'


 

とりあえず/etc/php.in からコメントアウトすればよいかと修正

;extension=apc.so
;extension=pgsql.so

 

再び、ユーザの作成

./symfony guard:create-user user password
PHP Warning:  PHP Startup: intl: Unable to initialize module
Module compiled with module API=20090626
PHP    compiled with module API=20100525
These options need to match
 in Unknown on line 0


 SQLSTATE[42S02]: Base table or view not found: 1146 Table 'streeme.sf_guard_user' doesn't exist
                                                                                                   

 

 

今度は、‘streeme.sf_guard_user’ doesn’t exist テーブルないので、なんだこれは思って調査してみると

おそらくこのプラグイン /usr/local/streeme/plugins/sfDoctrineGuardPlugin

「README」をみてると、翻訳してあるやつがみつかった

sfDoctrineGuardPluginのREADME翻訳 - しんふぉにゃん
翻訳を載せておきますが、微妙に内容が間違っている部分もあるっぽいです。今回はそういった部分は修正せずに単純に翻訳してあります。翻訳ファイルはgithubに載せましたので、本家のライセンスにしたがってご自由に利用してください。 # sfGua...

翻訳を見ながら、以下のコマンドでモデルを再構築、データベースのテーブルを更新します (既存のデーブルを削除して、再作成します)をしました。

cd /usr/local/streeme
./symfony doctrine:build-model
./symfony doctrine:build-sql
./symfony doctrine:insert-sql

 

 

今までテーブルを確認していなかったが、テーブルができてた。

mysql> show tables;
+---------------------------+
| Tables_in_streeme         |
+---------------------------+
| album                     |
| artist                    |
| echonest_properties       |
| genre                     |
| playlist                  |
| playlist_files            |
| scan                      |
| sf_guard_group            |
| sf_guard_group_permission |
| sf_guard_permission       |
| sf_guard_remember_key     |
| sf_guard_user             |
| sf_guard_user_group       |
| sf_guard_user_permission  |
| song                      |
| song_genres               |
+---------------------------+

 

 

 

今度こそとユーザを作成

 ./symfony guard:create-user user password
PHP Warning:  PHP Startup: intl: Unable to initialize module
Module compiled with module API=20090626
PHP    compiled with module API=20100525
These options need to match
 in Unknown on line 0
>> guard     Create user "user"

「Warning: PHP Startup: intl: Unable to initialize module 」がでてるけど作成されたぽい。

いちようphp.iniを修正しておいた

 

 

バーチャルホストを修正

vim /etc/httpd/conf.d/vhost.conf

 

<VirtualHost *:80>
    ServerName streeme.hogehoge.com
    ServerAdmin streeme@hogehoge.com
    DocumentRoot /usr/local/streeme/web
    ErrorLog logs/streeme_error_log
    TransferLog logs/streeme_access_log
</VirtualHost>

 

設定がOKかチェック

/sbin/service httpd configtest

問題なければ再起動

/sbin/service httpd graceful

※「restart」では httpd プロセスを完全に停止してから再起動します。対して「graceful」では httpd プロセスの通信が終わるのを待って、順次新しい設定を反映した httpd を起動させる方法です。

 

お名前.comでDNSレコード設定に以下の設定を追加。

streeme.hogehoge.com

 

streeme.hogehoge.comにアクセスすると

top

英語なので、以下のサイトにあった日本語のファイルを使って日本語化します。

301 Moved Permanently

 

・ダウンロード

https://blog.local-c.com/wp-content/uploads/2014/11/ja.zip

 

/usr/local/streeme/apps/client/i18n/ へ jaディレクトリごとアップしてこんな感じです。

/usr/local/streeme/apps/client/i18n/ja/messages.xml

 

変更を反映するため

cd /usr/local/streeme
./symfony cc

 

音楽ファイルのインポート

 

xmlファイルと音楽データをサーバへアップ

C:\Users\Hoge\Music\iTunes\iTunes Music Library.xml
↓
/home/hoge/music


C:\Users\Hoge\Music\iTunes\iTunes Media\Music
↓
/home/hoge/music

iTunes Music Library.xmlの中でローカルPCのパスになっているところを修正

<key>Location</key><string>file://localhost/home/hoge/music/B-DASH/E'/13%20M-11.m4a</string>

 

/usr/local/streeme/apps/client/config/app.yml を修正箇所

itunes_xml_location: "/home/hoge/music/iTunes Music Library.xml"
wf:
     watched_folders:
       - "/home/hoge/music"
aft:
     allowed_file_types:
      - mp3
      - m4a 32      

 

itunesのxml読み込んでインポートするやりかた

./symfony scan-media --type=itunes

 

でもこれが、すべてインポートできない。日本語のフォルダ名がいけないのか

 

itunesの設定に関係なくmp3,m4aのファイルを取り込む

./symfony scan-media --type=filesystem

すべて取り込まれるが、日本語のファイル名だと数字だけになってる。

もうギブアップ、mp3の日本語ファイルは正常に取り込まれているけど「.m4a」はだめだ!!

また今後調査

 

 

参考

GitHub - chaffneue/streeme: Listen to music on the go! Streeme is an open source, html5 based personal music server
Listen to music on the go! Streeme is an open source, html5 based personal music server - chaffneue/streeme
301 Moved Permanently
http://b.ruyaka.com/2012/04/20/%E3%81%95%E3%81%8F%E3%82%89%E3%81%AEvps%E3%81%AB%E9%9F%B3%E6%A5%BD%E9%85%8D%E4%BF%A1%E3%82%B7%E3%82%B9%E3%83%86%E3%83%A0%E3%80%8Cstreeme%E3%80%8D%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC/