phpbrewでインストール時に詰まったところメモ

今回の環境はCentOS 6.5(Final: x86_64)

$ phpbrew install 5.5.20 +default +mysql
===> phpbrew will now build 5.5.20
===> Loading and resolving variants...
Checking distribution checksum...
Checksum matched: 9dfc1d4d2b44fb7e2b4ee9651d032203
===> Distribution file was successfully extracted, skipping...
Found existing build.log, renaming it to /home/dimgraycat/.phpbrew/build/php-5.5.20/build.log.1423373902
===> Configuring 5.5.20...


Use tail command to see what's going on:
   $ tail -F /home/dimgraycat/.phpbrew/build/php-5.5.20/build.log



Configure failed. 1

エラーが出てたので tail を確認すると

configure: error: Cannot find OpenSSL's libraries

OpenSSLは昔入れた覚えがあるけどとりあえず確認する

$ yum list installed|grep openssl
openssl.x86_64        1.0.1e-30.el6_6.5 @updates
openssl-devel.x86_64  1.0.1e-30.el6_6.5 @updates

やはり、入ってるよねー。
ということは、configure時のパスが違うはず?
同じようなことが起きてる人が居ないかggr(定番)と
やはり居た!→ Cannot find OpenSSL's libraries · Issue #418 · phpbrew/phpbrew · GitHub

OpenSSLの場所を指定するのか、なるほど。

〜 +openssl=/usr -- --with-libdir=lib64

とりあえず、やってみる。

$ phpbrew install 5.5.20 +default +mysql +openssl=/usr -- --with-libdir=lib64
===> phpbrew will now build 5.5.20
===> Loading and resolving variants...
Checking distribution checksum...
Checksum matched: 9dfc1d4d2b44fb7e2b4ee9651d032203
===> Distribution file was successfully extracted, skipping...
Found existing build.log, renaming it to /home/dimgraycat/.phpbrew/build/php-5.5.20/build.log.1423375821
===> Configuring 5.5.20...


Use tail command to see what's going on:
   $ tail -F /home/dimgraycat/.phpbrew/build/php-5.5.20/build.log


===> Building...
Build finished: 19.6 minutes.
Installing...
      • > Creating php-fpm.conf
      • > Creating php.ini
      • > Copying /home/dimgraycat/.phpbrew/build/php-5.5.20/php.ini-development
      • > Found date.timezone is not set, patching...
Initializing pear config... sh: pear: コマンドが見つかりません sh: pear: コマンドが見つかりません sh: pear: コマンドが見つかりません Enabling pear auto-discover... sh: pear: コマンドが見つかりません Congratulations! Now you have PHP with 5.5.20 as php-5.5.20 To use the newly built PHP, try the line(s) below: $ phpbrew use php-5.5.20 Or you can use switch command to switch your default php to php-5.5.20: $ phpbrew switch php-5.5.20 Enjoy!

おkインストール出来た。
けど、「sh pear: コマンドが見つかりません」ってなんだ・・・!
しかし、build.log見るとインストールしてくれてるみたいなので気にしないでおこう。

CentOS7にperlbrewとcpanmを入れたメモ

新しいサーバにCentOS7を入れたので空っぽの段階から
perlbrewcpanm頑張って入れたメモ。

■ perlbrew を導入する

$ curl -kL http://install.perlbrew.pl | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   315    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  1255  100  1255    0     0    674      0  0:00:01  0:00:01 --:--:--  1594

## Download the latest perlbrew

## Installing perlbrew
Can't locate Getopt/Long.pm in @INC (@INC contains: FatPacked::39156136=HASH(0x25579a8) /usr/share/perl5 /usr/lib64/perl5 /usr/local/share/perl5 /usr/local/lib64/perl5) at perlbrew-8920 line 33.
BEGIN failed--compilation aborted at perlbrew-8920 line 33.
Compilation failed in require at perlbrew-8920 line 5795.
BEGIN failed--compilation aborted at perlbrew-8920 line 5795.

んん?Getopt/Long.pmが入ってないだと?
デフォルトで入ってたと思うけど、、、
とりあえず、yumさんで入れてしまおう。

$ sudo yum -y install perl-Getopt-Long
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
パッケージ perl-Getopt-Long-2.40-2.el7.noarch はインストール済みか最新バージョンです
何もしません

やっぱり入ってるじゃないかー!

なんでだとggrと
https://github.com/gugod/App-perlbrew/issues/409

