php-mcrypt

CentOS5.6がリリースされたので開発環境をアップデート。

ついでにPHPも5.3系を入れてみた。

以前の記事にも書いたが、php-mcryptRedHatでサポートされなくなった。
phpMyAdmin使いたいという要望があるので、どうにかしてphp-mcryptをインストールする方法をご紹介。

1.php53のSRPMを取得する。
# wget ftp://ftp.riken.jp/Linux/centos/5.6/updates/SRPMS/php53-5.3.3-1.el5_6.1.src.rpm

2.SRPMをインストール
# rpm -i php53-5.3.3-1.el5_6.1.src.rpm

3.インストールされたソース確認
# cd /usr/src/redhat/SOURCES
# ls
4.mcryptのあるディレクトリへ
# cd /usr/src/redhat/SOURCES/php-5.3.3/ext/mcrypt

5.mcryptコンパイル
# ./configure
# make
# make install

Installing shared extensions: /usr/lib/php/modules/
この辺にインストールされているはず。

6.mcrypt有効化
# cd /etc/php.d
# vi mcrypt.ini
extension=mcrypt.so

7.httpdを再起動

SRPMからじゃなくて、普通にphp5.3.3のソースを展開しても大丈夫な気がする。

サーバー管理者向けの良い本


はてなのインフラ構築からサーバー管理者向けの技術本。
これからサーバー管理者になる方、運営サイトの負荷に悩んでる方必見。
大規模インフラ構築の基本が載ってます。

運営しているサイトが中規模になってきたため、負荷をどのように分散できるかの参考にこの本を読みました。
memcachedはかなり使えます。

RedHatEL5.6のPHP5.3を野良コンパイル

先日、RedHatEL5.6がリリースされた。

php53というパッケージが追加され、EL6に移行しなくてもPHP5.3が使えるようになる。

CentOS5.6が待てないので、とりあえずRedHatのphp53パッケージをCentOS5.5で野良コンパイルしてみた。
CentOS5.6にアップデートしてもたぶん大丈夫だろう。

SRPMをダウンロードしてくる

ここらへんから
http://ftp.redhat.com/redhat/linux/enterprise/5Server/en/os/SRPMS/
php53-5.3.3-1.el5.src.rpm

野良コンパイルの準備

一般ユーザーの場合は↓参照
http://www.atmarkit.co.jp/flinux/rensai/linuxtips/952rpmbuild.html

ビルドコマンド実行

$ rpmbuild --rebuild --target x86_64 --define 'dist .el5' php53-5.3.3-1.el5.src.rpm
warning: InstallSourcePackage: Header V3 DSA signature: NOKEY, key ID 37017186
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
error: Failed build dependencies:
        bzip2-devel is needed by php53-5.3.3-1.el5.x86_64
        curl-devel >= 7.9 is needed by php53-5.3.3-1.el5.x86_64
        db4-devel is needed by php53-5.3.3-1.el5.x86_64
        gmp-devel is needed by php53-5.3.3-1.el5.x86_64
        httpd-devel >= 2.0.46-1 is needed by php53-5.3.3-1.el5.x86_64
        pam-devel is needed by php53-5.3.3-1.el5.x86_64
        openssl-devel is needed by php53-5.3.3-1.el5.x86_64
        sqlite-devel is needed by php53-5.3.3-1.el5.x86_64
        zlib-devel is needed by php53-5.3.3-1.el5.x86_64
        pcre-devel >= 6.6 is needed by php53-5.3.3-1.el5.x86_64
        libtool >= 1.4.3 is needed by php53-5.3.3-1.el5.x86_64
        krb5-devel is needed by php53-5.3.3-1.el5.x86_64
        libc-client-devel is needed by php53-5.3.3-1.el5.x86_64
        cyrus-sasl-devel is needed by php53-5.3.3-1.el5.x86_64
        openldap-devel is needed by php53-5.3.3-1.el5.x86_64
        mysql-devel >= 4.1.0 is needed by php53-5.3.3-1.el5.x86_64
        postgresql-devel is needed by php53-5.3.3-1.el5.x86_64
        unixODBC-devel is needed by php53-5.3.3-1.el5.x86_64
        libxml2-devel is needed by php53-5.3.3-1.el5.x86_64
        net-snmp-devel is needed by php53-5.3.3-1.el5.x86_64
        libxslt-devel >= 1.0.18-1 is needed by php53-5.3.3-1.el5.x86_64
        libxml2-devel >= 2.4.14-1 is needed by php53-5.3.3-1.el5.x86_64
        libXpm-devel is needed by php53-5.3.3-1.el5.x86_64
        libjpeg-devel is needed by php53-5.3.3-1.el5.x86_64
        libpng-devel is needed by php53-5.3.3-1.el5.x86_64
        freetype-devel is needed by php53-5.3.3-1.el5.x86_64
        aspell-devel >= 0.50.0 is needed by php53-5.3.3-1.el5.x86_64
        libicu-devel >= 3.6 is needed by php53-5.3.3-1.el5.x86_64

