locationの設定で、

    location /hogeadmin/ {

        proxy_pass http://localhost:40080/;

        proxy_redirect default;

    }

後ろのスラッシュが揃ってなくてパスが上手く通らず困った…

 

php.iniのsession.save_pathのディレクトリができていなかったのでmkdir。

かつchmod 777。

 

phpは何度もmakeしなおした…必要なextentionを見つけて、対応する、の繰り返し。

cloudnのcomptuteにインストールとか

curl https://raw.github.com/hokaccha/nodebrew/master/nodebrew | perl - setup

# vi ~/.bashrc

で一行追加。

<pre>

export PATH=$HOME/.nodebrew/current/bin:$PATH

</pre>

# source ~/.bashrc

# nodebrew install latest

でコンパイルエラーが出るので色々とインストールが必要。

% yum install gcc gcc-c++

# nodebrew install latest

でうまく行った。nodeの開発ディレクトリに移動して…

#npm install

あとは実行。

phpインストールメモ

php5.4を入れようとソースから持ってきたものの、apxsがないがためハマったメモ。

yum install httpd httpd-devel <-これやらないとapxsが入らない

の上で、php5.4ソースの展開先

./configure --with-apxs2=/usr/sbin/apxs --with-mysql

php.ini内設定変更。

mysql.default_socket = /tmp/mysql.sock

 

nginx+phpの場合はenable-fpmも有効にする。

./configure --with-apxs2=/usr/sbin/apxs --with-mysql --enable-fpm

後の設定はググってみてください。

node_redisでバイナリデータが上手く読み取れない

redis-cliを使って「value==バイナリ」のレコードを保存。

cat hoge.bin | redis-cli -x set filename:hoge.bin

node_redisで指定されたファイルを読み取るように書こうとしたがー…見事に壊れてる。

var redis = require('redis');
var client = redis.createClient();
client.on("error", function (err) {
    console.log(err);
    client.end();
});
    
    client.get("filename:hoge.bin", function (err, reply) {
console.log(parseInt(reply[0]).toString(16)); console.log(parseInt(reply[1]).toString(16));// ここら辺から元データと相違が… console.log(parseInt(reply[2]).toString(16)); console.log(parseInt(reply[3]).toString(16)); console.log(parseInt(reply[4]).toString(16)); console.log(parseInt(reply[5]).toString(16)); console.log(reply.length); }); 

redis-cliでとる分には問題なかった!だから問題ないはずなんだー(以下のやり方だと改行コード1Byte入るけど)

redis-cli get filename:hoge.bin > hoge.bin.redis

 

何でなんでー!?ググっても見つからず、みんなbase64とかにして扱ってるのかなーとか悩みながら一度帰って翌朝もう一度node_redisのgithub見てやっと気づいた。これか。

https://github.com/mranney/node_redis

detect_buffers: default to false. If set to true, then replies will be sent to callbacks as node Buffer objects if any of the input arguments to the original command were Buffer objects. This option lets you switch between Buffers and Strings on a per-command basis, whereas return_buffers applies to every command on a client.

 

あとこのサンプル

    // This will return a Buffer since original key is specified as a Buffer
    client.get(new Buffer("foo_rand000000000000"), function (err, reply) {
        console.log(reply.toString()); // Will print `<Buffer 4f 4b>`
    });

すなわち

var redis = require('redis');
var client = redis.createClient(null, null, {detect_buffers:true});
client.on("error", function (err) {
    console.log(err);
    client.end();
});
    
    client.get(new Buffer("filename:hoge.bin"), function (err, reply) {
console.log(parseInt(reply[0]).toString(16)); console.log(parseInt(reply[1]).toString(16)); console.log(parseInt(reply[2]).toString(16)); console.log(parseInt(reply[3]).toString(16)); console.log(parseInt(reply[4]).toString(16)); console.log(parseInt(reply[5]).toString(16)); console.log(reply.length); });

detect_buffersオプションとkey指定の時にBufferで指定するのがポイントでした。
valueにはjpegだって扱えるよ!というのは良く見つかるんだけど、そのjpegを使ったサンプルを…