curl -kL http://install.perlbrew.pl | sed "/\$PERLBREWDOWNLOAD/{N;s|$|sed -i -r '/@INC/ s/([)][}])/ vendorlib vendorarch\\\1/' \\\$LOCALINSTALLER\n|}" | bash

とやると良いよと書いてあった。

ということで、上記ワンライナーで試してみる。

$ curl -kL http://install.perlbrew.pl | sed "/\$PERLBREWDOWNLOAD/{N;s|$|sed -i -r '/@INC/ s/([)][}])/ vendorlib vendorarch\\\1/' \\\$LOCALINSTALLER\n|}" | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   315    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  1255  100  1255    0     0    739      0  0:00:01  0:00:01 --:--:--  6151

## Download the latest perlbrew

## Installing perlbrew
perlbrew is installed: ~/perl5/perlbrew/bin/perlbrew

perlbrew root (~/perl5/perlbrew) is initialized.

Append the following piece of code to the end of your ~/.bash_profile and start a
new shell, perlbrew should be up and fully functional from there:

    source ~/perl5/perlbrew/etc/bashrc

Simply run `perlbrew` for usage details.

Happy brewing!

## Installing patchperl

## Done.

ということで、インストール出来た!

後はいつもの設定

$ source ~/perl5/perlbrew/etc/bashrc
$ echo 'source ~/perl5/perlbrew/etc/bashrc' >> ~/.bashrc

■ cpanmをインストールする

$ perlbrew install-cpanm

cpanm is installed to

    /home/dimgraycat/perl5/perlbrew/bin/cpanm

ということで、完了!

RunTasksをアップデートしました

runtasks.yml内groups配下の設定内容を外部設定として分けれるようになりました。
実際、社内でひっそりと使っていたのですが、
別部署の方々が同じプロジェクトにコミットすることが多くなってきたため
runtasks.ymlが大量になったので部署ごとやタスクグループごとに分けれないかなと思い実装しました。

以前までは下記の様に記載していましたが

config/runtasks.yml

    • -
groups: hourly: - task1 - task2:foo - task3:bar a b c d - task4:hoge "`date -d '1 hours ago' '+%F %H:00:00'`" "`date -d '1 hours ago' '+%F %H:59:59'`" etl1: - task:extract type1 - task:transform type1 - task:load type1 etl2: - task:extract type2 - task:transform type2 - task:load type2

今回のバージョンアップで下記の様に分けることが出来ます。

config/runtasks.yml

    • -
groups: +hourly: hourly.yml +etl: etl.yml

config/runtasks/hourly.yml

hourly:
  - task1
  - task2:foo
  - task3:bar a b c d
  - task4:hoge "`date -d '1 hours ago' '+%F %H:00:00'`" "`date -d '1 hours ago' '+%F %H:59:59'`"

config/runtasks/etl.yml

etl1:
  - task:extract type1
  - task:transform type1
  - task:load type1
etl2:
  - task:extract type2
  - task:transform type2
  - task:load type2

この様にタスクグループの頭に「+」を付加することで別設定ファイルを読み込みます。
また、今まで通りの記述も可能です。

RunTasksの取得はこちらから↓
README.md:fuel-runtasks/README.md at master · dimgraycat/fuel-runtasks · GitHub
圧縮ファイル:Releases · dimgraycat/fuel-runtasks · GitHub

FuelPHPのtasksのcron設定が多くなってきたので

最近もっぱらFuelPHPを使って開発を行っているのですが、
cronの設定がいつの間にか大量になってきたので
ある程度纏めれるFuelPHPのpackageを作成しました。

GitHub - dimgraycat/fuel-runtasks

実際どのようなpackageかは下記をご確認ください。

たとえば、

0 */1 * * * env FUEL_ENV=production php oil refine task1
0 */1 * * * env FUEL_ENV=production php oil refine task2:foo
0 */1 * * * env FUEL_ENV=production php oil refine task3:bar a b c d
0 */1 * * * env FUEL_ENV=production php oil refine task4:hoge "`date -d '1 hours ago' '+\%F \%H:00:00'`" "`date -d '1 hours ago' '+\%F \%H:59:59'`"

こんな感じで毎時に数個のtaskが実行される場合で
特にきっかり全てが0分に動かしたい分けではない時に。

または、