なんかいっぱい要求されたw
warning〜は気にしなくていいらしい。

とりあえず、rootになって要求されたパッケージインストール

# yum install -y bzip2-devel curl-devel db4-devel gmp-devel httpd-devel pam-devel openssl-devel sqlite-devel zlib-devel  pcre-devel libtool krb5-devel libc-client-devel cyrus-sasl-devel openldap-devel mysql-devel postgresql-devel unixODBC-devel libxml2-devel net-snmp-devel libxslt-devel libxml2-devel libXpm-devel libjpeg-devel libpng-devel freetype-devel aspell-devel libicu-devel

再度コンパイル実行
$ rpmbuild --rebuild --target x86_64 --define 'dist .el5' php53-5.3.3-1.el5.src.rpm

まだ何か足りなさそう。

checking for bison... no
checking for byacc... no
checking for bison version... invalid
configure: WARNING: bison versions supported for regeneration of the Zend/PHP parsers: 1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 (found: none).
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.

#  yum install bison byacc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: ftp.riken.jp
 * base: ftp.riken.jp
 * extras: ftp.riken.jp
 * updates: ftp.riken.jp
Setting up Install Process
Resolving Dependencies
    • > Running transaction check
      • > Package bison.x86_64 0:2.3-2.1 set to be updated
      • > Package byacc.x86_64 0:1.9-29.2.2 set to be updated
    • > Finished Dependency Resolution

re2cも入れておく

# wget http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz/download
# tar xfz re2c-0.13.5.tar.gz
# cd re2c-0.13.5
# ./configure
# make
# make install

なんかまだPHPのチェックでエラーでてる・・・
えい。めんどくさい。開発関係ぜんぶいれてやれ。

# yum groupinstall "Development Tools"
# yum groupinstall "Development Libraries"
$ rpmbuild --rebuild --target x86_64 --define 'dist .el5' php53-5.3.3-1.el5.src.rpm
(省略)
=====================================================================
FAILED TEST SUMMARY
                                                                                                                                        • -
