2016年6月5日日曜日
2016年1月4日月曜日
logstashをWindowsで使う
最近elasticsearchが面白そう。あとログ収集でfluentdを使っているけど、logstashも気になるところ。
ということで、使ってみる。
ここを参考にさせてもらいました(途中まではほぼ一緒)。
http://qiita.com/qtwi/items/98c1184a8a6ce6e2a5e7
やってみることは、fluentdで実装済みなのですが、あるcsvファイルを読み取り、mongodbに保存する。という内容。環境は以下の通り
・ Windows8.1(x64)
・ Java 7u79(JRubyを使う) ※javaはインストール済み
・ logstash 2.1.1
・ mongodb v3.2.0-rc4
0.準備
javaがセットアップされていること。JAVA_HOMEも忘れずにセットアップ。
mongodbがセットアップされていること。
1.logstash のインストール
ここからインストーラをダウンロードする。
https://download.elastic.co/logstash/logstash/logstash-2.1.1.zip
し、中のフォルダを適当な場所にコピーする。
ここでは、「C:\logstash-2.1.1」にコピー。
2.pluginのインストール
今回使うpluginは以下の通り。
インストール済みのpluginを表示する。
今回のpluginのうち、
・logstash-input-file
・logstash-filter-csv
インストールができていることを確認。
※proxy環境下の場合は以下の設定をする
3.設定ファイルの作成
作成するにあたっての想定は以下の通り。
・サンプルに使うデータは"c:\test\test.csv"とする
・データの中身は以下の通り
これで設定をすると、
備忘録)
input pluginのfileだが、Windows環境ではワイルドカードを使うことができません。どうもjruby
環境にbugがあるようです。rubyだと出ないという記事もありました。
ここを参考にさせてもらいました(途中まではほぼ一緒)。
http://qiita.com/qtwi/items/98c1184a8a6ce6e2a5e7
やってみることは、fluentdで実装済みなのですが、あるcsvファイルを読み取り、mongodbに保存する。という内容。環境は以下の通り
・ Windows8.1(x64)
・ Java 7u79(JRubyを使う) ※javaはインストール済み
・ logstash 2.1.1
・ mongodb v3.2.0-rc4
0.準備
javaがセットアップされていること。JAVA_HOMEも忘れずにセットアップ。
mongodbがセットアップされていること。
1.logstash のインストール
ここからインストーラをダウンロードする。
https://download.elastic.co/logstash/logstash/logstash-2.1.1.zip
し、中のフォルダを適当な場所にコピーする。
ここでは、「C:\logstash-2.1.1」にコピー。
2.pluginのインストール
今回使うpluginは以下の通り。
1.ファイルを読み取るに、logstash-input-fileを使う
2.読み取ったログのデータにfield名をつけるのに、logstash-filter-csvを使う
3.読み取ったログの数値型データに型を割り当てるのに、logstash-filter-mutateを使う
4.読み取ったログのデータに日付型を割り当てるのに、logstash-filter-dateを使う
5.mongodbに入れるのに、logstash-output-mongodbを使う
インストールしてみる。pluginに関するコマンドは、以下の通り。
$ cd C:\logstash-2.1.1\bin
インストール済みのpluginを表示する。
$ plugin list
今回のpluginのうち、
・logstash-input-file
・logstash-filter-csv
・logstash-filter-mutate
・logstash-filter-date
はデフォルトでインストールされていることがわかる。
あとはmongodb。
$ plugin install logstash-output-mongodb
これでインストールができる。インストール済みのoutputプラグインを見るには、
$ plugin list --group output
で絞って見れる。plugin名の一部で検索することもできる
$ plugin list mongodb
※proxy環境下の場合は以下の設定をする
$ export HTTP_PROXY=http://[proxy server]:[proxy port]
作成するにあたっての想定は以下の通り。
・サンプルに使うデータは"c:\test\test.csv"とする
・データの中身は以下の通り
time,hostname,object,metric ,value,data1,data2,data3,data4,data5
2015/11/21 00:00:05,server1,object1,metric1,0.13,201511,21,00,00,05
・上記のデータのうち、data1まで取り込んで、data2-5は取り込まない
・フィールドの"time"はdate型、"value"はfloat型、残りはstring型とする
・時間のフィールド名は"time"とする(@timestampではない)
これで設定をすると、
input {
file{
path => ['C:\test\test.csv'] # input用ファイル
start_position => beginning # ファイルを最初からチェックする
}
} filter {
csv {
columns =>[ # フィールド名
"time",
"hostname",
"object",
"metric",
"value",
"data1"
]
separator => "," # 区切り文字はカンマ
}
mutate {
convert => {
"value" => "float" # フィールド"value"の型をfloat型に変換
}
}
date {
match => [ "time","YYYY/MM/dd HH:mm:ss"] # フィールド"time"の値をdate型に変換
timezone => "Asia/Tokyo" # タイムゾーンを日本に。
target => "time" # 変換後の値をフィール"time"にセット。デフォルトは"@timestamp"
}
} output {
stdout{} # 確認のために標準出力に出力
mongodb { # mongodbに入れる
codec => plain
collection => "windows" # collection名
database => "logstash" # database名
isodate => true # 時刻をisodateに
retry_delay => 10 # 挿入失敗時のリトライ数
uri => "mongodb://192.168.x.x" # mongodb接続文字列
workers => 1 # outputで使われるコア数(並列度)
}
}
としてみた。この結果mongodbに入った情報は、以下の通り。
{
"_id" : ObjectId("56882fc7564ba8d0b3000002"),
"message" : "2015/11/21 00:00:28\tserver1\tobject1\tmetric1\t0.13\t2015\t11\t21\t00\t00\t05\r",
"@version" : "1",
"@timestamp" : ISODate("2015-11-20T15:00:05.000+0000"),
"host" : "WIN-O4KS6DHF31D",
"path" : "C:\\test\\test.csv",
"time" : ISODate("2015-11-20T15:00:28.000+0000"),
"hostname" : "server1",
"object" : "object1",
"metric" : "metric1",
"value" : 0.13,
"data1" : "2015",
"column7" : "11",
"column8" : "21",
"column9" : "00",
"column10" : "00",
"column11" : "05"
}
随分と想定外のデータが入ってしまっている。logstash内部やelasticsearchで使うフィールドが
含まれているみたい。mutateのremove_fieldを使用して削除すればいいのかなと。
filterセクションのmutate pluginで以下を追加してみる。
@timestamp前提で実装されている部分がある。ちなみに、@timestampを削除外にして進めると、エラーがなくなり、登録データもかなり近い状態となった。
あとはこのpluginを別のpluginとして登録するようにすれば、とりあえずは解決できそう。
もっとスマートな方法があるかと思うが、とりあえず、終了。
含まれているみたい。mutateのremove_fieldを使用して削除すればいいのかなと。
filterセクションのmutate pluginで以下を追加してみる。
remove => "message"
remove => "@version"
remove => "@timestamp"
remove => "host"
remove => "path"
remove => "column7"
remove => "column8"
remove => "column9"
remove => "column10"
remove => "column11"
これをすると、以下のエラーがでるNoMethodError: undefined method `to_iso8601' for nil:NilClass
調べると、もともと@timestampは必須の項目のようで、mongodb pluginのソースをみても、@timestamp前提で実装されている部分がある。ちなみに、@timestampを削除外にして進めると、エラーがなくなり、登録データもかなり近い状態となった。
{
"_id" : ObjectId("568846b0564ba8b65b000001"),
"@timestamp" : ISODate("2016-01-02T21:52:48.431+0000"),
"time" : ISODate("2015-11-20T15:00:35.000+0000"),
"hostname" : "server1",
"object" : "object1",
"metric" : "metric1",
"value" : 0.13,
"data1" : "2015"
}
やはり@timestampが不要(データサイズがかさむ)。ということで、mongodb pluginのソースを
少々いじり、mongodbに登録時のみ@timestampを削除するように1行追加してみた。
C:\logstash-2.1.1\vendor\bundle\jruby\1.9\gems\logstash-output-mongodb-2.0.3\lib\logstash\outputs\mongodb.rbの56行目(insert_oneの直前)に以下を追加
document.delete("@timestamp")
これで登録すると、無事想定通りのデータができあがった。あとはこのpluginを別のpluginとして登録するようにすれば、とりあえずは解決できそう。
もっとスマートな方法があるかと思うが、とりあえず、終了。
備忘録)
input pluginのfileだが、Windows環境ではワイルドカードを使うことができません。どうもjruby
環境にbugがあるようです。rubyだと出ないという記事もありました。
2015年12月25日金曜日
fluentdをWindowsで使う
以前、Windows上でお試し版のfluentdの0.10.46を使っていたが、正式に対応した(masterブランチに組み込まれた)とのことで、改めて導入してみた。
ここを参考にさせてもらいました(ほぼ一緒)。
http://qiita.com/nurse/items/8bbb194982c685f1e795
環境は以下の通り
・ Windows8.1(x64)
・ Ruby 2.2.3(x64) + devkit(Cコンパイル環境)
・ fluentd 0.14.0.pre.1
・ Git for Windows
1.Ruby のインストール
ここからインストーラをダウンロードし、インストールする。
ここでは、「c:\Ruby22-x64」にインストールする。
途中のオプション指定で、PATHに追加する。
2.devkit
このモジュールも上記と同じサイトから入手する。
入手したモジュールを実行すると、展開先を聞かれるので、「c:\ruby」としておく。
展開し終わったら、以下を実施。
- C:/Ruby22-x64
ここを参考にさせてもらいました(ほぼ一緒)。
http://qiita.com/nurse/items/8bbb194982c685f1e795
環境は以下の通り
・ Windows8.1(x64)
・ Ruby 2.2.3(x64) + devkit(Cコンパイル環境)
・ fluentd 0.14.0.pre.1
・ Git for Windows
1.Ruby のインストール
ここからインストーラをダウンロードし、インストールする。
ここでは、「c:\Ruby22-x64」にインストールする。
途中のオプション指定で、PATHに追加する。
2.devkit
このモジュールも上記と同じサイトから入手する。
入手したモジュールを実行すると、展開先を聞かれるので、「c:\ruby」としておく。
展開し終わったら、以下を実施。
$ cd c:\ruby
$ ruby dk.rb init
config.ymlgが生成されるので、そのファイルに1のrubyインストールパスを記載する- C:/Ruby22-x64
編集が終わったら、
$ ruby dk.rb install
を実行する。
3.Git
git レポジトリからfluentdを入手。zip出ダウンロードでもいいかなと思ったのですが、
fluentdのgemfileの中身で改行がLFとなっていたので、動作しなかった。これだけなら、
ファイルを改修すればよいかもしれないけど、、他でも問題がでるかもしれないので、、
素直にgitを入れて、同梱のgit-bashを使うことにする。
http://www.git-scm.com/download/win
からダウンロードする。
サーバ利用などを考慮すると何かとインストールされるのは気持ち悪いので、portableで進める(c:\git)。
4.fluentdのインストール
以下は、c:\git\bash.exeを実行し、その上で進める。
gitをProxy環境下で使用する場合、以下の設定をしておく
これで基本のセットアップ完了。
これでうまく動けばテスト完了。
5.pluginのインストール
試しに、複数のログをtailで読み取り、mongodbに送り込むという処理を実装してみる。
・ 複数のファイルを読み取るには、fluent-plugin-tail-exを使う
・ 読み取ったログのフォーマットに型を割り当てるのに、fluent-plugin-typecastを使う
3.Git
git レポジトリからfluentdを入手。zip出ダウンロードでもいいかなと思ったのですが、
fluentdのgemfileの中身で改行がLFとなっていたので、動作しなかった。これだけなら、
ファイルを改修すればよいかもしれないけど、、他でも問題がでるかもしれないので、、
素直にgitを入れて、同梱のgit-bashを使うことにする。
http://www.git-scm.com/download/win
からダウンロードする。
サーバ利用などを考慮すると何かとインストールされるのは気持ち悪いので、portableで進める(c:\git)。
4.fluentdのインストール
以下は、c:\git\bash.exeを実行し、その上で進める。
$ cd /c
$ git clone https://github.com/fluent/fluentd.git
$ cd fluentd
$ gem install bundler
$ bundle
$ bundle exec rake build
$ gem install pkg/fluentd-0.14.0.pre.1.gem
$ git config --global http.proxy http://proxy.example.com:8080
$ git config --global https.proxy http://proxy.example.com:8080
同様にgemも使うので、下の設定をしておく$ export HTTP_PROXY=http://proxy.example.com:8080
これで基本のセットアップ完了。
$ fluentd -c ./example/in_forward.conf
これでうまく動けばテスト完了。
5.pluginのインストール
試しに、複数のログをtailで読み取り、mongodbに送り込むという処理を実装してみる。
・ 複数のファイルを読み取るには、fluent-plugin-tail-exを使う
・ 読み取ったログのフォーマットに型を割り当てるのに、fluent-plugin-typecastを使う
・ mongodbに入れるのに、 fluent-plugin-mongoを使う
ということで、以下を実行する。
$ ./bin/fluent-gem install fluent-plugin-tail-ex
$ ./bin/fluent-gem install fluent-plugin-typecast
$ ./bin/fluent-gem install fluent-plugin-mongo
とここで問題が。
installすると、fluentdの0.12.19が一緒にインストールされてしまい、fluentd自体が
そちらを参照しに行ってしまう。
$ fluentd --version
fluentd 0.12.19
結果として、
$ fluentd -c ./example/in_tail.conf
2015-12-24 00:45:48 +0900 [info]: reading config file path="./example/in_tail.conf"
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/fluentd-0.12.19/lib/fluent/supervisor.rb:387:in `trap': unsupported signal SIGHUP (ArgumentError)
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/fluentd-0.12.19/lib/fluent/supervisor.rb:387:in `install_supervisor_signal_handlers'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/fluentd-0.12.19/lib/fluent/supervisor.rb:139:in `start'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/fluentd-0.12.19/lib/fluent/command/fluentd.rb:171:in `<top (required)>'
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/fluentd-0.12.19/bin/fluentd:6:in `<top (required)`>'
from C:/Ruby22-x64/bin/fluentd:23:in `load'
from C:/Ruby22-x64/bin/fluentd:23:in `<main>'
こんなエラーがでるようになる。0.12.19はWindowsに対応していないが原因。
とりあえず、0.12.19をアンインストールしてみる
$ ./bin/fluent-gem uninstall fluentd
Select gem to uninstall:
1. fluentd-0.12.19
2. fluentd-0.14.0.pre.1
3. All versions
> 1
Successfully uninstalled fluentd-0.12.19
これで動くかどうか・・ですね。
で設定は以下の通り(ログは適当)。
test.conf
<source>
type tail_ex
path c:\fluentd\data\*.tsv
pos_file c:\fluentd\data\fluentd-tsv.pos
tag tail_ex.a
format tsv
keys time,name,counterobject,counter,value
time_key time
refresh_interval 30
</source>
<match tail_ex.*>
type typecast
item_types time:string,name:string,counterobject:string,counter:string,value:float
tag mongo.data
</match>
<match mongo.data>
# plugin type
type mongo
# mongodb db + collection
database test
tag_mapped
emove_tag_prefix mongo.
# mongodb host + port
host 192.168.33.207
port 27017
# interval
flush_interval 10s
#include_time_key true
</match>
あと今はgit-bash.exe上でテストをしているが、バッチとして実行したいので、コマンドプロンプト
から実行するには、、
$ c:\git\bin\bash -c "/C/fluentd/bin/fluentd -c /C/fluentd/test.conf"
これで実施できる。
で、試してみたが、、エラーだ・・tail_exが引っかかっているみたい。
tailであれば、動く。
tail _exは引き続き調査してみることにしよう・・
tail _exは引き続き調査してみることにしよう・・
2015年10月22日木曜日
node.jsでのログ出力:log4js
node.jsでのlog4jsを使ったログ出力について備忘録。
log4js
javaで使われいてるlog4のjavascript版のlog4jsをNode.jsにコンバージョンしたもの。
https://github.com/nomiddlename/log4js-node
特徴的な機能としては次のようなものがある。
■インストール
まずはモジュールのインストール。
次に出力設定ファイルを、外部ファイルとして作成する。
log4js_config.json
上記のlevelsで使用できる値は以下の通り。
以下は実装例。
log4js
javaで使われいてるlog4のjavascript版のlog4jsをNode.jsにコンバージョンしたもの。
https://github.com/nomiddlename/log4js-node
特徴的な機能としては次のようなものがある。
- Node.jsのConsoleログを置き換えられる
- file appenderでは、ファイルサイズでローテーションができる
- メール送信ができる(smtp appender)
- logstashに送信できる(Logstash UDP appender)
- Workerプロセス構成のときに使えるmultiprocess appender
- それぞれのカテゴリにそれぞれのログレベルで出力を設定できる
■インストール
まずはモジュールのインストール。
$ npm install log4js --save
次に出力設定ファイルを、外部ファイルとして作成する。
log4js_config.json
{
"appenders": [
{
"type": "File",
"category": "system",
"maxLogSize": 1048576,
"backups": 3,
"compress":true,
"filename": "logs/system.log"
},
{
"type": "dateFile",
"category": "access",
"filename": "logs/access.log",
"pattern": "-yyyy-MM-dd"
},
{
"type": "dateFile",
"category": "error",
"filename": "logs/error.log",
"pattern": "-yyyy-MM-dd"
},
{
"type": "console",
"category": "test"
}
],
"levels": {"system": "INFO"},
"replaceConsole": true
}
上記を例に設定内容の記載。
| appenders | type | dateFile | ローテーション対応したファイルへの出力 |
| file | ただのファイルへの出力 | ||
| console | すべてをconsoleへの出力 | ||
| category | 出力するログの設定の単位。カテゴリごとに設定をすることができる。 | ||
| filename | 出力するファイルの名前 | ||
| pattern | Outputストリーム。デフォルトは、process.stdoutになっている | ||
| maxLogSize | typeがfileの場合の最大ファイルサイズ(bytes) | ||
| backups | backup世代数 | ||
| compress | typeがfileの場合のオプションで、gzipをするかどうか?フラグ | ||
| levels | 出力するログレベルを設定。例では、categoryがsystemのものをINFOレベル以上で出力するという設定 | ||
| replaceConsole | typeにconsoleが指定されていた場合、consoleへの出力フォーマットが通常のログ形式と同じになる設定 | ||
上記のlevelsで使用できる値は以下の通り。
| ALL | すべて出力 |
| TRACE | TRACE 以上を出力 |
| DEBUG | DEBUG 以上を出力 |
| INFO | INFO 以上を出力 |
| WARN | WARN 以上を出力 |
| ERROR | ERROR 以上を出力 |
| FATAL | FATAL 以上を出力 |
| MARK | MARK 以上を出力 |
| OFF | 出力しない |
以下は実装例。
// モジュールの取り込み
var log4js = require('log4js');
// 設定ファイルの取り込み(ファイルは環境変数:LOG4JS_CONFIGに指定してもよい)
// reloadSecsはオプション(byou )。通常は60秒間隔で設定ファイルがReloadされる。
log4js.configure('path/log4js_config.json', { reloadSecs: 300 });
// 設定がいるを絶対パスで記載することもできる。
log4js.configure('log4js_config.json', { cwd: '/absolute/path/to/log/dir' });
// 出力するカテゴリの指定
var logger = log4js.getLogger('system');
// 出力レベルの設定(設定ファイルのlevelsに相当)
logger.setLevel('ERROR');
// 出力
logger.trace('Entering cheese testing');
logger.debug('Got cheese.');
logger.info('Cheese is Gouda.');
logger.warn('Cheese is quite smelly.');
logger.error('Cheese is too ripe!');
logger.fatal('Cheese was breeding ground for listeria.');
2015年10月10日土曜日
graphiteの環境の構築
CentOS 6.5
■Graphiteの構成
Graphite-Web
Carbon
Whisper
■graphiteのインストール準備
graphiteをpip(pythonのパッケージ管理ツール)でインストールする。(本家サイトを参照)
■graphiteのインストール
では、さっそくgraphiteのインストールを始める。
デフォルトでは、/opt/graphite/にインストールされる。とマニュアルにあるが、
/usr/lib/python2.6/site-packages/opt/graphite/
に出来上がっている。/opt/graphiteにまとめておきたいので、インストールし直し。
■graphiteのセットアップ(本家サイトを参照)
graphite-webでは、local_settings.pyを読み込んで設定されるみたいなので、設定を変更する。
サイトのページには
/opt/graphite/webapp/graphite/local_settings.py
があると記載があったが、見あたらなかった。exampleファイルがあったので、コピーして使う。
・carbon.conf
carbonデーモン用の設定ファイル。ファイル内のセクションは
[cache]・・・carbon-cacheに関する設定ファイル
$ cp carbon.conf.example carbon.conf
・storage-schemas.conf
・ファイルの上から順に適用される
・正規表現が使える
・メトリクス名にマッチした最初のパターンが使われる
・最初にメトリクスが送られた来たときに、保持期限が設定される
・この設定が変更されても、生成済みwspファイルには反映されない。whisper-resize.pyを使って変更する必要がある。
とのこと。
記載例)
[apache_busyWorkers]
pattern = ^servers\.www.*\.workers\.busyWorkers$
retentions = 15s:7d,1m:21d,15m:5y
1行目はセクション名。2行目は
3行目は、7日間は15秒間平均(デフォルトは平均)、21日間は1分平均、5年間は15分平均
という意味になる。
今回はデフォルトで。
$ cp storage-schemas.conf.example storage-schemas.conf
$ less storage-schemas.conf
Schema definitions for Whisper files. Entries are scanned in order,
# and first match wins. This file is scanned for changes every 60 seconds.
#
# [name]
# pattern = regex
# retentions = timePerPoint:timeToStore, timePerPoint:timeToStore, ...
# Carbon's internal metrics. This entry should match what is specified in
# CARBON_METRIC_PREFIX and CARBON_METRIC_INTERVAL settings
[carbon]
pattern = ^carbon\.
retentions = 60:90d
[default_1min_for_1day]
pattern = .*
retentions = 60s:1d
■Graphiteの構成
Graphite-Web
Carbon
Whisper
■graphiteのインストール準備
graphiteをpip(pythonのパッケージ管理ツール)でインストールする。(本家サイトを参照)
#graphiteの構成要素のcarbonをインストールするために、pythonの開発ヘッダーを入れる。 $ sudo yum install python-devel #pipのセットアップを行うため、setuptoolsをインストールする $ wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python #続いてpipのインストール $ curl -kL https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python準備完了!
■graphiteのインストール
では、さっそくgraphiteのインストールを始める。
$ sudo pip install https://github.com/graphite-project/ceres/tarball/master $ sudo pip install whisper $ sudo pip install carbon $ sudo pip install graphite-web特にエラーなし。
デフォルトでは、/opt/graphite/にインストールされる。とマニュアルにあるが、
/usr/lib/python2.6/site-packages/opt/graphite/
に出来上がっている。/opt/graphiteにまとめておきたいので、インストールし直し。
$ sudo pip uninstall carbon $ sudo pip uninstall graphite-web $ sudo pip install carbon --install-option="--prefix=/opt/graphite" --install-option="--install-lib=/op¥t/graphite/lib" $ sudo pip install graphite-web --install-option="--prefix=/opt/graphite" --install-option="--install-lib=/opt/graphite/lib" $ ls /opt/graphite bin conf examples lib storage webapp
■graphiteのセットアップ(本家サイトを参照)
graphite-webでは、local_settings.pyを読み込んで設定されるみたいなので、設定を変更する。
サイトのページには
/opt/graphite/webapp/graphite/local_settings.py
があると記載があったが、見あたらなかった。exampleファイルがあったので、コピーして使う。
$ mkdir /opt/graphite/webapp/graphite $ cd /opt/graphite/webapp/graphite $ cp /opt/graphite/lib/graphite/local_settings.py.example ./local_settings.py $ sudo vi local_settings.py#以下、変更箇所
TIME_ZONE = 'Asia/Tokyo' LOG_RENDERING_PERFORMANCE = True LOG_CACHE_PERFORMANCE = True LOG_METRIC_ACCESS = True
■carbonのセットアップ(本家サイトを参照)
・carbon.conf
carbonデーモン用の設定ファイル。ファイル内のセクションは
[cache]・・・carbon-cacheに関する設定ファイル
[relay]・・・carbon-relayに関する設定
[aggregator]・・・carbon-aggregatorに関する設定
今回は設定変更なし進める。
・storage-schemas.conf
メトリクスの保持期間の設定をするためのファイル。ここの設定でwhisperに伝達する。
この設定のポイントは・ファイルの上から順に適用される
・正規表現が使える
・メトリクス名にマッチした最初のパターンが使われる
・最初にメトリクスが送られた来たときに、保持期限が設定される
・この設定が変更されても、生成済みwspファイルには反映されない。whisper-resize.pyを使って変更する必要がある。
とのこと。
記載例)
[apache_busyWorkers]
pattern = ^servers\.www.*\.workers\.busyWorkers$
retentions = 15s:7d,1m:21d,15m:5y
1行目はセクション名。2行目は
3行目は、7日間は15秒間平均(デフォルトは平均)、21日間は1分平均、5年間は15分平均
という意味になる。
今回はデフォルトで。
$ cp storage-schemas.conf.example storage-schemas.conf
$ less storage-schemas.conf
Schema definitions for Whisper files. Entries are scanned in order,
# and first match wins. This file is scanned for changes every 60 seconds.
#
# [name]
# pattern = regex
# retentions = timePerPoint:timeToStore, timePerPoint:timeToStore, ...
# Carbon's internal metrics. This entry should match what is specified in
# CARBON_METRIC_PREFIX and CARBON_METRIC_INTERVAL settings
[carbon]
pattern = ^carbon\.
retentions = 60:90d
[default_1min_for_1day]
pattern = .*
retentions = 60s:1d
すべてのデータを60秒間平均で1日保持。
$ /opt/graphite/bin/carbon-cache.py start
・
・
ImportError: Twisted requires zope.interface 3.6.0 or later: no module named zope.interface.
$ sudo pip install zope.interface==3.6.0
$ sudo /opt/graphite/bin/carbon-cache.py start
・
・
Starting carbon-cache (instance a)
#ログも確認してみる
$ cd /opt/graphite/storage/log/carbon-cache/
$ ls
carbon-cache-a
$ cd carbon-cache-a
$ less console.log
10/10/2015 23:39:36 :: Log opened.
10/10/2015 23:39:36 :: twistd 15.4.0 (/usr/bin/python 2.6.6) starting up.
10/10/2015 23:39:36 :: reactor class: twisted.internet.epollreactor.EPollReactor.
10/10/2015 23:39:36 :: ServerFactory starting on 2003
10/10/2015 23:39:36 :: Starting factory <twisted.internet.protocol.ServerFactory instance at 0x308e290>
10/10/2015 23:39:36 :: ServerFactory starting on 2004
10/10/2015 23:39:36 :: Starting factory <twisted.internet.protocol.ServerFactory instance at 0x3097b90>
10/10/2015 23:39:36 :: ServerFactory starting on 7002
10/10/2015 23:39:36 :: Starting factory <twisted.internet.protocol.ServerFactory instance at 0x3097bd8>
10/10/2015 23:40:36 :: /opt/graphite/conf/storage-aggregation.conf not found, ignoring.
10/10/2015 23:41:36 :: /opt/graphite/conf/storage-aggregation.conf not found, ignoring.
10/10/2015 23:42:36 :: /opt/graphite/conf/storage-aggregation.conf not found, ignoring.
10/10/2015 23:43:36 :: /opt/graphite/conf/storage-aggregation.conf not found, ignoring.
■carbonの実行
$ /opt/graphite/bin/carbon-cache.py start
・
・
ImportError: Twisted requires zope.interface 3.6.0 or later: no module named zope.interface.
エラーが出た。調べてみると、とりあえずzope.interface自体をインストールする方法があるらしい。
$ sudo pip install zope.interface==3.6.0
$ sudo /opt/graphite/bin/carbon-cache.py start
・
・
Starting carbon-cache (instance a)
$ cd /opt/graphite/storage/log/carbon-cache/
$ ls
carbon-cache-a
$ cd carbon-cache-a
$ less console.log
10/10/2015 23:39:36 :: Log opened.
10/10/2015 23:39:36 :: twistd 15.4.0 (/usr/bin/python 2.6.6) starting up.
10/10/2015 23:39:36 :: reactor class: twisted.internet.epollreactor.EPollReactor.
10/10/2015 23:39:36 :: ServerFactory starting on 2003
10/10/2015 23:39:36 :: Starting factory <twisted.internet.protocol.ServerFactory instance at 0x308e290>
10/10/2015 23:39:36 :: ServerFactory starting on 2004
10/10/2015 23:39:36 :: Starting factory <twisted.internet.protocol.ServerFactory instance at 0x3097b90>
10/10/2015 23:39:36 :: ServerFactory starting on 7002
10/10/2015 23:39:36 :: Starting factory <twisted.internet.protocol.ServerFactory instance at 0x3097bd8>
10/10/2015 23:40:36 :: /opt/graphite/conf/storage-aggregation.conf not found, ignoring.
10/10/2015 23:41:36 :: /opt/graphite/conf/storage-aggregation.conf not found, ignoring.
10/10/2015 23:42:36 :: /opt/graphite/conf/storage-aggregation.conf not found, ignoring.
10/10/2015 23:43:36 :: /opt/graphite/conf/storage-aggregation.conf not found, ignoring.
ちゃん起動しているようです。
2015年9月23日水曜日
node.jsでのログ出力:morgan
node.jsでのログ出力について備忘録。
morgan
express 4でアクセスログ出力に使われているモジュール。
参考にささせていただいたのは以下のサイト。
http://qiita.com/hoshi-takanori/items/7f5602d7fd7ee0fa6427
https://github.com/expressjs/morgan
■インストール
1.package.jsonに追加
例:
2.インストール
$ npm install
(expressでテンプレートを作るとついてくる)
書式:morgan(format[, options])
"format"は、ログのフォーマットを指定する引数。あらかじめ定義されたフォーマットがある。
combined
Apache combinedログフォーマット。デフォルト。tokenを使って書くと以下の通り
使用できるtokenは以下の通り。
また作成することもできる。以下は、content-typeを示す"type"というtokenを作成する例。
・使用例
morganの実施の使用例を以下に。
ログをファイルに出力する例
pathモジュールを入れておく。
https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options
ログファイルをローテーションする例。
file-stream-rotatorというモジュールを使う。
独自tokenを使う例
Webアプリなどでも使われる(らしい)UUIDを生成して、それをログに記録する例。
https://github.com/broofa/node-uuid
◆winston
morgan
express 4でアクセスログ出力に使われているモジュール。
参考にささせていただいたのは以下のサイト。
http://qiita.com/hoshi-takanori/items/7f5602d7fd7ee0fa6427
https://github.com/expressjs/morgan
■インストール
1.package.jsonに追加
例:
{
"name": "sample_prject",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "~1.12.4",
"cookie-parser": "~1.3.5",
"debug": "~2.2.0",
"ejs": "~2.3.1",
"express": "~4.12.4",
"morgan": "~1.5.3",
"serve-favicon": "~2.2.1",
"validator": "^3.40.1"
}
}
2.インストール
$ npm install
(expressでテンプレートを作るとついてくる)
書式:morgan(format[, options])
"format"は、ログのフォーマットを指定する引数。あらかじめ定義されたフォーマットがある。
combined
Apache combinedログフォーマット。デフォルト。tokenを使って書くと以下の通り
:remote-addr - :remote-user [:date[clf]] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"
出力される内容は以下の通り。
::ffff:192.168.33.1 - - [23/Sep/2015:17:04:07 +0000] "GET / HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36"
| format | combined | Apache combinedログフォーマット。デフォルト。tokenを使って書くと以下の通り
|
| common | Apache commonログフォーマット。tokenを使って書くと以下の通り
| |
| dev | http status code毎に色付けして表示されるログ。サーバエラーの場合は赤、クライアントエラーの場合は黄色、Ridirectはシアンで表示される。tokenを使って書くと以下の通り
| |
| short | デフォルト(combined)より短いフォーマット。tokenを使って書くと以下の通り
| |
| tiny | 一番短いログフォーマット。tokenを使って書くと以下の通り
| |
| options | immediate | リクエストを受けた時点でログ出力をする。サーバがCrashしたとき絵も出力されるが、レスポンス時間やコンテキスト長などレスポンスに関する情報は記録されない |
| skip | 特定の条件でログを出力しない場合に使う。以下の例では、HTTPのステータスコードが400未満の場合はログ出力をしない。デフォルトは、falseになっている(つまりすべて出力)。 例)
| |
| stream | Outputストリーム。デフォルトは、process.stdoutになっている |
使用できるtokenは以下の通り。
| :date[format] | 現時刻。指定できるフォーマットは以下の通り。 clf common log format。例:10/Oct/2000:13:55:36 +0000 iso ISO 8601 date time format。例:2000-10-10T13:55:36.000Z web RFC1123 date time format。例:Tue, 10 Oct 2000 13:55:36 GMT |
| :http-version | リクエストされたHTTPのバージョン |
| :method | リクエストのHTTPメソッド |
| :referrer | リクエストのReferrerヘッダー。ミススペルでRefererがあった場合はそれを使う。 |
| :remote-addr | リクエストのリモートアドレス。req.ipが使われる。そうでなければreq.connection.remoteAddressが使われる |
| :remote-user | 基本認証された場合のユーザID。 |
| :req[header] | リクエストの[header]で指定されたヘッダー |
| :res[header] | レスポンスの[header]で指定されたヘッダー |
| :response-time | リクエストがmorganに来てから、レスポンスヘッダーがかかれるまでの所要時間(ms) |
| :status | レスポンスのstatus code。レスポンスがクライアントに送信される前に、クライアント側からTCP/IPセッションがクローズされるなどが発生した場合は、ブランクとなる。 |
| :url | リクエストされたURL。req.originalUrlがあればそれを、なければreq.urlが使われる |
| :user-agent | リクエストのUser-Agentヘッダーの値。 |
また作成することもできる。以下は、content-typeを示す"type"というtokenを作成する例。
morgan.token('type', function(req, res){ return req.headers['content-type']; })
・使用例
morganの実施の使用例を以下に。
ログをファイルに出力する例
pathモジュールを入れておく。
$ npm install path --save
var express = require('express')
var fs = require('fs')
var morgan = require('morgan')
var app = express()
// create a write stream (in append mode)
var accessLogStream = fs.createWriteStream(__dirname + '/access.log', {flags: 'a'})
// setup the logger
app.use(morgan('combined', {stream: accessLogStream}))
app.get('/', function (req, res) {
res.send('hello, world!')
})
ちなみに、createWriteStreamの仕様については以下を参照。https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options
ログファイルをローテーションする例。
file-stream-rotatorというモジュールを使う。
$ npm install file-stream-rotator --save
var FileStreamRotator = require('file-stream-rotator')
var express = require('express')
var fs = require('fs')
var morgan = require('morgan')
var app = express()
var logDirectory = __dirname + '/log'
// ディレクトリがなければ作成する
fs.existsSync(logDirectory) || fs.mkdirSync(logDirectory)
// write streamをローテーションする設定
var accessLogStream = FileStreamRotator.getStream({
filename: logDirectory + '/access-%DATE%.log',
frequency: 'daily',
verbose: false,
date_format: "YYYY-MM-DD"
})
// 今回はcombinedで出力
app.use(morgan('combined', {stream: accessLogStream}))
app.get('/', function (req, res) {
res.send('hello, world!')
})
独自tokenを使う例
Webアプリなどでも使われる(らしい)UUIDを生成して、それをログに記録する例。
var express = require('express')
var morgan = require('morgan')
var uuid = require('node-uuid')
morgan.token('id', function getId(req) {
return req.id
})
var app = express()
app.use(assignId)
app.use(morgan(':id :method :url :response-time'))
app.get('/', function (req, res) {
res.send('hello, world!')
})
function assignId(req, res, next) {
req.id = uuid.v4()
next()
}
ちなみに、node-uuidの仕様については以下を参照。https://github.com/broofa/node-uuid
◆winston
2015年6月26日金曜日
Let's Chatを入れてみた
slackを使っていのだけど、やはりプロジェクトによっては社外のサービスを使うのはなぁ?という懸念が上がるときがある。抜け道を考えるのが面倒なので、社内にChatサーバーを立ててることにした(BYOSというの?)。折角なのでSlack風Chatの「Let's Chat」を使ってみようと思ったので、備忘録。
0.環境準備
使った環境は以下の通り。
・vagrant
・CentOS 6.5
・Let's Chat 0.3.12
1.インストール
Let's Chatの導入要件となっている、以下のツール群を導入する。
・nodejs v0.12.4
・mongodb 3.0
・Python 2.7
1.1 nodejsを入れる
ここを参照しつつ入れる!
1.2 mongodbを入れる
$ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.0.3.tgz
$ tar xvfz mongodb-linux-x86_64-rhel62-3.0.3.tgz
$ cd mongodb-linux-x86_64-rhel62-3.0.3 mongo
1.3 python2.7を入れる
$ wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
$ tar xvfz Python-2.7.6.tgz
$ cd Python-2.7.6
$ ./configure --enable-shared --with-threads
$ make
$ sudo make install
$ python -V
python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
なんだかエラーがでてる。
$ ldd /usr/local/bin/python
linux-vdso.so.1 => (0x00007fffc0ad3000)
libpython2.7.so.1.0 => not found
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f112bed4000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f112bcd0000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007f112bacd000)
libm.so.6 => /lib64/libm.so.6 (0x00007f112b848000)
libc.so.6 => /lib64/libc.so.6 (0x00007f112b4b4000)
/lib64/ld-linux-x86-64.so.2 (0x00007f112c0fb000)
といストールされている。のでリンクで対応する。
$ sudo ln /usr/local/lib/libpython2.7.so.1.0 /lib64/libpython2.7.so.1.0
$ python -V
Python 2.7.6
1.4 Let's Chatを入れる
最後にLet's Chatを入れる。
$ git clone https://github.com/sdelements/lets-chat.git
$ cd lets-chat/
$ npm install
gyp: Call to 'which icu-config > /dev/null || echo n' returned exit status 0. while trying to load binding.gyp
$ npm install
4.ldap認証
デフォルトでは、local認証となっていて、さらに自由にアカウント登録ができてしまう。今回インターネット経由でアクセスをさせるので、この状態はよろしくない。
とうことで、openldapを立てて、アカウント管理!
※openldapの導入はこちら。
settings.yml
===
auth:
providers: [ldap]
ldap:
connect_settings:
url: ldap://192.168.x.x:389/
bind_options:
bindDN: uid=bind,ou=Account,dc=example,dc=com
bindCredentials: password
search:
base: "ou=Account,dc=example,dc=com"
opts:
scope: one
filter: (uid={{username}})
#filter: (sAMAccountName={{username}})
field_mappings:
uid: uid
firstName: givenName
lastName: sn
displayName: givenName
email: mail
0.環境準備
使った環境は以下の通り。
・vagrant
・CentOS 6.5
・Let's Chat 0.3.12
1.インストール
Let's Chatの導入要件となっている、以下のツール群を導入する。
・nodejs v0.12.4
・mongodb 3.0
・Python 2.7
ここを参照しつつ入れる!
1.2 mongodbを入れる
$ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.0.3.tgz
$ tar xvfz mongodb-linux-x86_64-rhel62-3.0.3.tgz
$ cd mongodb-linux-x86_64-rhel62-3.0.3 mongo
1.3 python2.7を入れる
$ wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
$ tar xvfz Python-2.7.6.tgz
$ cd Python-2.7.6
$ ./configure --enable-shared --with-threads
$ make
$ sudo make install
$ python -V
python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
なんだかエラーがでてる。
$ ldd /usr/local/bin/python
linux-vdso.so.1 => (0x00007fffc0ad3000)
libpython2.7.so.1.0 => not found
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f112bed4000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f112bcd0000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007f112bacd000)
libm.so.6 => /lib64/libm.so.6 (0x00007f112b848000)
libc.so.6 => /lib64/libc.so.6 (0x00007f112b4b4000)
/lib64/ld-linux-x86-64.so.2 (0x00007f112c0fb000)
同じですが、libpython2.7.so.1.0がないと言われている。ただ実際には、、
$ sudo find / -name 'libpython2.7.so.1.0'
/home/vagrant/Python-2.7.6/libpython2.7.so.1.0
/usr/local/lib/libpython2.7.so.1.0
といストールされている。のでリンクで対応する。
$ sudo ln /usr/local/lib/libpython2.7.so.1.0 /lib64/libpython2.7.so.1.0
$ python -V
Python 2.7.6
無事。インストールができたみたいです。
1.4 Let's Chatを入れる
最後にLet's Chatを入れる。
$ git clone https://github.com/sdelements/lets-chat.git
$ cd lets-chat/
$ npm install
gyp: Call to 'which icu-config > /dev/null || echo n' returned exit status 0. while trying to load binding.gyp
何やらエラーがでて失敗した。ライブラリを追加で入れる。
$ sudo yum install libicu-devel.x86_64
で、再チャレンジです
・
・
node-xmpp-core@1.0.0-alpha14 node_modules/node-xmpp-core
├- tls-connect@0.2.2
├- debug@2.2.0 (ms@0.7.1)
├- reconnect-core@0.0.1 (backoff@2.3.0)
├- node-stringprep@0.7.0 (bindings@1.2.1, debug@2.0.0, nan@1.8.4)
└- mqq ltx@0.9.0 (sax@0.6.1, node-expat@2.3.8)
をーインストール完了。
2. Let's Chatの設定
$ cp settings.yml.sample settings.yml
$ vi settings.yml
#
# See defaults.yml for all available options
#
env: production # development / production
http:
enable: true
host: '0.0.0.0'
port: 80
https:
enable: false
port: 5001
key: key.pem
cert: certificate.pem
files:
enable: true
provider: local
local:
dir: uploads
xmpp:
enable: false
port: 5222
domain: example.com
database:
uri: mongodb://localhost/letschat
secrets:
cookie: secretsauce
auth:
providers: [local]
local:
enableRegistration: true
================
# Let's Chat Settings#
# See defaults.yml for all available options
#
env: production # development / production
http:
enable: true
host: '0.0.0.0'
port: 80
https:
enable: false
port: 5001
key: key.pem
cert: certificate.pem
files:
enable: true
provider: local
local:
dir: uploads
xmpp:
enable: false
port: 5222
domain: example.com
database:
uri: mongodb://localhost/letschat
secrets:
cookie: secretsauce
auth:
providers: [local]
local:
enableRegistration: true
================
$ npm start
[Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
あがるっちゃ、あがるんだけど、エラーがでている。いろいろググってみたけど、
npm cache clean; rm -rf node_modules ;npm install
これで再インストールすればいけるみたい。
ということでやってみたら・・・行けた!
3.検索をカスタマイズ
chatの履歴から全文検索ができるようになっているのですが、、mongodbの全文検索機能を使っており、mongodbのそれは日本語には対応していない。なので、全くといっていいほど使えない。それだったらせめてmessagesの検索だけでも意味があるかなと思い、少しソースを修正。
lets-chat/app/core/messages.js
3.検索をカスタマイズ
chatの履歴から全文検索ができるようになっているのですが、、mongodbの全文検索機能を使っており、mongodbのそれは日本語には対応していない。なので、全くといっていいほど使えない。それだったらせめてmessagesの検索だけでも意味があるかなと思い、少しソースを修正。
lets-chat/app/core/messages.js
if (options.query) {
find = find.find({$text: {$search: options.query}});
}
find = find.find({$text: {$search: options.query}});
}
if (options.query) {
var r = new RegExp(options.query, "i")
find = find.find({"text": {$regex:r}});
var r = new RegExp(options.query, "i")
find = find.find({"text": {$regex:r}});
}
に変更してみた。これだけでも結構便利!
4.ldap認証
デフォルトでは、local認証となっていて、さらに自由にアカウント登録ができてしまう。今回インターネット経由でアクセスをさせるので、この状態はよろしくない。
とうことで、openldapを立てて、アカウント管理!
※openldapの導入はこちら。
settings.yml
===
auth:
providers: [ldap]
ldap:
connect_settings:
url: ldap://192.168.x.x:389/
bind_options:
bindDN: uid=bind,ou=Account,dc=example,dc=com
bindCredentials: password
search:
base: "ou=Account,dc=example,dc=com"
opts:
scope: one
filter: (uid={{username}})
#filter: (sAMAccountName={{username}})
field_mappings:
uid: uid
firstName: givenName
lastName: sn
displayName: givenName
email: mail
===
いや~バカになるくらいで簡単にできた・・。すごい!
2015年6月6日土曜日
サーバー証明書のCSR+オレオレ証明書の作り方
サーバー証明書の発行手順
1.秘密キーの生成
正式な商用サーバー証明書発行してもらう。
5.自己証明書を発行
1.秘密キーの生成
openssl genrsa -rand randfile 2048 > xxx.key
2.証明書(CSR)作成openssl req -new -sha256 -key xxx.key -out xxx.csr
3.証明書(CSR)の確認openssl req -noout -text -in xxx.csr
4.正式証明書を発行正式な商用サーバー証明書発行してもらう。
5.自己証明書を発行
$ openssl x509 -days 3650 -req -signkey xxx.key < xxx.csr > xxx.crt
5.自己証明書の確認$ openssl x509 -text < xxx.crt
OpenLdapを入れてみた
自PCにChatを導入してみようと思い(BYOS:Bring your own serverというらしい)、Slack風chatのLet's Chatを入れてみようとした。
デフォルトだとアカウントが自由に登録できちゃう。今回は特定ユーザだけどインターネット環境で利用することを考えると、さすがによろしくないなぁということで、ldap認証に変えようとopenldapの構築に思い立った・・
0.環境準備
CentOS : 6.5
openldap 2.4.
1.インストール
openldapのサーバー「openldap-servers」と、管理用コマンド「ldapadd」「ldapsearch」が含まれているクライアントパッケージ「openldap-clients」を入れる。
設定ファイルをコピーする
rootユーザ(管理者ユーザー)のパスワードを設定する
設定ファイルの修正をする(/etc/openldap/slapd.conf)
※設定ファイルを、設定ディレクトリ(/etc/openldap/slapd.d)に配置する場合
この設定をすると、起動時に設定ディレクトリが優先され、設定ファイルは無視される。
設定ファイルが無くなっても大丈夫になるが、簡単に設定変更ができなくなる。
どっちがいいんでしょう・・
ちなみに設定ディレクトリを作成しないと、デフォルトの起動スクリプトで起動すると、
2.データの登録・更新・削除
基本的にデータの登録・更新は、LDIFファイルを作成し、それをコマンドを使って反映というステップで行う。Apache Directory Studioを使うと楽にできたが、 とりあえず理解を深めるために、、地道に。 まずは、ベース ldapadd -x -D "cn=Manager,dc=example,dc=com" -W -f test.ldif.txt
登録データをコマンドで確認してみる。
ldapsearch -x -b dc=example,dc=com
削除は
ldapdelete -D "cn=Manager,dc=example,dc=com" -W "削除するDN"
ldapdelete -D "cn=Manager,dc=example,dc=com" -W "uid=bind,ou=Account,dc=example,dc=com"
修正は
ldapmodify -x -W -D cn=config -f loglevel.ldif
slappasswd -h '{CRYPT}'
3.その他
・登録ユーザのパスワード変更
$ ldappasswd -x -D "uid=<自分のアカウント>,ou=Account,dc=example,dc=com" -S -w <自分のパスワード> "uid=<自分のアカウント>,ou=Account,dc=example,dc=com"
・デバッグログ
openldapサーバーのログレベルの変更
vi /etc/openldap/slapd.conf
loglevel ACL
j設定ディレクトリを作成していると、上記の設定ファイルでログレベルを設定しても無視されて
しまう。ので動的にloglevelを変更する必要がある。ステップは、
・動的に設定変更をする際には、設定変更用のパスワードを設定する。
パスワードを生成する。
$ slappasswd -s [パスワード]
・パスワードを設定変ファイルに書き込む。
vi /etc/openldap/slapd.d/cn=config/olcDatabase={0}config.ldif
==
# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.
# CRC32 b65956a0
dn: olcDatabase={0}config
objectClass: olcDatabaseConfig
olcDatabase: {0}config
olcAccess: {0}to * by * none
olcAddContentAcl: TRUE
olcLastMod: TRUE
olcMaxDerefDepth: 15
olcReadOnly: FALSE
olcRootDN: cn=config
olcRootPW: {SSHA}bl2YB5/i9fZ64tMNV/7dr9li4a3YsNc0 (*)
olcSyncUseSubentry: FALSE
olcMonitoring: FALSE
structuralObjectClass: olcDatabaseConfig
entryUUID: ac9a77d2-a08f-1034-959f-516e801fdd3a
creatorsName: cn=config
createTimestamp: 20150606120240Z
entryCSN: 20150606120240.046232Z#000000#000#000000
modifiersName: cn=config
modifyTimestamp: 20150606120240Z
・ログ変更用のファイルを作成する
vi /etc/openldap/ldif/loglevel.ldif
===
dn: cn=config
changetype: modify
add: olcLogLevel
olcLogLevel: filter config ACL stats
・ldapmodifyコマンドで変更する
$ ldapmodify -x -W -D cn=config -f loglevel.ldif
Enter LDAP Password:
modifying entry "cn=config"
デフォルトだとアカウントが自由に登録できちゃう。今回は特定ユーザだけどインターネット環境で利用することを考えると、さすがによろしくないなぁということで、ldap認証に変えようとopenldapの構築に思い立った・・
0.環境準備
CentOS : 6.5
openldap 2.4.
1.インストール
openldapのサーバー「openldap-servers」と、管理用コマンド「ldapadd」「ldapsearch」が含まれているクライアントパッケージ「openldap-clients」を入れる。
$ sudo yum install -y openldap-servers openldap-clients
初期の設定を削除する$ sudo rm -rf /etc/openldap/slapd.d/*
$ sudo rm -rf /var/lib/ldap/*
設定ファイルをコピーする
$ sudo cp -a /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
$ sudo chown ldap. /var/lib/ldap/DB_CONFIG
$ sudo cp -a /usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/slapd.conf
rootユーザ(管理者ユーザー)のパスワードを設定する
$ slappasswd -s [パスワード]
{SSHA}bl2YB5/i9fZ64tMNV/7dr9li4a3YsNc0 ・・・(*1)
設定ファイルの修正をする(/etc/openldap/slapd.conf)
# スキーマファイル設定
include /etc/openldap/schema/corba.schema
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/duaconf.schema
include /etc/openldap/schema/dyngroup.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/java.schema
include /etc/openldap/schema/misc.schema
include /etc/openldap/schema/nis.schema
include /etc/openldap/schema/openldap.schema
include /etc/openldap/schema/ppolicy.schema
include /etc/openldap/schema/collective.schema
# 接続プロトコル
allow bind_v2
# 管理ファイル
pidfile /var/run/openldap/slapd.pid
argsfile /var/run/openldap/slapd.args
# userPasswordに関するアクセス権
access to attrs=userPassword
by self write
by dn="cn=Manager,dc=example,dc=com" write
by anonymous auth
by * none
# その他の属性に対するアクセス権
access to *
by self write
by dn="cn=Manager,dc=example,dc=com" write
by * read
# monitorデータベースに対するアクセス権
database monitor
access to *
by dn.exact="cn=Manager,dc=example,dc=com" read
by * none
# データベース設定
database bdb
suffix "dc=example,dc=com"
checkpoint 1024 15
rootdn "cn=Manager,dc=example,dc=com"
rootpw {SSHA}bl2YB5/i9fZ64tMNV/7dr9li4a3YsNc0 ・・・(*1)
directory /var/lib/ldap
# indexの設定
index objectClass eq,pres
index ou,cn,mail,surname,givenname eq,pres,sub
index uid,memberUid eq,pres,sub
設定ファイルのチェック$ sudo su -
# sudo -u ldap slaptest -u -v -f /etc/openldap/slapd.conf
config file testing succeeded
※設定ファイルを、設定ディレクトリ(/etc/openldap/slapd.d)に配置する場合
# sudo -u ldap slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d
config file testing succeeded
この設定をすると、起動時に設定ディレクトリが優先され、設定ファイルは無視される。
設定ファイルが無くなっても大丈夫になるが、簡単に設定変更ができなくなる。
どっちがいいんでしょう・・
ちなみに設定ディレクトリを作成しないと、デフォルトの起動スクリプトで起動すると、
ls: cannot access /etc/openldap/slapd.d//cn=config/olcDatabase*.ldif: そのようなファイルやディレクトリはありません
というエラーがでる。無視できそうだけど・・わかっていないので、設定ディレクトリを使って進める。
$ sudo service slapd start
$ chkconfig slapd on
あとはログの取得設定をしておく。rsyslogの設定ファイルに以下を追加する(/etc/rsyslog.conf)local4.* /var/log/ldap.log
でもって再起動。
$ sudo service rsyslog restart
2.データの登録・更新・削除
基本的にデータの登録・更新は、LDIFファイルを作成し、それをコマンドを使って反映というステップで行う。Apache Directory Studioを使うと楽にできたが、 とりあえず理解を深めるために、、地道に。 まずは、ベース ldapadd -x -D "cn=Manager,dc=example,dc=com" -W -f test.ldif.txt
登録データをコマンドで確認してみる。
ldapsearch -x -b dc=example,dc=com
削除は
ldapdelete -D "cn=Manager,dc=example,dc=com" -W "削除するDN"
ldapdelete -D "cn=Manager,dc=example,dc=com" -W "uid=bind,ou=Account,dc=example,dc=com"
修正は
ldapmodify -x -W -D cn=config -f loglevel.ldif
slappasswd -h '{CRYPT}'
3.その他
・登録ユーザのパスワード変更
$ ldappasswd -x -D "uid=<自分のアカウント>,ou=Account,dc=example,dc=com" -S -w <自分のパスワード> "uid=<自分のアカウント>,ou=Account,dc=example,dc=com"
・デバッグログ
openldapサーバーのログレベルの変更
vi /etc/openldap/slapd.conf
loglevel ACL
j設定ディレクトリを作成していると、上記の設定ファイルでログレベルを設定しても無視されて
しまう。ので動的にloglevelを変更する必要がある。ステップは、
・動的に設定変更をする際には、設定変更用のパスワードを設定する。
パスワードを生成する。
$ slappasswd -s [パスワード]
・パスワードを設定変ファイルに書き込む。
vi /etc/openldap/slapd.d/cn=config/olcDatabase={0}config.ldif
==
# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.
# CRC32 b65956a0
dn: olcDatabase={0}config
objectClass: olcDatabaseConfig
olcDatabase: {0}config
olcAccess: {0}to * by * none
olcAddContentAcl: TRUE
olcLastMod: TRUE
olcMaxDerefDepth: 15
olcReadOnly: FALSE
olcRootDN: cn=config
olcRootPW: {SSHA}bl2YB5/i9fZ64tMNV/7dr9li4a3YsNc0 (*)
olcSyncUseSubentry: FALSE
olcMonitoring: FALSE
structuralObjectClass: olcDatabaseConfig
entryUUID: ac9a77d2-a08f-1034-959f-516e801fdd3a
creatorsName: cn=config
createTimestamp: 20150606120240Z
entryCSN: 20150606120240.046232Z#000000#000#000000
modifiersName: cn=config
modifyTimestamp: 20150606120240Z
==
最初の2行を削除する
(*)の行を追加する。パスワードは上記で生成したものを指定する。
vi /etc/openldap/ldif/loglevel.ldif
===
dn: cn=config
changetype: modify
add: olcLogLevel
olcLogLevel: filter config ACL stats
===
2回目以降に更新する場合は、
add: olcLogLevel
を
replace: olcLogLevel
に変更する。
2回目以降に更新する場合は、
add: olcLogLevel
を
replace: olcLogLevel
に変更する。
・ldapmodifyコマンドで変更する
$ ldapmodify -x -W -D cn=config -f loglevel.ldif
Enter LDAP Password:
modifying entry "cn=config"
※パスワードは上記で生成したものを!
2015年5月6日水曜日
meanスタックの実行環境を整える
meanスタック + d3.js + bootstrap.jsを使ったアプリを作成してみたいので、そのサイトのための環境を作ってみる。
angular.jsと、d3.jsやbootstrap.jsを組み合わせるためには、
0 環境準備
インストールするには、node.jsとnpmが入っている環境が必要。ここでは割愛。
試す環境は以下の通り
・CentOS 6.5
・nodejs v0.12.0
・npm 2.5.1
1.bowerの環境構築
まず、javascriptのライブラリ管理ツールであるbowerを入れてみる。ライブラリの依存関係をまとめて管理してくれる。
とはいっても、指定したライブラリをgitからダウンロードしてくれるだけ見たいで、自動で依存するライブラリをダウンロードしてくれるだけではないし、格納ディレクトリもばらばらなので、実際に使うときのパス指定は、それぞれのライブラリによって異なる(のでまとまっている感は少ない)。
npmとの違いは、ここに記載されている内容からすると、npmはクライアントとサーバーをまとめて管理はできるものの、分けて管理ができない。bowerはクライアントサイドに特化した管理ツールであり、npmをサーバーサイドのライブラリ管理ツールとして使う。という使い分けをするみたいです。この後いれる、yoemanでも使うみたいです。このあたりのClient-Sideのlibrary管理はいろいろと議論があるみたいですね。
1.1 bowerのインストール
1.2 使ってみる
テストアプリとして、"apptest"をプロジェクトとして想定し進める。 初期化の時にいくつか質問がくるので、適当に入力する。質問の内容はqiita.comを参照
ちなみに「--save-dev」オプションは、開発環境のみで使用し、かつ環境移行ができるようbower.jsonに記録するためのオプション。本番でも使う場合は「--save」を使う。
その他のオプションは以下の通り
指定バージョンのライブラリをインストールする
(--save-devで保存されたライブラリはインストールされない)
2.grunt/gulp
javascriptのビルドツール群。gruntが先に出てきて、そのあとgulpが出てきたみたいです。
テンプレート作成ツール(yoemanなど)によってもどちらが適用しているか?があるみたいです。
なんとなくgulpのほうが新しくていい感じ。基本gulpを使うが、両方入れておけるので、とりあえず入れてみる。
2.1 grunt インストール
2.2 gruntを使ってみる(ちょっとインストールのつづきも)
gruntで
2.3 gulp インストール
gulpでファイルをコピーするタスクを実装してみる。
gruntと同じファイルをコピーするタスクを実装してみる。
3.yo
プロジェクトのひな型生成ツールで、テンプレートを指定することで、さまざまなプロジェクトのひな型を生成することができる。yoはNode.js上で動作するツールだが、phpやjavaなどのバックエンド側のひな型を生成できるジェネレーターも公開されているとのこと。
http://yeoman.io/generators/
3.1インストール
4.angularプロジェクトを作成してみる
以下の3つのgeneratorを試してみる。
4.1 generator-angular
・nodejs v0.10.38
・npm 2.9.0
再チャレンジ!
(2016/3/2追記)
proxy環境下で、bowerを使う場合の設定
angular.jsと、d3.jsやbootstrap.jsを組み合わせるためには、
- bower。javascriptなどのライブラリの管理を環境をつくる。
- gulp/grunt。コンパイル環境を作る
- yo。プロジェクトのひな形を作成するツール
- yoeman。上記3つを使って一連のワークフローを提供するツール。今回これを使って、angular.jsを使ったプロジェクトのひな形を作る。
- d3.jsを組み込む
0 環境準備
インストールするには、node.jsとnpmが入っている環境が必要。ここでは割愛。
試す環境は以下の通り
・CentOS 6.5
・nodejs v0.12.0
・npm 2.5.1
1.bowerの環境構築
まず、javascriptのライブラリ管理ツールであるbowerを入れてみる。ライブラリの依存関係をまとめて管理してくれる。
とはいっても、指定したライブラリをgitからダウンロードしてくれるだけ見たいで、自動で依存するライブラリをダウンロードしてくれるだけではないし、格納ディレクトリもばらばらなので、実際に使うときのパス指定は、それぞれのライブラリによって異なる(のでまとまっている感は少ない)。
npmとの違いは、ここに記載されている内容からすると、npmはクライアントとサーバーをまとめて管理はできるものの、分けて管理ができない。bowerはクライアントサイドに特化した管理ツールであり、npmをサーバーサイドのライブラリ管理ツールとして使う。という使い分けをするみたいです。この後いれる、yoemanでも使うみたいです。このあたりのClient-Sideのlibrary管理はいろいろと議論があるみたいですね。
1.1 bowerのインストール
$ npm install bower -g
・
・
・
$ bower -v
1.4.1
1.2 使ってみる
テストアプリとして、"apptest"をプロジェクトとして想定し進める。 初期化の時にいくつか質問がくるので、適当に入力する。質問の内容はqiita.comを参照
$ mkdir apptest && cd $_
$ bower init
? May bower anonymously report usage statistics to improve the tool over time? Yes
? name: apptest
? version: 0.0.1
? description: test site
? main file: index.js
? what types of modules does this package expose?
◯ amd
◯ es6
◯ globals
?? node
◯ yui
? keywords:
? authors:
? license: MIT
? homepage:
? set currently installed components as dependencies? Yes
? add commonly ignored files to ignore list? Yes
? would you like to mark this package as private which prevents it from being accidentally published to the registry? (y? would you like to mark this package as private which prevents it from being accidentally published to the registry? No
{
name: 'apptest',
version: '0.0.1',
description: 'test site',
main: 'index.js',
moduleType: [
'node'
],
license: 'MIT',
ignore: [
'**/.*',
'node_modules',
'bower_components',
'test',
'tests'
]
}
? Looks good? Yes
$ ls
bower.json
試しにangular.jsをインストールしてみる。
$ bower install angular --save-dev
bower angular#* cached git://github.com/angular/bower-angular.git#1.3.15
bower angular#* validate 1.3.15 against git://github.com/angular/bower-angular.git#*
bower angular#~1.3.15 install angular#1.3.15
angular#1.3.15 bower_components/angular
$
bower_componentsディレクトリの配下にインストールされている。$ ls -lR bower_components
bower_components:
total 4
drwxrwxr-x 2 nodejs nodejs 4096 Apr 12 08:29 angular
bower_components/angular:
total 1480
-rw-rw-r-- 1 nodejs nodejs 263 Mar 17 13:15 angular-csp.css
-rw-rw-r-- 1 nodejs nodejs 960560 Mar 17 13:15 angular.js
-rw-rw-r-- 1 nodejs nodejs 125909 Mar 17 13:15 angular.min.js
-rw-rw-r-- 1 nodejs nodejs 50407 Mar 17 13:15 angular.min.js.gzip
-rw-rw-r-- 1 nodejs nodejs 348935 Mar 17 13:15 angular.min.js.map
-rw-rw-r-- 1 nodejs nodejs 114 Mar 17 13:15 bower.json
-rw-rw-r-- 1 nodejs nodejs 48 Mar 17 13:15 index.js
-rw-rw-r-- 1 nodejs nodejs 573 Mar 17 13:15 package.json
-rw-rw-r-- 1 nodejs nodejs 1885 Mar 17 13:15 README.md
$
ちなみに「--save-dev」オプションは、開発環境のみで使用し、かつ環境移行ができるようbower.jsonに記録するためのオプション。本番でも使う場合は「--save」を使う。
その他のオプションは以下の通り
指定バージョンのライブラリをインストールする
$ bower install <library>#<バージョン>
ライブラリをアップデートする
$ bower update
bower自身をアップデートする
$ npm update -g bower
ライブラリをアンインストールする
$ bower uninstall <library>
ライブラリを検索する
$ bower search <library>
ライブラリの詳細を確認する
$ bower info <library>#<バージョン>
インストール済みのライブラリの一覧を出力する
$ bower list
別場所の環境で、--saveで保存したライブラリのみインストールする(--save-devで保存されたライブラリはインストールされない)
$ bower install --produnction
指定したライブラリの情報(バージョンなど)を入手する
$ bower info <library>
2.grunt/gulp
javascriptのビルドツール群。gruntが先に出てきて、そのあとgulpが出てきたみたいです。
テンプレート作成ツール(yoemanなど)によってもどちらが適用しているか?があるみたいです。
なんとなくgulpのほうが新しくていい感じ。基本gulpを使うが、両方入れておけるので、とりあえず入れてみる。
2.1 grunt インストール
$ npm install -g grunt-cli
$ gulp -v
[16:17:38] CLI version 3.8.11
[16:17:38] Local version 3.8.11
$ grunt -v
grunt-cli: The grunt command line interface. (v0.1.13)
Fatal error: Unable to find local grunt.
If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information about
installing and configuring grunt, please see the Getting Started guide:
http://gruntjs.com/getting-started
2.2 gruntを使ってみる(ちょっとインストールのつづきも)
gruntで
- 1.メッセージを出力する
- 2.ファイルをコピーするタスクを実装してみる
$ mkdir sample_grunt && cd $_
$ npm init
$ npm install grunt --save-dev
$ vi Gruntfile.js
module.exports = function(grunt) {
//Gruntの設定
grunt.initConfig({
pkg: grunt.file.readJSON('package.json')
});
//defaultタスクの定義
grunt.registerTask('default', 'LogProcess..', function() {
//ログメッセージの出力
grunt.log.write('message...').ok();
});
};
$ grunt
Running "default" task
message...OK
Done, without errors.
$
"message"を出力できました。次にファイルコピーをする処理を実装してみる。
$ npm install grunt-contrib-copy --save-dev
$ vi Gruntfile.js
'use strict'
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
//コピーを実行するタスク
copy: {
main:{
files: [ {
//src/jsディレクトリ以下のファイルをコピー
expand: true,
flatten: true,
src: ['src/js/*'],
dest: 'dest/js'
}, {
//src/htmlディレクトリ以下のファイルをコピー
expand: true,
flatten: true,
src: ['src/html/*'],
dest: 'dest/html'
}]
}
}
});
// Load tasks(grunt実行時に読み込むプラグイン)
grunt.loadNpmTasks('grunt-contrib-copy');
// Default tasks(grunt実行時に実行するタスク)
grunt.registerTask('default', ['copy']); //(*)
};
上記の処理は、 ・「src/js/*」を、「dest/js/」にコピーをした後に ・「src/html/*」の中身を、「dest/html」にコピーを実施する という内容になる。 また上記の(*)の行は、実行時にtaskの指定がない場合に実行されるタスクを記載しています(この例では、上記のコピー処理(copyというtask名)を実施することと同じ。次にテストファイルを用意する
$ mkdir -p src/js src/html
$ touch src/js/test.js src/html/test.html
$ ls -lR src
src:
total 8
drwxrwxr-x 2 nodejs nodejs 4096 May 5 14:05 html
drwxrwxr-x 2 nodejs nodejs 4096 May 5 14:05 js
src/html:
total 0
-rw-rw-r-- 1 nodejs nodejs 0 May 5 14:05 test.html
src/js:
total 0
-rw-rw-r-- 1 nodejs nodejs 0 May 5 14:05 test.js
$ grunt
Running "copy:main" (copy) task
Copied 2 files
Done, without errors.
$ ls -lR dest
dest:
total 8
drwxrwxr-x 2 nodejs nodejs 4096 May 5 14:06 html
drwxrwxr-x 2 nodejs nodejs 4096 May 5 14:06 js
dest/html:
total 0
-rw-rw-r-- 1 nodejs nodejs 0 May 5 14:05 test.html
dest/js:
total 0
-rw-rw-r-- 1 nodejs nodejs 0 May 5 14:05 test.js
コピー先はディレクトリも作成してくれてるみたいですね。
2.3 gulp インストール
gulpでファイルをコピーするタスクを実装してみる。
npm install -g gulp
$ gulp -v
[16:17:38] CLI version 3.8.11
[16:17:38] Local version 3.8.11
2.4 gulp を使ってみる
gruntと同じファイルをコピーするタスクを実装してみる。
$ mkdir sample_gulp && cd $_
$ vi gulpfile.js
'use strict'
var gulp = require('gulp');
//コピーを実行するタスク
gulp.task('copy', function() {
//src/jsディレクトリ以下のファイルをコピー
gulp.src('src/js/**')
.pipe(gulp.dest('dest/js'));
//src/htmlディレクトリ以下のファイルをコピー
gulp.src('src/html/**')
.pipe(gulp.dest('dest/html'));
});
//デフォルトタスク定義
gulp.task('default', function() {
gulp.run('copy');
});
$ mkdir -p src/js src/html
$ touch src/js/test.js src/html/test.html
$ gulp
[13:20:47] Using gulpfile ~/sample_gulp/gulpfile.js
[13:20:47] Starting 'default'...
gulp.run() has been deprecated. Use task dependencies or gulp.watch task triggering instead.
[13:20:47] Starting 'copy'...
[13:20:47] Finished 'copy' after 23 ms
[13:20:47] Finished 'default' after 25 ms
$ ls -lR dest/
dest/:
total 8
drwxrwxr-x 2 nodejs nodejs 4096 May 5 13:20 html
drwxrwxr-x 2 nodejs nodejs 4096 May 5 13:20 js
dest/html:
total 0
-rw-rw-r-- 1 nodejs nodejs 0 May 5 13:20 touch.html
dest/js:
total 0
-rw-rw-r-- 1 nodejs nodejs 0 May 5 13:20 touch.js
gruntと同じくコピーされましたね。3.yo
プロジェクトのひな型生成ツールで、テンプレートを指定することで、さまざまなプロジェクトのひな型を生成することができる。yoはNode.js上で動作するツールだが、phpやjavaなどのバックエンド側のひな型を生成できるジェネレーターも公開されているとのこと。
http://yeoman.io/generators/
3.1インストール
$ npm install yo -g
で実行してみたが、待てど暮らせど終わらない。。3時間たっても終わらないので、いったん終了させて、debugモードで状況を確認してみたら、、、$ npm install yo -g --loglevel verbose
今度はエラーなしでうまくいった。。まぁうまくいったから、とりあえずいいか。4.angularプロジェクトを作成してみる
以下の3つのgeneratorを試してみる。
・generator-angular オフィシャルなGenerator。yoemanのサンプルのインストール手順でも使われていた。 ・generator-angular-fullstack) コミュニティですが、Starが多く評価されているGenerator。上との比較で入れてみる。 ・gulp-angular 上記2つはgruntを使ってるけど、これはgulpを使ったもの。試しに入れてみる。
4.1 generator-angular
$ npm install -g generator-angular
ここでも止まる。。やはりおかしい。nvmで管理しているので、node.jsのversionを0.10.38にdowngradeして、再度試してみる。
$ nvm install 0.10.38
$ nvm use 0.10.38
$ nvm alise default 0.10.38
$ npm install --global npm@latest
$ npm --version
2.9.0
今一度環境の整備を記載。・nodejs v0.10.38
・npm 2.9.0
再チャレンジ!
$ npm install -g bower grunt-cli grunt gulp yo --loglevel verbose
$ npm install -g generator-angular --loglevel verbose
うまくいった。downgradeが功を奏したかどうか、、わからないが、とりあえずこれで進める。。$ mkdir -p yoeman/angular && cd $_
$ yo angular test
? ==========================================================================
We're constantly looking for ways to make yo better!
May we anonymously report usage statistics to improve the tool over time?
More info: https://github.com/yeoman/insight & http://yeoman.io
========================================================================== Yes
_-----_
| | .--------------------------.
|--(o)--| | Welcome to Yeoman, |
`---------´ | ladies and gentlemen! |
( _´U`_ ) '--------------------------'
/___A___\
| ~ |
__'.___.'__
´ ` |° ´ Y `
Out of the box I include Bootstrap and some AngularJS recommended modules.
? Would you like to use Sass (with Compass)? No
? Would you like to include Bootstrap? Yes
? Which modules would you like to include? angular-animate.js, angular-cookies.js, angular-resource.js, angular-route.js, angular-sanitize.js, angular-touch.js
create app/styles/main.css
create app/index.html
create bower.json
create .bowerrc
create package.json
create Gruntfile.js
create README.md
invoke angular:common:/home/nodejs/.nvm/v0.10.38/lib/node_modules/generator-angular/app/index.js
create .editorconfig
create .gitattributes
create .jshintrc
create .yo-rc.json
create .gitignore
create test/.jshintrc
create app/.buildignore
create app/.htaccess
create app/404.html
create app/favicon.ico
create app/robots.txt
create app/views/main.html
create app/images/yeoman.png
invoke angular:main:/home/nodejs/.nvm/v0.10.38/lib/node_modules/generator-angular/app/index.js
create app/scripts/app.js
invoke angular:controller:/home/nodejs/.nvm/v0.10.38/lib/node_modules/generator-angular/app/index.js
create app/scripts/controllers/main.js
create test/spec/controllers/main.js
invoke karma:app
I'm all done. Running bower install & npm install for you to install the required dependencies. If this fails, try running the command yourself.
invoke angular:route
invoke angular:controller:/home/nodejs/.nvm/v0.10.38/lib/node_modules/generator-angular/route/index.js
create app/scripts/controllers/about.js
create test/spec/controllers/about.js
invoke angular:view:/home/nodejs/.nvm/v0.10.38/lib/node_modules/generator-angular/route/index.js
create app/views/about.html
create test/karma.conf.js
conflict package.json
? Overwrite package.json? (Ynaxdh) ? May bower anonymously report usage statistics to improve the tool over time? (Y/n) ? May bower anonymously report usage statistics to improve the tool over time? Yes
? Overwrite package.json? overwrite
force package.json
create .travis.yml
bower angular#^1.3.0 not-cached git://github.com/angular/bower-angular.git#^1.3.0
bower angular#^1.3.0 resolve git://github.com/angular/bower-angular.git#^1.3.0
bower angular-cookies#^1.3.0 not-cached git://github.com/angular/bower-angular-cookies.git#^1.3.0
bower angular-cookies#^1.3.0 resolve git://github.com/angular/bower-angular-cookies.git#^1.3.0
bower bootstrap#^3.2.0 not-cached git://github.com/twbs/bootstrap.git#^3.2.0
bower bootstrap#^3.2.0 resolve git://github.com/twbs/bootstrap.git#^3.2.0
bower angular-animate#^1.3.0 not-cached git://github.com/angular/bower-angular-animate.git#^1.3.0
bower angular-animate#^1.3.0 resolve git://github.com/angular/bower-angular-animate.git#^1.3.0
/
bower angular-route#^1.3.0 not-cached git://github.com/angular/bower-angular-route.git#^1.3.0
bower angular-route#^1.3.0 resolve git://github.com/angular/bower-angular-route.git#^1.3.0
bower angular-sanitize#^1.3.0 not-cached git://github.com/angular/bower-angular-sanitize.git#^1.3.0
bower angular-sanitize#^1.3.0 resolve git://github.com/angular/bower-angular-sanitize.git#^1.3.0
bower angular-touch#^1.3.0 not-cached git://github.com/angular/bower-angular-touch.git#^1.3.0
bower angular-touch#^1.3.0 resolve git://github.com/angular/bower-angular-touch.git#^1.3.0
bower angular-mocks#^1.3.0 not-cached git://github.com/angular/bower-angular-mocks.git#^1.3.0
bower angular-mocks#^1.3.0 resolve git://github.com/angular/bower-angular-mocks.git#^1.3.0
bower angular-resource#^1.3.0 not-cached git://github.com/angular/bower-angular-resource.git#^1.3.0
bower angular-resource#^1.3.0 resolve git://github.com/angular/bower-angular-resource.git#^1.3.0
bower angular-animate#^1.3.0 download https://github.com/angular/bower-angular-animate/archive/v1.3.15.tar.gz
bower bootstrap#^3.2.0 download https://github.com/twbs/bootstrap/archive/v3.3.4.tar.gz
npm WARN peerDependencies The peer dependency karma@>=0.9 included from karma-phantomjs-launcher will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency karma@>=0.9 included from karma-jasmine will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency jasmine-core@* included from karma-jasmine will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency karma@~0.12.0 included from grunt-karma will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
bower angular-route#^1.3.0 download https://github.com/angular/bower-angular-route/archive/v1.3.15.tar.gz
bower angular#^1.3.0 download https://github.com/angular/bower-angular/archive/v1.3.15.tar.gz
bower angular-cookies#^1.3.0 download https://github.com/angular/bower-angular-cookies/archive/v1.3.15.tar.gz
bower angular-mocks#^1.3.0 download https://github.com/angular/bower-angular-mocks/archive/v1.3.15.tar.gz
bower angular-touch#^1.3.0 download https://github.com/angular/bower-angular-touch/archive/v1.3.15.tar.gz
bower angular-sanitize#^1.3.0 download https://github.com/angular/bower-angular-sanitize/archive/v1.3.15.tar.gz
bower angular-route#^1.3.0 extract archive.tar.gz
bower angular-animate#^1.3.0 extract archive.tar.gz
bower angular-resource#^1.3.0 download https://github.com/angular/bower-angular-resource/archive/v1.3.15.tar.gz
bower angular-route#^1.3.0 resolved git://github.com/angular/bower-angular-route.git#1.3.15
bower angular-animate#^1.3.0 resolved git://github.com/angular/bower-angular-animate.git#1.3.15
bower angular#^1.3.0 extract archive.tar.gz
bower angular#^1.3.0 resolved git://github.com/angular/bower-angular.git#1.3.15
bower angular-sanitize#^1.3.0 extract archive.tar.gz
bower angular-sanitize#^1.3.0 resolved git://github.com/angular/bower-angular-sanitize.git#1.3.15
bower angular-cookies#^1.3.0 extract archive.tar.gz
bower angular-cookies#^1.3.0 resolved git://github.com/angular/bower-angular-cookies.git#1.3.15
bower bootstrap#^3.2.0 progress received 1.5MB of 3.0MB downloaded, 51%
bower angular-touch#^1.3.0 extract archive.tar.gz
bower angular-touch#^1.3.0 resolved git://github.com/angular/bower-angular-touch.git#1.3.15
bower bootstrap#^3.2.0 progress received 1.8MB of 3.0MB downloaded, 60%
bower angular-mocks#^1.3.0 extract archive.tar.gz
bower angular-mocks#^1.3.0 resolved git://github.com/angular/bower-angular-mocks.git#1.3.15
bower bootstrap#^3.2.0 progress received 2.2MB of 3.0MB downloaded, 72%
bower bootstrap#^3.2.0 progress received 2.5MB of 3.0MB downloaded, 82%
bower bootstrap#^3.2.0 progress received 2.8MB of 3.0MB downloaded, 92%
bower bootstrap#^3.2.0 extract archive.tar.gz
bower bootstrap#^3.2.0 resolved git://github.com/twbs/bootstrap.git#3.3.4
bower angular-resource#^1.3.0 extract archive.tar.gz
bower angular-resource#^1.3.0 resolved git://github.com/angular/bower-angular-resource.git#1.3.15
bower jquery#>= 1.9.1 not-cached git://github.com/jquery/jquery.git#>= 1.9.1
bower jquery#>= 1.9.1 resolve git://github.com/jquery/jquery.git#>= 1.9.1
bower jquery#>= 1.9.1 download https://github.com/jquery/jquery/archive/2.1.4.tar.gz
npm WARN optional dep failed, continuing fsevents@0.3.6
> phantomjs@1.9.16 install /home/nodejs/yoeman/angular/node_modules/karma-phantomjs-launcher/node_modules/phantomjs
> node install.js
bower jquery#>= 1.9.1 extract archive.tar.gz
bower jquery#>= 1.9.1 resolved git://github.com/jquery/jquery.git#2.1.4
bower angular-route#^1.3.0 install angular-route#1.3.15
bower angular-animate#^1.3.0 install angular-animate#1.3.15
bower angular#^1.3.0 install angular#1.3.15
bower angular-sanitize#^1.3.0 install angular-sanitize#1.3.15
bower angular-cookies#^1.3.0 install angular-cookies#1.3.15
bower angular-touch#^1.3.0 install angular-touch#1.3.15
bower angular-mocks#^1.3.0 install angular-mocks#1.3.15
bower bootstrap#^3.2.0 install bootstrap#3.3.4
bower angular-resource#^1.3.0 install angular-resource#1.3.15
bower jquery#>= 1.9.1 install jquery#2.1.4
Downloading https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
Saving to /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2
Receiving...
\
angular-route#1.3.15 bower_components/angular-route
mqq angular#1.3.15
angular-animate#1.3.15 bower_components/angular-animate
mqq angular#1.3.15
angular#1.3.15 bower_components/angular
angular-sanitize#1.3.15 bower_components/angular-sanitize
mqq angular#1.3.15
angular-cookies#1.3.15 bower_components/angular-cookies
mqq angular#1.3.15
angular-touch#1.3.15 bower_components/angular-touch
mqq angular#1.3.15
angular-mocks#1.3.15 bower_components/angular-mocks
mqq angular#1.3.15
bootstrap#3.3.4 bower_components/bootstrap
mqq jquery#2.1.4
angular-resource#1.3.15 bower_components/angular-resource
mqq angular#1.3.15
jquery#2.1.4 bower_components/jquery
[==================----------------------] 46% 0.0s/
> gifsicle@2.0.1 postinstall /home/nodejs/yoeman/angular/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-gifsicle/node_modules/gifsicle
> node lib/install.js
[=====================-------------------] 52% 0.0s ? gifsicle pre-build test passed successfully
> pngquant-bin@3.0.0 postinstall /home/nodejs/yoeman/angular/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-pngquant/node_modules/pngquant-bin
> node lib/install.js
[========================----------------] 59% 0.0s ? The `/home/nodejs/yoeman/angular/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-pngquant/node_modules/pngquant-bin/vendor/pngquant` binary doesn't seem to work correctly
? pngquant pre-build test failed
? compiling from source
[=========================---------------] 63% 0.0s ? Error: pngquant failed to build, make sure that libpng-dev is installed (*1)
at ChildProcess.exithandler (child_process.js:658:15)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Socket. (child_process.js:979:11)
at Socket.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
> optipng-bin@2.0.4 postinstall /home/nodejs/yoeman/angular/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/optipng-bin
> node lib/install.js
[===========================-------------] 68% 0.0s ? optipng pre-build test passed successfully
> jpegtran-bin@2.0.2 postinstall /home/nodejs/yoeman/angular/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-jpegtran/node_modules/jpegtran-bin
> node lib/install.js
[=============================-----------] 72% 0.0s ? jpegtran pre-build test passed successfully
[================================--------] 80% 0.0sgrunt-contrib-clean@0.6.0 node_modules/grunt-contrib-clean
mqq rimraf@2.2.8
grunt-newer@1.1.0 node_modules/grunt-newer
tqq rimraf@2.2.8
mqq async@0.9.0
grunt-contrib-copy@0.7.0 node_modules/grunt-contrib-copy
mqq chalk@0.5.1 (ansi-styles@1.1.0, escape-string-regexp@1.0.3, supports-color@0.2.0, has-ansi@0.1.0, strip-ansi@0.3.0)
grunt-usemin@3.0.0 node_modules/grunt-usemin
tqq lodash@2.4.2
tqq debug@2.1.3 (ms@0.7.0)
mqq chalk@0.5.1 (ansi-styles@1.1.0, escape-string-regexp@1.0.3, supports-color@0.2.0, has-ansi@0.1.0, strip-ansi@0.3.0)
jshint-stylish@1.0.2 node_modules/jshint-stylish
tqq log-symbols@1.0.2
tqq text-table@0.2.0
tqq string-length@1.0.0 (strip-ansi@2.0.1)
mqq chalk@1.0.0 (escape-string-regexp@1.0.3, ansi-styles@2.0.1, supports-color@1.3.1, strip-ansi@2.0.1, has-ansi@1.0.3)
grunt-filerev@2.3.1 node_modules/grunt-filerev
tqq each-async@0.1.3
tqq convert-source-map@1.1.0
mqq chalk@1.0.0 (escape-string-regexp@1.0.3, ansi-styles@2.0.1, supports-color@1.3.1, strip-ansi@2.0.1, has-ansi@1.0.3)
grunt-concurrent@1.0.0 node_modules/grunt-concurrent
tqq async@0.9.0
mqq pad-stdio@1.0.0 (lpad@1.0.0)
time-grunt@1.1.1 node_modules/time-grunt
tqq figures@1.3.5
tqq date-time@1.0.0
tqq text-table@0.2.0
tqq hooker@0.2.3
tqq chalk@1.0.0 (escape-string-regexp@1.0.3, ansi-styles@2.0.1, supports-color@1.3.1, strip-ansi@2.0.1, has-ansi@1.0.3)
mqq pretty-ms@1.1.0 (get-stdin@4.0.1, parse-ms@1.0.0)
grunt-contrib-concat@0.5.1 node_modules/grunt-contrib-concat
tqq chalk@0.5.1 (ansi-styles@1.1.0, escape-string-regexp@1.0.3, supports-color@0.2.0, has-ansi@0.1.0, strip-ansi@0.3.0)
mqq source-map@0.3.0 (amdefine@0.1.0)
load-grunt-tasks@3.1.0 node_modules/load-grunt-tasks
tqq multimatch@2.0.0 (array-differ@1.0.0, array-union@1.0.1, minimatch@2.0.7)
mqq findup-sync@0.2.1 (glob@4.3.5)
grunt-wiredep@2.0.0 node_modules/grunt-wiredep
mqq wiredep@2.2.2 (propprop@0.3.0, minimist@1.1.1, chalk@0.5.1, lodash@2.4.2, through2@0.6.5, bower-config@0.5.2, glob@4.5.3)
grunt@0.4.5 node_modules/grunt
tqq dateformat@1.0.2-1.2.3
tqq which@1.0.9
tqq eventemitter2@0.4.14
tqq getobject@0.1.0
tqq rimraf@2.2.8
tqq colors@0.6.2
tqq async@0.1.22
tqq grunt-legacy-util@0.2.0
tqq hooker@0.2.3
tqq exit@0.1.2
tqq nopt@1.0.10 (abbrev@1.0.5)
tqq minimatch@0.2.14 (sigmund@1.0.0, lru-cache@2.6.2)
tqq glob@3.1.21 (inherits@1.0.0, graceful-fs@1.2.3)
tqq lodash@0.9.2
tqq coffee-script@1.3.3
tqq underscore.string@2.2.1
tqq iconv-lite@0.2.11
tqq grunt-legacy-log@0.1.1 (underscore.string@2.3.3, lodash@2.4.2)
tqq findup-sync@0.1.3 (lodash@2.4.2, glob@3.2.11)
mqq js-yaml@2.0.5 (esprima@1.0.4, argparse@0.1.16)
grunt-contrib-watch@0.6.1 node_modules/grunt-contrib-watch
tqq async@0.2.10
tqq lodash@2.4.2
tqq gaze@0.5.1 (globule@0.1.0)
mqq tiny-lr-fork@0.0.5 (debug@0.7.4, faye-websocket@0.4.4, qs@0.5.6, noptify@0.0.3)
grunt-contrib-htmlmin@0.4.0 node_modules/grunt-contrib-htmlmin
tqq chalk@0.5.1 (ansi-styles@1.1.0, escape-string-regexp@1.0.3, supports-color@0.2.0, strip-ansi@0.3.0, has-ansi@0.1.0)
tqq pretty-bytes@1.0.4 (get-stdin@4.0.1, meow@3.1.0)
mqq html-minifier@0.7.2 (relateurl@0.2.6, concat-stream@1.4.8, change-case@2.3.0, cli@0.6.6, clean-css@3.1.9, uglify-js@2.4.21)
grunt-contrib-connect@0.9.0 node_modules/grunt-contrib-connect
tqq opn@1.0.2
tqq connect-livereload@0.5.3
tqq async@0.9.0
tqq portscanner@1.0.0 (async@0.1.15)
mqq connect@2.29.1 (cookie-signature@1.0.6, utils-merge@1.0.0, fresh@0.2.4, cookie@0.1.2, content-type@1.0.1, parseurl@1.3.0, pause@0.0.1, response-time@2.3.0, vhost@3.0.0, on-headers@1.0.0, basic-auth-connect@1.0.0, bytes@1.0.0, cookie-parser@1.3.4, depd@1.0.1, qs@2.4.1, debug@2.1.3, connect-timeout@1.6.1, http-errors@1.3.1, method-override@2.3.2, finalhandler@0.3.4, morgan@1.5.2, serve-favicon@2.2.0, express-session@1.10.4, multiparty@3.3.2, type-is@1.6.1, csurf@1.7.0, serve-static@1.9.2, errorhandler@1.3.5, compression@1.4.3, body-parser@1.12.3, serve-index@1.6.3)
grunt-contrib-uglify@0.7.0 node_modules/grunt-contrib-uglify
tqq uri-path@0.0.2
tqq chalk@0.5.1 (ansi-styles@1.1.0, escape-string-regexp@1.0.3, supports-color@0.2.0, has-ansi@0.1.0, strip-ansi@0.3.0)
tqq lodash@2.4.2
tqq uglify-js@2.4.21 (uglify-to-browserify@1.0.2, async@0.2.10, yargs@3.5.4, source-map@0.1.34)
mqq maxmin@1.1.0 (figures@1.3.5, chalk@1.0.0, pretty-bytes@1.0.4, gzip-size@1.0.0)
grunt-contrib-cssmin@0.12.2 node_modules/grunt-contrib-cssmin
tqq chalk@0.5.1 (ansi-styles@1.1.0, escape-string-regexp@1.0.3, supports-color@0.2.0, has-ansi@0.1.0, strip-ansi@0.3.0)
tqq clean-css@3.2.8 (commander@2.8.1, source-map@0.4.2)
mqq maxmin@1.1.0 (figures@1.3.5, chalk@1.0.0, pretty-bytes@1.0.4, gzip-size@1.0.0)
grunt-contrib-jshint@0.11.2 node_modules/grunt-contrib-jshint
tqq hooker@0.2.3
mqq jshint@2.7.0 (strip-json-comments@1.0.2, exit@0.1.2, shelljs@0.3.0, console-browserify@1.1.0, minimatch@2.0.7, cli@0.6.6, htmlparser2@3.8.2, lodash@3.6.0)
grunt-ng-annotate@0.9.2 node_modules/grunt-ng-annotate
tqq lodash@2.4.2
mqq ng-annotate@0.15.4 (tryor@0.1.2, simple-is@0.2.0, simple-fmt@0.1.0, stringset@0.2.1, stringmap@0.2.2, alter@0.2.0, stable@0.1.5, convert-source-map@0.4.1, ordered-ast-traverse@1.1.1, optimist@0.6.1, source-map@0.1.43, acorn@0.11.0)
grunt-svgmin@2.0.1 node_modules/grunt-svgmin
tqq log-symbols@1.0.2
tqq chalk@1.0.0 (escape-string-regexp@1.0.3, ansi-styles@2.0.1, supports-color@1.3.1, strip-ansi@2.0.1, has-ansi@1.0.3)
tqq each-async@1.1.1 (set-immediate-shim@1.0.1, onetime@1.0.0)
tqq pretty-bytes@1.0.4 (get-stdin@4.0.1, meow@3.1.0)
mqq svgo@0.5.1 (whet.extend@0.9.9, colors@1.0.3, mkdirp@0.5.0, coa@1.0.1, sax@0.6.1, js-yaml@3.2.7)
grunt-autoprefixer@2.2.0 node_modules/grunt-autoprefixer
tqq diff@1.2.2
tqq chalk@0.5.1 (ansi-styles@1.1.0, escape-string-regexp@1.0.3, supports-color@0.2.0, has-ansi@0.1.0, strip-ansi@0.3.0)
mqq autoprefixer-core@5.1.11 (num2fraction@1.1.0, browserslist@0.2.0, postcss@4.0.6, caniuse-db@1.0.30000156)
grunt-google-cdn@0.4.3 node_modules/grunt-google-cdn
tqq chalk@0.5.1 (ansi-styles@1.1.0, escape-string-regexp@1.0.3, supports-color@0.2.0, strip-ansi@0.3.0, has-ansi@0.1.0)
tqq bower@1.4.1 (is-root@1.0.0, junk@1.0.1, stringify-object@1.0.1, abbrev@1.0.5, chmodr@0.1.0, user-home@1.1.1, which@1.0.9, rimraf@2.3.3, archy@1.0.0, opn@1.0.2, bower-logger@0.2.2, bower-endpoint-parser@0.2.2, graceful-fs@3.0.6, lockfile@1.0.0, lru-cache@2.6.2, nopt@3.0.1, retry@0.6.1, tmp@0.0.24, q@1.3.0, semver@2.3.2, p-throttler@0.1.1, fstream@1.0.4, request-progress@0.3.1, bower-json@0.4.0, shell-quote@1.4.3, mkdirp@0.5.0, promptly@0.2.0, chalk@1.0.0, fstream-ignore@1.0.2, glob@4.5.3, tar-fs@1.5.0, insight@0.5.3, decompress-zip@0.1.0, update-notifier@0.3.2, request@2.53.0, bower-registry-client@0.3.0, github@0.2.4, cardinal@0.4.4, mout@0.11.0, bower-config@0.6.1, configstore@0.3.2, inquirer@0.8.0, handlebars@2.0.0)
mqq google-cdn@0.7.0 (regexp-quote@0.0.0, google-cdn-data@0.1.17, async@0.9.0, semver@2.3.2, debug@1.0.4, cdnjs-cdn-data@0.1.1, bower@1.3.12)
grunt-contrib-imagemin@0.9.4 node_modules/grunt-contrib-imagemin
tqq gulp-rename@1.2.2
tqq async@0.9.0
tqq chalk@1.0.0 (escape-string-regexp@1.0.3, ansi-styles@2.0.1, supports-color@1.3.1, strip-ansi@2.0.1, has-ansi@1.0.3)
tqq pretty-bytes@1.0.4 (get-stdin@4.0.1, meow@3.1.0)
mqq imagemin@3.1.0 (get-stdin@3.0.2, optional@0.1.3, stream-combiner@0.2.1, vinyl@0.4.6, concat-stream@1.4.8, through2@0.6.5, meow@2.1.0, vinyl-fs@0.3.13, imagemin-svgo@4.1.2, imagemin-gifsicle@4.1.0, imagemin-pngquant@4.1.0, imagemin-optipng@4.2.0, imagemin-jpegtran@4.1.0)
[=================================-------] 83% 0.0sRunning "wiredep:app" (wiredep) task
Running "wiredep:test" (wiredep) task
Done, without errors.
Execution Time (2015-05-06 14:18:19 UTC)
loading tasks 31ms ???? 4%
wiredep:app 741ms ?????????????????????????????????????????????????????????????????????????????????? 93%
wiredep:test 20ms ??? 3%
Total 794ms
[========================================] 100% 0.0s
Received 12854K total.
Extracting tar contents (via spawned process)
Removing /home/nodejs/yoeman/angular/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-1430921977466/phantomjs-1.9.8-linux-x86_64 -> /home/nodejs/yoeman/angular/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /home/nodejs/yoeman/angular/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs
> ws@0.4.32 install /home/nodejs/yoeman/angular/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/home/nodejs/yoeman/angular/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/build'
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/obj.target/bufferutil.node
SOLINK_MODULE(target) Release/obj.target/bufferutil.node: Finished
COPY Release/bufferutil.node
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/obj.target/validation.node
SOLINK_MODULE(target) Release/obj.target/validation.node: Finished
COPY Release/validation.node
make: Leaving directory `/home/nodejs/yoeman/angular/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/build'
karma-phantomjs-launcher@0.1.4 node_modules/karma-phantomjs-launcher
mqq phantomjs@1.9.16 (which@1.0.9, progress@1.1.8, kew@0.4.0, request-progress@0.3.1, adm-zip@0.4.4, npmconf@2.1.1, request@2.42.0, fs-extra@0.16.5)
jasmine-core@2.3.0 node_modules/jasmine-core
karma@0.12.31 node_modules/karma
tqq di@0.0.1
tqq graceful-fs@2.0.3
tqq rimraf@2.2.8
tqq colors@0.6.2
tqq mime@1.2.11
tqq q@0.9.7
tqq minimatch@0.2.14 (sigmund@1.0.0, lru-cache@2.6.2)
tqq optimist@0.6.1 (wordwrap@0.0.2, minimist@0.0.10)
tqq source-map@0.1.43 (amdefine@0.1.0)
tqq glob@3.2.11 (inherits@2.0.1, minimatch@0.3.0)
tqq lodash@2.4.2
tqq useragent@2.0.10 (lru-cache@2.2.4)
tqq log4js@0.6.24 (async@0.2.10, underscore@1.8.2, readable-stream@1.0.33, semver@4.3.4)
tqq connect@2.26.6 (fresh@0.2.4, cookie@0.1.2, pause@0.0.1, vhost@3.0.0, on-headers@1.0.0, bytes@1.0.0, basic-auth-connect@1.0.0, cookie-signature@1.0.5, response-time@2.0.1, media-typer@0.3.0, parseurl@1.3.0, depd@0.4.5, cookie-parser@1.3.4, connect-timeout@1.3.0, qs@2.2.4, finalhandler@0.2.0, debug@2.0.0, method-override@2.2.0, serve-favicon@2.1.7, morgan@1.3.2, csurf@1.6.6, type-is@1.5.7, multiparty@3.3.2, compression@1.1.2, errorhandler@1.2.4, serve-static@1.6.5, body-parser@1.8.4, express-session@1.8.2, serve-index@1.2.1)
tqq http-proxy@0.10.4 (pkginfo@0.3.0, utile@0.2.1)
tqq chokidar@1.0.1 (arrify@1.0.0, is-glob@1.1.3, glob-parent@1.2.0, async-each@0.1.6, is-binary-path@1.0.0, readdirp@1.3.0, anymatch@1.3.0)
mqq socket.io@0.9.16 (base64id@0.1.0, policyfile@0.0.4, redis@0.7.3, socket.io-client@0.9.16)
karma-jasmine@0.3.5 node_modules/karma-jasmine
grunt-karma@0.10.1 node_modules/grunt-karma
mqq lodash@2.4.2
Errorが出ている(*1)。gruntで画像の最適化処理するために"libpng-dev"がいるらしいですね。
そのまま処理は継続されているので、いったんこのまま進める。
(2016/3/2追記)
proxy環境下で、bowerを使う場合の設定
{
"proxy" : "http://proxy.example.co.jp:8080",
"https-proxy" : "http://proxy.example.co.jp:8080"
}
2015年3月11日水曜日
node.jsのパッケージ管理ツールでexpressの導入
node.jsをnvm(NodeersionManager)を使ってインストールし、パッケージ管理(npm)を使ってexpress環境を構築してみる。環境は以下の通り。 OS:CentOS6.5(x64) nvm:0.24.0 node.js:0.12.0 npm: forever: express:4.12.2
0.環境準備~nvm/node.jsのインストール
$ sudo useradd nodejs
$ sudo su - nodejs
$ sudo yum install git #入っていなかったら入れる
$ git clone git://github.com/creationix/nvm.git ~/.nvm
$ source ~/.nvm/nvm.sh
これでnvmはインストール完了。次はnvmを使ってnode.jsをインストールしてみる。
インストールできる、node.jsのバージョン一覧を確認する。偶数が安定板、奇数が開発版
$ nvm ls-remote
v0.1.14
v0.1.15
v0.1.16
・
・
・
・
v0.11.14
v0.11.15
v0.11.16
v0.12.0
$
ということで最新(2015/3/8 時点:v0.12.0)を入れてみることに。
$ nvm install 0.12.0
######################################################################## 100.0%
Now using node v0.12.0
とても簡単!完了。次に複数インストールした場合のデフォルトで使用するバージョンを設定しておく
$ nvm alias default v0.12.0
default -> v0.12.0
デフォルトでnvmも使えるように設定する
$ vi ~/.bash_profile
・
・
if [[ -f ~/.nvm/nvm.sh ]];
then source ~/.nvm/nvm.sh
npm_dir=${NVM_PATH}_modules
export NODE_PATH=$npm_dir
export PATH=$NVM_BIN:$PATH
fi
次にnode.jsのサンプルを作成してみる
$ vi example.js
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(9000, "192.168.0.74");
console.log('Server running at http://192.168.0.74:9000/');
実行!
$ node example.js
Server running at http://192.168.0.74:9000/
超簡単・・。ブラウザで表示。
ただこの状態だと、エラーがあるとプロセスがこけてしまい、Webサーバーがダウンすることになる。 試しに、以下のようなサンプルコードを実行した場合、
$ vi example_err.js
var n = 0;
var http = require('http');
http.createServer(function (req, res) {
if (++n > 4) { a }
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end("result:" + n + "\n");
}).listen(9000, "192.168.0.74");
console.log('Server running at http://192.168.0.74:9000/');
別端末でcurlでアクセスをしてみると、変数"n"がカウントアップされ、5回目に変数"a"を参照しにいき、落ちる。
$ curl http://192.168.0.74:9000
result:1
$ curl http://192.168.0.74:9000
result:2
$ curl http://192.168.0.74:9000
result:3
$ curl http://192.168.0.74:9000
result:4
$ curl http://192.168.0.74:9000
url: (52) Empty reply from server
node.js側はこんな感じ。
$ node example_err.js
Server running at http://192.168.0.74:9000/
/home/nodejs/example_err.js:4
if (++n > 4) { a }
^
ReferenceError: a is not defined
at Server.<anonymous> (/home/nodejs/example_err.js:4:18)
at Server.emit (events.js:110:17)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:491:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:111:23)
at Socket.socketOnData (_http_server.js:343:22)
at Socket.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at Socket.Readable.push (_stream_readable.js:126:10)
at TCP.onread (net.js:529:20)
これだと実際には使えない・・・ということで、次にnpmを使ってforeverというモジュールを使ってみる。
1.npmを使ってforeverをインストールしてみる
node.jsを入れると、npmもインストールされている。これを使って、foreverモジュールをインストールしてみる。
$ npm install -g forever
"-g"でグローバルインストールとし、全部のアプリで使えるようにしておく。 インストールが終わったら、実際に実行してみる。
$ npm
Usage: npm <command></command>
where <command></command> is one of:
add-user, adduser, apihelp, author, bin, bugs, c, cache,
completion, config, ddp, dedupe, deprecate, docs, edit,
explore, faq, find, find-dupes, get, help, help-search,
home, i, info, init, install, issues, la, link, list, ll,
ln, login, ls, outdated, owner, pack, prefix, prune,
publish, r, rb, rebuild, remove, repo, restart, rm, root,
run-script, s, se, search, set, show, shrinkwrap, star,
stars, start, stop, t, tag, test, tst, un, uninstall,
unlink, unpublish, unstar, up, update, v, verison, version,
view, whoami
npm <cmd> -h quick help on <cmd>
npm -l display full usage info
npm faq commonly asked questions
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
/home/nave/.npmrc
or on the command line via: npm <command></command> --key value
Config info can be viewed via: npm help config
npm@2.1.14 /usr/local/nave/installed/0.10.35/lib/node_modules/npm
$ forever start example_err.js
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info: Forever processing file: example_err.js
warningはでたけど、、起動している。先ほどのようにcurlで何度かアクセスすると、resultが1に戻って表示され node.js側は何もエラーがでていない。つまり、node.jsが再起動されて起動し続けているということのようです。 一件落着。
で次に、expressだ。
2.npmを使ってexpressをインストールしてみる
これを使ってexpressをインストールする。
$ npm install -g express
express@4.12.2 /home/nodejs/.nvm/versions/node/v0.12.0/lib/node_modules/express
tqq merge-descriptors@1.0.0
tqq utils-merge@1.0.0
tqq cookie-signature@1.0.6
tqq methods@1.1.1
tqq fresh@0.2.4
tqq cookie@0.1.2
tqq escape-html@1.0.1
tqq range-parser@1.0.2
tqq content-type@1.0.1
tqq finalhandler@0.3.3
tqq vary@1.0.0
tqq parseurl@1.3.0
tqq serve-static@1.9.1
tqq content-disposition@0.5.0
tqq path-to-regexp@0.1.3
tqq depd@1.0.0
tqq on-finished@2.2.0 (ee-first@1.1.0)
tqq qs@2.3.3
tqq etag@1.5.1 (crc@3.2.1)
tqq proxy-addr@1.0.6 (forwarded@0.1.0, ipaddr.js@0.1.8)
tqq debug@2.1.2 (ms@0.7.0)
tqq send@0.12.1 (destroy@1.0.3, ms@0.7.0, mime@1.3.4)
tqq type-is@1.6.0 (media-typer@0.3.0, mime-types@2.0.9)
mqq accepts@1.2.4 (negotiator@0.5.1, mime-types@2.0.9)
インストール完了・・これまたあっけなし。以下のサンプルプログラムでお試し。
$ vi app.js
var express = require('express');
var app = express();
app.get('/',function (req,res){
res.send('Hello Express!');
});
app.listen(9000,"192.168.0.74");
ブラウザでつついて、ばっちり!あとは追加でexpressのひな形自動作成ツールを追加してみる。
express-generatorというパッケージになる。
$ npm install -g express-generator
/home/nodejs/.nvm/versions/node/v0.12.0/bin/express -> /home/nodejs/.nvm/versions/node/v0.12.0/lib/node_modules/express-generator/bin/express
express-generator@4.12.1 /home/nodejs/.nvm/versions/node/v0.12.0/lib/node_modules/express-generator
tqq sorted-object@1.0.0
tqq commander@2.6.0
mqq mkdirp@0.5.0 (minimist@0.0.8)
次にEJSというビューテンプレートを使ってひな形を作成してみる。
$ express --ejs expressexample
create : expressexample
create : expressexample/package.json
create : expressexample/app.js
create : expressexample/public
create : expressexample/public/javascripts
create : expressexample/public/images
create : expressexample/public/stylesheets
create : expressexample/public/stylesheets/style.css
create : expressexample/routes
create : expressexample/routes/index.js
create : expressexample/routes/users.js
create : expressexample/views
create : expressexample/views/index.ejs
create : expressexample/views/error.ejs
create : expressexample/bin
create : expressexample/bin/www
install dependencies:
$ cd expressexample && npm install
run the app:
$ DEBUG=expressexample:* ./bin/www
で作成。ただこれだけだとディレクトリ・ファイルが出来上がっただけなので、記載されいてるとおり、
$ cd expressexample && npm install
でセットアップする。出来上がったものを、これまた記載通りDEBUG付きで実行してみる。
$ DEBUG=expressexample:* ./bin/www
expressexample:server Listening on port 3000 +0ms
あとはブラウザでアクセスしてみると、ばらばらとデバッグ(トレース)が出てきた。なるへそねぇ。
で、もう少し出来上がった中身を見てみる。
$ vi package.json
{
"name": "expressexample",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "~1.12.0",
"cookie-parser": "~1.3.4",
"debug": "~2.1.1",
"ejs": "~2.3.1",
"express": "~4.12.2",
"morgan": "~1.5.1",
"serve-favicon": "~2.2.0"
}
}
これはnpmのファイル。6行目の内容は、npm startと打った時に実行される内容。
つまり、
$ npm start
でも実行ができるということですね。あとは依存関係のあるパッケージが記載されている。このpackage.jsonファイル
を他の環境に持っていき、npm installをすれば、同じ環境が出来上がる!ということですね。
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var routes = require('./routes/index'); //(*1)
var users = require('./routes/users');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes); //(*2)
app.use('/users', users);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handlers
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}
// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});
module.exports = app;
このファイルは、サーバーで使用するミドルウェアを取り込んだり、ルーティングするためのファイルとのこと。
例えば(*2)は
http://192.168.0.74/
でアクセスされた場合のルーティング設定で、この行ではroutes変数にアサインされている。で、routes変数に何が入っているかというと、、(*1)に記載されている。
(*1)ではroutes変数に[./routes/index]を割り当てているが、これは./routes/index.jsのことを指している。
ちなみに、このapp.jsファイルを読むと、ルーティングはファイルの上から順に評価されていき、該当したところで止まる(後続は処理されない)という処理のようですね。今後作っていく際のポイントになりそう。
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
module.exports = router;
このファイルは上記にあったapp.jsで呼び出されたroutes/index.js。ポイントは6行目。今回テンプレートとしてejsを採用しているので、この行にあるrender関数でejsテンプレートが呼び出される。どのテンプレートかというと、第一引数がindexとなっているので、views/index.ejsだ。このテンプレートを呼び出すにあたり、title変数に、[Express]を設定して、呼び出している。
$ vi views/index.ejs
<html>
<head>
<title><%= title %></title>
<link href="/stylesheets/style.css" rel="stylesheet"></link>
</head>
<body>
<h1><%= title %></h1>
Welcome to <%= title %>
</body>
</html>
このファイルはhtmlベースのテンプレートとなっており、<%= title %>となっているところに、index.jsのrender関数で指定したtitle編巣の値をセットしている。
今日はここまで・・
2015年2月3日火曜日
CentOS6.5でphp5.5のrpm化&インストール
WordPressを構築してみるために、最新のphp 5.6.5をインストールを試みた。rpm作成から試してみる。
※rpm作成環境の構築はこちら ソースコードを入手し、さくっとrpmを作成してみる。
まずは標準のレポジトリから入れてみる。
まずは、5.5系の最新版である5.5.21。
※rpm作成環境の構築はこちら ソースコードを入手し、さくっとrpmを作成してみる。
まずは標準のレポジトリから入れてみる。
$ sudo yum install php
・
・
Error: Package: php-5.3.3-40.el6_6.x86_64 (updates)
Requires: httpd-mmn = 20051115
Installed: httpd-2.4.12-1.x86_64 (installed)
httpd-mmn = 20120211
Available: httpd-2.2.15-39.el6.centos.x86_64 (base)
httpd-mmn = 20051115
・
・
となった。バージョンも5.3.3となっているし、httpd 2.4が入ってる環境だと、エラーが出てしまう見たい。
原因はメッセージの通り、httpd 2.2.15までにしか対応していない。ということなのでしょう。
ということで、ソース化からrpmを作ってみることにした。phpのサイトから入手して、、
$ wget http://jp1.php.net/get/php-5.6.5.tar.bz2/from/this/mirror -O php-5.6.5.tar.bz2 $ rpmbuild -bb php-5.6.5.tar.bz2 error: File /home/hayashi/rpmbuild/SOURCES/php-5.6.5.tar.bz2 does not appear to be a specfile.specファイルがないと・・確かにない。ということで、IUSのサイトからSRPMを入手し、試す。
$ cd ~/rpmbuild/SRPMS
$ wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/SRPMS/php56u-5.6.5-1.ius.centos6.src.rpm
$ rpmbuild --rebuild --clean php56u-5.6.5-1.ius.centos6.src.rpm
・
・
・
error: Failed build dependencies:
bzip2-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
curl-devel >= 7.9 is needed by php56u-5.6.5-1.ius.el6.x86_64
pam-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
httpd-devel < 2.4 is needed by php56u-5.6.5-1.ius.el6.x86_64
libedit-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
libtool-ltdl-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
systemtap-sdt-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
libc-client-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
firebird-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
net-snmp-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
libxslt-devel >= 1.0.18-1 is needed by php56u-5.6.5-1.ius.el6.x86_64
t1lib-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
libjpeg-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
libpng-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
freetype-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
libXpm-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
libvpx-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
gmp-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
tokyocabinet-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
libmcrypt-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
libtidy-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
aspell-devel >= 0.50.0 is needed by php56u-5.6.5-1.ius.el6.x86_64
recode-devel is needed by php56u-5.6.5-1.ius.el6.x86_64
libicu-devel >= 4.0 is needed by php56u-5.6.5-1.ius.el6.x86_64
enchant-devel >= 1.2.4 is needed by php56u-5.6.5-1.ius.el6.x86_64
$ yum install bzip2-devel curl-devel pam-devel libedit-devel libtool-ltdl-devel systemtap-sdt-devel /
libc-client-devel firebird-devel net-snmp-devel libxslt-devel t1lib-devel libjpeg-devel libpng-devel /
freetype-devel libXpm-devel libvpx-devel gmp-devel tokyocabinet-devel libmcrypt-devel libtidy-devel /
aspell-devel recode-devel libicu-devel enchant-devel
$ sudo rpm -ivh ~/rpmbuild/RPMS/x86_64/httpd-devel-2.4.12-1.x86_64.rpm
error: Failed build dependencies:
httpd-devel < 2.4 is needed by php56u-5.6.5-1.ius.el6.x86_64
おっと、、httpd-develはapache2.4.12と合わせてインストールしたが、、これを見ると2.2じゃないとダメということか?httpdとhttpd-develのバージョンを別々のものを入れてもよいのか?はわからなかった。ということで、php 5.5.xを
探してみる。
ちなみにphpの古いバージョンは、IUSのサイトのアーカイブを参照。まずは、5.5系の最新版である5.5.21。
$ mkdir /tmp/php/ $ wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/SRPMS/php55u-5.5.21-1.ius.el6.src.rpm $ rpm2cpio php55u-5.5.21-1.ius.centos6.src.rpm | cpio -id $ less php55u.spec
・
・
%if 0%{?rhel} < 7
BuildRequires: httpd-devel < 2.4
%else
BuildRequires: httpd-devel
%endif
・
・
となっており、5.6とおなじく、redhet6(この場合はcentos6)だと、httpd-develは2.4未満じゃないとダメらしい。次は5.5.20。5.5.20のspecを見ると、
・ ・ BuildRequires: httpd-devel >= 2.0.46-1, pam-devel ・ ・となっており、大丈夫そうです。ということで、5.5.20で進める。
$ cd ~/rpmbuild/SRPM $ rpmbuild --rebuild --clean php55u-5.5.20-1.ius.centos6.src.rpm ・ ・ Sorry, I cannot run apxs. Possible reasons follow: 1. Perl is not installed 2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs 3. Apache was not built using --enable-so (the apxs usage page is displayed) The output of /usr/sbin/apxs follows: ./configure: line 8754: /usr/sbin/apxs: No such file or directory configure: error: Aborting error: Bad exit status from /var/tmp/rpm-tmp.bYrvIJ (%build) ・ ・というエラーがでた。apache2.4からは、apxsのパスは、「/usr/bin/apxs」に変更になったとの ことで、specファイルを変更する。
$ cd /tmp/php/;rm -f * $ rpm2cpio php55u-5.5.20-1.ius.centos6.src.rpm | cpio -id $ cp php55u.spec ~/rpmbuild/SPECS/ $ cd ~/rpmbuild/SPECS/ $ vi php55u.spec
# /usr/sbin/apsx with httpd < 2.4 and defined as /usr/bin/apxs with httpd >= 2.4
%{!?_httpd_apxs: %{expand: %%global _httpd_apxs %%{_sbindir}/apxs}}
↓
# /usr/sbin/apsx with httpd < 2.4 and defined as /usr/bin/apxs with httpd >= 2.4
#%{!?_httpd_apxs: %{expand: %%global _httpd_apxs %%{_sbindir}/apxs}}
%{!?_httpd_apxs: %{expand: %%global _httpd_apxs %%{_bindir}/apxs}}
これでいけるかな・・
$ rpmbuild -bb --clean ~/rpmbuild/SPECS/php55u.spec ・ ・ + umask 022 + cd /home/hayashi/rpmbuild/BUILD + rm -rf php-5.5.20 + exit 0 $ cd ~/rpmbuild/RPMS/x86_64/ $ ls php55u-*5.5.20* php55u-5.5.20-1.ius.el6.x86_64.rpm php55u-mbstring-5.5.20-1.ius.el6.x86_64.rpm php55u-bcmath-5.5.20-1.ius.el6.x86_64.rpm php55u-mcrypt-5.5.20-1.ius.el6.x86_64.rpm php55u-cli-5.5.20-1.ius.el6.x86_64.rpm php55u-mssql-5.5.20-1.ius.el6.x86_64.rpm php55u-common-5.5.20-1.ius.el6.x86_64.rpm php55u-mysqlnd-5.5.20-1.ius.el6.x86_64.rpm php55u-dba-5.5.20-1.ius.el6.x86_64.rpm php55u-odbc-5.5.20-1.ius.el6.x86_64.rpm php55u-debuginfo-5.5.20-1.ius.el6.x86_64.rpm php55u-opcache-5.5.20-1.ius.el6.x86_64.rpm php55u-devel-5.5.20-1.ius.el6.x86_64.rpm php55u-pdo-5.5.20-1.ius.el6.x86_64.rpm php55u-embedded-5.5.20-1.ius.el6.x86_64.rpm php55u-pgsql-5.5.20-1.ius.el6.x86_64.rpm php55u-enchant-5.5.20-1.ius.el6.x86_64.rpm php55u-process-5.5.20-1.ius.el6.x86_64.rpm php55u-fpm-5.5.20-1.ius.el6.x86_64.rpm php55u-pspell-5.5.20-1.ius.el6.x86_64.rpm php55u-gd-5.5.20-1.ius.el6.x86_64.rpm php55u-recode-5.5.20-1.ius.el6.x86_64.rpm php55u-gmp-5.5.20-1.ius.el6.x86_64.rpm php55u-snmp-5.5.20-1.ius.el6.x86_64.rpm php55u-imap-5.5.20-1.ius.el6.x86_64.rpm php55u-soap-5.5.20-1.ius.el6.x86_64.rpm php55u-interbase-5.5.20-1.ius.el6.x86_64.rpm php55u-tidy-5.5.20-1.ius.el6.x86_64.rpm php55u-intl-5.5.20-1.ius.el6.x86_64.rpm php55u-xml-5.5.20-1.ius.el6.x86_64.rpm php55u-ldap-5.5.20-1.ius.el6.x86_64.rpm php55u-xmlrpc-5.5.20-1.ius.el6.x86_64.rpm php55u-litespeed-5.5.20-1.ius.el6.x86_64.rpm成功!wordpressを想定してインストールしてみる。
$ sudo rpm -Uvh php55u-5.5.20-1.ius.el6.x86_64.rpm php55u-mbstring-5.5.20-1.ius.el6.x86_64.rpm php55u-mssql-5.5.20-1.ius.el6.x86_64.rpm
error: Failed dependencies:
php55u-common(x86-64) = 5.5.20-1.ius.el6 is needed by php55u-5.5.20-1.ius.el6.x86_64
php55u-cli(x86-64) = 5.5.20-1.ius.el6 is needed by php55u-5.5.20-1.ius.el6.x86_64
php55u-common = 5.5.20-1.ius.el6 is needed by php55u-mbstring-5.5.20-1.ius.el6.x86_64
php55u-pdo = 5.5.20-1.ius.el6 is needed by php55u-mssql-5.5.20-1.ius.el6.x86_64
$ sudo rpm -Uvh php55u-5.5.20-1.ius.el6.x86_64.rpm php55u-mbstring-5.5.20-1.ius.el6.x86_64.rpm php55u-mssql-5.5.20-1.ius.el6.x86_64.rpm php55u-common-5.5.20-1.ius.el6.x86_64.rpm php55u-cli-5.5.20-1.ius.el6.x86_64.rpm php55u-pdo-5.5.20-1.ius.el6.x86_64.rpm
error: Failed dependencies:
php55u-pecl-jsonc is needed by php55u-common-5.5.20-1.ius.el6.x86_64
まだかぁ。先は長いっす。この後も出てきます。ちょっと関係性を整理しておく。
php55u-common
⇒php55u-pecl-jsonc(*)
⇒php55u-devel
⇒php55u-cli
⇒php55u-common
⇒php55u-pecl-jsonc-devel(*)
⇒php55u-pear(*)
⇒php55u-cli
⇒php55u-common
⇒php55u-xml
⇒php55u-common
とループしちゃってます。うち、(*)についてはコンパイルが必要になります。ので、、
コンパイルに必要となるphp55u-cli、php55u-common、php55u-xml、php55u-develについては、依存関係を無視して
インストールする必要があるってことですね。
$ sudo rpm -Uvh --nodeps php55u-cli-5.5.20-1.ius.el6.x86_64.rpm php55u-common-5.5.20-1.ius.el6.x86_6 4.rpm php55u-xml-5.5.20-1.ius.el6.x86_64.rpm php55u-devel-5.5.20-1.ius.el6.x86_64.rpm残りのパッケージについて、IUSで再度入手して進める。
$ wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/SRPMS/php55u-pear-1.9.5-2.ius.centos6.src.rpm
$ rpmbuild --rebuild --clean php55u-pear-1.9.5-2.ius.centos6.src.rpm
$ sudo rpm -Uvh ../RPMS/noarch/php55u-pear-1.9.5-2.ius.el6.noarch.rpm
error: Failed dependencies:
php55u-posix is needed by php55u-pear-1:1.9.5-2.ius.el6.noarch
まだあるんですか。。長すぎる。php55u-posixのSRPMをIUSのサイトで調べたけど、見当たらず。yumを使って調査をしてみた。まずはIUSのレポジトリを追加。
$ wget wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ius-release-1.0-13.ius.centos6.noarch.rpm $ sudo rpm -Uvh ius-release-1.0-13.ius.centos6.noarch.rpm $ sudo vi /etc/yum.repos.d/ius.repo
[ius] ・ ・ #enabled=1 enabled=0 ・ ・ [ius-debuginfo] ・ ・調査。
$ yum --enablerepo=ius provides php55u-posix Loaded plugins: fastestmirror, versionlock Loading mirror speeds from cached hostfile * base: ftp.riken.jp * epel: ftp.kddilabs.jp * extras: ftp.riken.jp * ius: hkg.mirror.rackspace.com * updates: ftp.riken.jp php55u-process-5.5.21-1.ius.centos6.x86_64 : Modules for PHP script using system process interfaces Repo : ius Matched from: Other : php55u-posixということで、php55u-processを入れればいいみたい。
$ sudo rpm -Uvh ../RPMS/noarch/php55u-pear-1.9.5-2.ius.el6.noarch.rpm ../RPMS/x86_64/php55u-process-5.5.20-1.ius.el6.x86_64.rpm無事成功。残るは、、php55u-pecl-jsoncとphp55u-pecl-jsonc-develです。
$ wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/SRPMS/php55u-pecl-jsonc-1.3.6-3.ius.centos6.src.rpm $ rpmbuild --rebuild --clean php55u-pecl-jsonc-1.3.6-3.ius.centos6.src.rpm $ cd ../RPMS/x86_64/ $ sudo rpm -Uvh php55u-pecl-jsonc-1.3.6-3.ius.el6.x86_64.rpm php55u-pecl-jsonc-devel-1.3.6-3.ius.el6.x86_64.rp $ sudo rpm -Uvh php55u-5.5.20-1.ius.el6.x86_64.rpm php55u-mbstring-5.5.20-1.ius.el6.x86_64.rpm php55u-pdo-5.5.20-1.ius.el6.x86_64.rpm php55u-mysqlnd-5.5.20-1.ius.el6.x86_64.rpmということで、php 5.5.20を無事インストールすることができました。 wordPress $ sudo rpm -Uvh php55u-5.5.14-1.ius.el6.x86_64.rpm php55u-common-5.5.14-1.ius.el6.x86_64.rpm php55u-cli-5.5.14-1.ius.el6.x86_64.rpm php55u-opcache-5.5.14-1.ius.el6.x86_64.rpm php55u-pdo-5.5.14-1.ius.el6.x86_64.rpm php55u-mysqlnd-5.5.14-1.ius.el6.x86_64.rpm php55u-mbstring-5.5.14-1.ius.el6.x86_64.rpm $ sudo rpm -Uvh php55u-fpm-5.5.14-1.ius.el6.x86_64.rpm $ sudo chkconfig php-fpm on http.conf LoadModule mpm_event_module lib64/httpd/modules/mod_mpm_event.so #LoadModule mpm_prefork_module lib64/httpd/modules/mod_mpm_prefork.so root:password mysql mysql> create database wp; mysql> grant all privileges on wp.* to wp@localhost identified by "wppassword";
登録:
投稿 (Atom)
