*PHP [#c4e576ed]
[[PHP:+http://php.net/]]
色々なWebアプリを動かすのに必須なミドルウェア。LAMPの"P"たる所以。
PHP5.4以下とPHP5.5以上の間に開発の壁があり、5.4だと動いた物が5.5だと動かなかったりする。
また、現在のPHPオフィシャルメンテナー期間はメジャーバージョンリリースがされた2世代前までなので、
PHP5.7が公開されたら、オフィシャル版PHP5.4も終息となる予定。
*Barnyard2 [#c1639a76]
[[Barnyard2:+https://github.com/firnsy/barnyard2]]
Snortが検出した不正侵入ログをMySQLへ書き出してくれるプログラム。
アーカイブパッケージのver0.2.xと、Gitで配布されているver2.1.xの二種類がある。
MySQLへの出力に対応しているのはGit版。
~
ただし、CentOSプロジェクトとか他メンテナーが絡んでいる物は、そっち側の意向によって変化する。
例:CentOSのyumのBaseリポジトリで提供しているPHP5.3はCentOS6が終了するまでメンテナンスする予定 --> [[メモ記事>+http://www.ns-lab.org/digiloog/2014/09/article_2613/]]
~
*インストール [#wf288ab0]
*インストール [#baee7b27]
&size(16){&font(b){0. ビルドオプション};};
長いオプションを使うので、オプションの意味は割愛。大体は『$ ./configure --help』打てば出る。
以下は改行してあるが、実際には一行化した上でconfigure.optionとかに出力しておき、
『$ ./configure `cat ../configure.option`』とかにすると楽。
 --prefix=/usr/local/php \
 --sysconfdir=/etc \
 --with-apxs2=/usr/local/apache/bin/apxs \
今回はGitからソースを取ってくるが、最終的にはconfigureをかけるのでレシピを作っておく。
 # vi configure.option
 =====
 --prefix=/usr/local/barnyard-2.1.13 \
 --with-mysql=/usr/local/mysql \
 --with-mysqli=mysqlnd \
 --with-pdo-mysql=mysqlnd \
 --with-libdir=lib64 \
 --with-curl=/usr/lib64 \
 --with-jpeg-dir=/usr/lib64 \
 --with-png-dir=/usr/lib64 \
 --with-vpx-dir=/usr/lib64 \
 --with-xpm-dir=/usr/lib64 \
 --with-bz2 \
 --with-gd \
 --with-gettext \
 --with-gmp \
 --with-iconv \
 --with-kerberos \
 --with-layout \
 --with-openssl \
 --with-pic \
 --with-xmlrpc \
 --with-zlib \
 --without-pspell \
 --without-unixODBC \
 --enable-bcmath \
 --enable-calendar \
 --enable-cli \
 --enable-exif \
 --enable-ftp \
 --enable-gd-native-ttf \
 --enable-intl \
 --enable-mbstring \
 --enable-pcntl \
 --enable-pdo \
 --enable-shmop \
 --enable-soap \
 --enable-sockets \
 --enable-sysvmsg \
 --enable-sysvsem \
 --enable-sysvshm \
 --enable-xml \
 --enable-xmlreader \
 --enable-xmlwriter \
 --enable-zip \
 --disable-dba \
 --disable-debug \
 --disable-dom \
 --disable-fileinfo \
 --disable-phar \
 --disable-posix \
 --disable-rpath \
 --disable-sysvmsg \
 --disable-sysvsem \
 --disable-sysvshm \
 --disable-wddx
 --with-mysql-includes=/usr/local/mysql/include \
 --with-mysql-libraries=/usr/local/mysql/lib
~
&size(16){&font(b){1. ビルド};};
上記のconfigureオプションを別ファイル化した場合のビルド例
 # tar jxvf php-5.6.1.tar.bz2
 # cd php-5.6.1
 # ./configure `cat ../configure.option`
&size(16){&font(b){1. インストール};};
今回はGitからソースを取ってくる。Gitコマンドが入っていない場合はyumとかapt-getで入れておく。
 # cd /usr/local/src
 # git clone "https://github.com/firnsy/barnyard2" barnyard
 # cd barnyard
 # ./autogen.sh
 # ./configure `cat configure.option`
 # make
 # make test
 # make install
 # cd /usr/local
 # ln -s /usr/local/barnyard-2.1.13 ./barnyard
~
&size(16){&font(b){2. 設定};};
ソースコードの中にphp.iniが入っているので、それを/etcにコピーして使用する。
また、apacheとの連携をしている場合はhttpd.confにPHPのLoadModuleが追記されているかも確認する
 # cp {$PHP_SrcDIR}/php.ini-development /etc/php.ini
init用にbarnyard2バイナリへのシンボリックリンクも追加する必要がある。
あと、Barnyard2用のMySQLユーザとテーブルは事前に作成しておく。
 # cd /usr/local/src/barnyard
 # cp rpm/barnyard2 /etc/init.d/barnyard2
 # cp rpm/barnyard2.config /etc/sysconfig/barnyard2
 # ln -s /usr/local/barnyard/bin/barnyard2 /usr/bin/barnyard2
 # ln -s /usr/local/barnyard/etc/barnyard2.conf /etc/snort/barnyard.conf
 # mysql -u "Barnyard2用のDBユーザ" -p "Barnyard2用のDB名" < ./schemas/create_mysql
~
『$ ./configure --sysconfdir=/etc』を外した場合はコンフィグの場所が変わる
&font(b){/usr/local/php/etcでは無い};ので注意
 # cp {$PHP_SrcDIR}/php.ini-development /usr/local/php/lib/php.ini
他には、Snortとの連携に必要なファイルとディレクトリも作成する。
 # mkdir /var/log/barnyard2
 # touch /var/log/snort/barnyard2.waldo
~
&size(16){&font(b){2. Barnyard2のコンフィグ};};
※以下のメモでは変更した箇所のみを記載
 # vi /etc/init.d/varnyard2
 =====
 6 :: # chkconfig: 2345 85 15
 12 :: # pidfile: /var/lock/subsys/barnyard2.pid <- 削除する
 20 :: [ -x /usr/local/snort/bin/snort ] || exit 1
 36 :: PIDFILE="/run/barnyard2-$INT.pid"
 37 :: #ARCHIVEDIR="$SNORTDIR/$INT/archive"
 38 :: WALDO_FILE="$SNORTDIR/barnyard2.waldo"
 39 :: BARNYARD_OPTS="-D -c $CONF -d $SNORTDIR -w $WALDO_FILE -f $LOG_FILE -X $PIDFILE $EXTRA_ARGS"
~
 # vi /etc/sysconfig/barnyard2
 =====
 2 :: # LOG_FILE="snort-barnyard.log"
~
 # vi /etc/snort/barnyard.conf
 =====
 まだメモ中