Testing php_egg_logo_guid() function [tests/basic/php_egg_logo_guid.phpt] Class constant whose initial value refereces a non-existent class [tests/classes/constants_error_004.phpt] easter_date() [ext/calendar/tests/easter_date.phpt] unixtojd() [ext/calendar/tests/unixtojd.phpt] timezone_abbreviations_list() tests [ext/date/tests/010.phpt] Test DateTime::modify() function : usage variation - Passing unexpected values to first argument $modify. [ext/date/tests/DateTime_modify_variation1.phpt] Bug #33415 [2] (Possibly invalid non-one-hour DST or timezone shifts) [ext/date/tests/bug33415-2.phpt] Bug #48187 (DateTime::diff() corrupting microtime() result) [ext/date/tests/bug48187.phpt] Bug #50475 (DateTime::setISODate followed by DateTime::setTime) [ext/date/tests/bug50475.phpt] Bug #51819 (Case discrepancy in timezone names cause Uncaught exception and fatal error) [ext/date/tests/bug51819.phpt] Bug #51994 (date_parse_from_format is parsing invalid date using 'yz' format) [ext/date/tests/bug51994.phpt] Bug #52290 (setDate, setISODate, setTime works wrong when DateTime created from timestamp) [ext/date/tests/bug52290.phpt] Test date_modify() function : usage variation - Passing unexpected values to second argument $format. [ext/date/tests/date_modify_variation2.phpt] Test timezone_abbreviations_list() function : basic functionality [ext/date/tests/timezone_abbreviations_list_basic1.phpt] timezone_location_get: Test that timezone_location_get returns a correct array of information [ext/date/tests/timezone_location_get.phpt] Feature Request #50283 (allow base in gmp_strval to use full range: 2 to 62, and -2 to -36) [ext/gmp/tests/bug50283.phpt] Bug #41638 (pcre 7.0 regression) [ext/pcre/tests/bug41638.phpt] Bug #42298 (pcre gives bogus results with /u) [ext/pcre/tests/bug42298.phpt] ReflectionClass::getConstructor() [ext/reflection/tests/ReflectionClass_getConstructor_basic.phpt] ReflectionMethod::isConstructor() [ext/reflection/tests/ReflectionMethod_constructor_basic.phpt] ReflectionObject::getConstructor() - basic function test [ext/reflection/tests/ReflectionObject_getConstructor_basic.phpt] a script should not be able to modify session.use_trans_sid [ext/session/tests/014.phpt] use_trans_sid should not affect SID [ext/session/tests/015.phpt] rewriter correctly handles attribute names which contain dashes [ext/session/tests/018.phpt] rewriter uses arg_seperator.output for modifying URLs [ext/session/tests/020.phpt] rewriter handles form and fieldset tags correctly [ext/session/tests/021.phpt] Bug #31454 (Incorrect adding PHPSESSID to links, which contains \r\n) [ext/session/tests/bug36459.phpt] Bug #41600 (url rewriter tags doesn't work with namespaced tags) [ext/session/tests/bug41600.phpt] Test session_encode() function : error functionality [ext/session/tests/session_encode_error2.phpt] SimpleXML: XPath [ext/simplexml/tests/008.phpt] Bug #51615 (PHP crash with wrong HTML in SimpleXML) [ext/simplexml/tests/bug51615.phpt] Test fscanf() function: usage variations - unsigned int formats with integer values [ext/standard/tests/file/fscanf_variation39.phpt] Test fscanf() function: usage variations - tracking file pointer while reading [ext/standard/tests/file/fscanf_variation55.phpt] Bug #44394 (Last two bytes missing from output) with session.use_trans_id [ext/standard/tests/general_functions/bug44394_2.phpt] htmlentities() / html_entity_decode() #8592 - #9002 table test [ext/standard/tests/strings/htmlentities17.phpt] Test sscanf() function : basic functionality - unsigned format [ext/standard/tests/strings/sscanf_basic6.phpt] ===================================================================== ===================================================================== EXPECTED FAILED TEST SUMMARY
                                                                                                                                        • -
output buffering - fatalism [tests/output/ob_011.phpt] Inconsistencies when accessing protected members [Zend/tests/access_modifiers_008.phpt] Inconsistencies when accessing protected members - 2 [Zend/tests/access_modifiers_009.phpt] Bug #48770 (call_user_func_array() fails to call parent from inheriting class) [Zend/tests/bug48770.phpt] Bug #48770 (call_user_func_array() fails to call parent from inheriting class) [Zend/tests/bug48770_2.phpt] Bug #48770 (call_user_func_array() fails to call parent from inheriting class) [Zend/tests/bug48770_3.phpt] SimpleXML: array casting bug [ext/simplexml/tests/034.phpt] Bug #39863 (file_exists() silently truncates after a null byte) [ext/standard/tests/file/bug39863.phpt] =====================================================================