0 1 * * * env FUEL_ENV=production php oil refine task:extract type1
0 1 * * * env FUEL_ENV=production php oil refine task:extract type2
0 2 * * * env FUEL_ENV=production php oil refine task:transform type1
0 2 * * * env FUEL_ENV=production php oil refine task:transform type2
0 3 * * * env FUEL_ENV=production php oil refine task:load type1
0 3 * * * env FUEL_ENV=production php oil refine task:load type2

ETLの処理をcronの設定で処理をさせている時など。

上記のような設定を今回作ったpackageを使用するとこうなります。

まずはcronの設定

0 */1 * * * env FUEL_ENV=production php runtasks hourly
0 1 * * * env FUEL_ENV=production runtasks etl_type1
0 1 * * * env FUEL_ENV=production runtasks etl_type2

runtasksのconfigの設定(YAMLで記載します)

    • -
groups: hourly: - task1 - task2:foo - task3:bar a b c d - task4:hoge "`date -d '1 hours ago' '+%F %H:00:00'`" "`date -d '1 hours ago' '+%F %H:59:59'`" etl_type1: - task:extract type1 - task:transform type1 - task:load type1 etl_type2: - task:extract type2 - task:transform type2 - task:load type2

RunTasksで注意しなければダメなところは、
設定のarrayの部分は上から順に実行されるためあまり長いtaskが設定されているとcronが多重で動き出します。

他にも設定などはありますが、githubの方をご確認ください。

■ 今後の追加予定(:未定)

  • 設定ファイルが長くなるのでグループごとに別ファイルで管理できるようにする
  • 最近話題になったsongmu氏作のApp::RunCron様にSTDOUT, STDERRをLogだけでなく別の物に渡せるように。

後者は設定がもっさりしてくるのであまり追加予定ではないでs

fuelPHPへFluent-logger-phpを導入

fuelphpの導入は割愛します。

どこかに fluent-logger-php をclone。
fuelphp へ src/Fluentd をコピーします。

cp -r src/Fluentd fuel/app/vendor

ツリーで見るとこんな感じ。

├── fuel
│      ├── app
│      │     ├── vendor
│      │     │      └── Fluent
│      │     │               └── Logger
...

次に bootstrap へFluentdの設定をします。
fuel/app/bootstrap.php

require APPPATH.'vendor/Fluent/Autoloader.php';
Fluent\Autoloader::register();

を追加することでFluent-logger-phpが使えるようになります。

例えば tasks で
fuel/app/tasks/test.php

<?php

namespace Fuel\Tasks;

use Fluent\Logger\FluentLogger;

class Test {

    public static function run() {
        $log = new FluentLogger("localhost", "24224");
        $log->post("debug.test", array("hello" => "world"));
    }

}

こんな感じで使えます。

centos6.4 ネットワーク設定

久々に設定して忘れていたのでメモ用に残すだけ。

■ 設定に必要ファイル

/etc/resolv.conf
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0

■ /etc/resolv.conf

  • DNSサーバの設定をの設定をする

nameserver 192.168.X.Y1
nameserver 192.168.X.Y2

■ /etc/sysconfig/network

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=[HOSTNAME]
GATEWAY=192.168.X.Y
GATEWAYDEV=eth0

■ /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
HWADDR=[ mac address ]
TYPE=Ethernet
UUID=[ UUID ]
ONBOOT=yes
NM_CONTROLLED=yes
GATEWAY=192.168.X.Y
BROADCAST=192.168.X.Z
IPADDR=192.168.X.A
NETMASK=255.255.255.0
IPV6INIT=no
IPV6_AUTOCONF=no
PEERDNS=no

細かい説明は割愛します。

※追記

■ /etc/udev/rules.d/70-persistent-net.rules
eth* のmacアドレスとかの設定ファイル

centos5.5にvim7.3をインストール

■ vim7.3のDLと解凍

wget http://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2
tar xjvf vim-7.3.tar.bz2

■ パッチを当てる

mkdir vim73/patches
cd vim73/patches
seq -f http://ftp.vim.org/pub/vim/patches/7.3/7.3.%03g 470 | xargs wget
cd ..
cat patches/7.3.* | patch -p0

コンパイル&インストール

# マルチバイト文字も許可する
./configure --prefix=/usr --enable-multibyte
make
make install

perlのsyntaxがおかしかったから直す

perl-mauke.vimからDLする。

## syntaxのdirが存在しない場合
mkdir .vim/syntax
cd .vim/syntax
wget http://www.vim.org/scripts/download_script.php?src_id=9087 -O perl.vim