なんかテストまだエラーでてるけど・・・。ま、いっか。
とりあえず、rpmはできたので。

$ cd ../RPMS
$ ll -G -g
total 13332
-rw-r--r-- 1 4345396 Jan 27 16:06 php53-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1   85009 Jan 27 16:06 php53-bcmath-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1 2751789 Jan 27 16:06 php53-cli-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1 1247899 Jan 27 16:06 php53-common-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1  137380 Jan 27 16:06 php53-dba-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1  611538 Jan 27 16:06 php53-devel-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1  347931 Jan 27 16:06 php53-gd-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1  113370 Jan 27 16:06 php53-imap-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1  343364 Jan 27 16:06 php53-intl-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1   69120 Jan 27 16:06 php53-ldap-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1 1535891 Jan 27 16:06 php53-mbstring-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1  313225 Jan 27 16:06 php53-mysql-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1  122708 Jan 27 16:06 php53-odbc-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1  178956 Jan 27 16:06 php53-pdo-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1  185038 Jan 27 16:06 php53-pgsql-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1  105595 Jan 27 16:06 php53-process-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1   43657 Jan 27 16:06 php53-pspell-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1   48589 Jan 27 16:06 php53-snmp-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1  382597 Jan 27 16:06 php53-soap-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1  427156 Jan 27 16:06 php53-xml-5.3.3-1.el5.x86_64.rpm
-rw-r--r-- 1  143052 Jan 27 16:06 php53-xmlrpc-5.3.3-1.el5.x86_64.rpm

php-mcryptはサポートされてないんだ・・・。
ショボーン(´・ω・`)

とりあえずできたものはこの辺に保存。
ftp://ns.cool-creators.com/pub/centos/5/RPMS/

Scientic Linux 6.0 α4のMySQL

RHEL6.0の再編集版であるScientic Linux6.0のα4をインストールしてみた。
とりあえずどんな感じになってるのかの途中検証。

PHP5.3でMySQLも5.1と快適なパッケージ構成になっています。

テスト的に使ったのですが、どうしてもMySQLに日本語がINSERTできない。

[root@sl6a4 html]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 156
Server version: 5.1.47 Source distribution
mysql> use sample db;
mysql> set names utf8;
mysql> INSERT INTO member (name) VALUE ('test');
mysql> INSERT INTO member (name) VALUE ('日本語test');
mysql> INSERT INTO member (name) VALUE ('日本語テスト');
mysql> INSERT INTO member (name) VALUE ('テスト');

mysql> SELECT * FROM member;
+----+---------+
| id | name    |
+----+---------+
| 19 | test    |
| 20 | ???test |
| 21 | ??????  |
| 22 | ???     |
+----+---------+
4 rows in set (0.00 sec)

日本語が全部?で返ってくる。

PHP側から実行しても同じ。
set namesが効かないのかな・・・。

mysql> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

現時点で不明ということで・・・。

openx 2.8.5

DBの文字化け対応

■openx/lib/OA/DB.php
追加場所:

$oDbh->setFetchMode(MDB2_FETCHMODE_ASSOC);

上記の下に追加:

$oDbh->query(“SET NAMES utf8”);


■openx/lib/OA/Dal/Delivery/mysql.php

追加場所:

if (@mysql_select_db($dbName, $dbLink)) {

上記の下に追加:

@mysql_query(“SET NAMES utf8”);

上記を設定しなくても、var/hogehoge.conf.phpの中で

[databaseCharset]
checkComplete=1
clientCharset=utf8

とすれば大丈夫かも。(未確認)

表示の文字化け対応

lib/max/other/html.php

function MAX_buildName($id, $name)
{
return htmlentities($name);
}

上記を下記に変更

function MAX_buildName($id, $name)
{
return htmlentities($name, ENT_COMPAT, "UTF-8");
}


あと、通知メールが文字化けしてるなぁ・・・どこだろう。