EC-CUBE を Solaris10 + Apache2.2 MPM worker + FastCGI で動作させる
EC-CUBE を Solaris 10 + Apache 2.2 MPM worker + FastCGI という, エンタープライズな環境で動かしてみるテスト.
データベースは, Solaris 10 にバンドルしている PostgreSQL 8.3 を使用しました.
FastCGI モジュールは, mod_fcgid を使用しています.
準備
予め, Solaris Software Companion CD から curl をインストールしておく.
# Solaris Software Companion CD をマウントしておく $ cd /cdrom/s10_509_software_companion/Solaris_Software_Companion/Solaris_i386/Packages/ # pkgadd -d `pwd` SFWcurl
また, バンドルしている libiconv では, PHP5 のコンパイルが通らないので, sunfreeware.com から libiconv-1.11 パッケージをインストールしておく
$ curl -O ftp://ftp.sunfreeware.com/pub/freeware/intel/10/libiconv-1.11-sol10-x86-local.gz $ gzip -d libiconv-1.11-sol10-x86-local.gz $ su # pkgadd -d libiconv-1.11-sol10-x86-local
Apache 2.2
$ curl -O http://ftp.riken.jp/net/apache/httpd/httpd-2.2.14.tar.gz $ gzip -dc httpd-2.2.14.tar.gz | tar xvf - $ cd httpd-2.2.14 $ ./configure --prefix=/opt/apache22 --with-ssl=/opt/sfw --enable-mods-shared=all --with-mpm=worker $ make $ su # /usr/ccs/bin/make install
mod_fcgid
$ curl -O http://ftp.riken.jp/net/apache/httpd/mod_fcgid/mod_fcgid-2.3.4.tar.gz $ gzip -dc mod_fcgid-2.3.4.tar.gz | tar xvf - $ cd mod_fcgid-2.3.4 $ APXS=/opt/apache22/bin/apxs ./configure.apxs $ make $ su # /usr/ccs/bin/make install
PHP5
PHP5.3.0 からは, --enable-fastcgi は常に有効となっている
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib $ curl -O http://jp.php.net/distributions/php-5.3.0.tar.gz $ gzip -dc php-5.3.0.tar.gz | tar xvf - $ cd php-5.3.0 $ ./configure --prefix=/opt/php5 --enable-zend-multibyte --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --with-jpeg-dir=/usr --with-png-dir=/usr --with-freetype-dir=/usr/sfw --with-pgsql=/usr/postgres/8.3 --with-pdo-pgsql=/usr/postgres/8.3 --enable-mbstring --with-zlib-dir=/usr --with-pear $ make $ su # LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/sfw/lib:/usr/sfw/lib:/opt/apache22/lib:/usr/local/lib make install
PostgreSQL
Solaris 10 には, PostgreSQL 8.3 がバンドルしているので, これを使う
$ su postgres $ /usr/postgres/8.3/bin/init-db --no-locale -E UTF8 -D /var/lib/pgsql/data $ /usr/postgres/8.3/bin/pg_ctl -w -D /var/lib/pgsql/data start $ /usr/postgres/8.3/bin/createuser eccube_db_user $ /usr/postgres/8.3/bin/createdb eccube_db
httpd.conf の設定
ソケット用のディレクトリを作成し, httpd ユーザーで書き込み可能にしておく
# mkdir -p /var/lib/fcgid/sock # chown -R apache:apache /var/lib/fcgid
以下の内容で, /opt/php5/bin/php-wrapper を作成し, 実行パーミッションを付与する
#!/bin/sh # Set desired PHP_FCGI_* environment variables. # Example: # PHP FastCGI processes exit after 500 requests by default. PHP_FCGI_MAX_REQUESTS=10000 export PHP_FCGI_MAX_REQUESTS # Replace with the path to your FastCGI-enabled PHP executable exec /opt/php5/bin/php-cgi
# chmod +x /opt/php5/bin/php-wrapper
VirtualHost の定義はこんな感じ.
NameVirtualHost 192.168.1.2:80AddHandler fcgid-script .php .cgi # 必ず .cgi をつけないとダメらしい FcgidIPCDir /var/lib/fcgid/sock IPCConnectTimeout 10 IPCCommTimeout 20 OutputBufferSize 0 MaxRequestsPerProcess 500 ServerAdmin nanasess@fsm.ne.jp DocumentRoot "/home/nanasess/workspace/eccube-branches/version-2_4/html" ServerName solaris.ec-cube.net ErrorLog "logs/solaris.ec-cube.net-error_log" CustomLog "logs/solaris.ec-cube.net-access_log" common DirectoryIndex index.php AllowOverride All Options +ExecCGI FCGIWrapper /opt/php5/bin/php-wrapper .php Order allow,deny Allow from all
EC-CUBE の設定
あとは, EC-CUBE をインストールするだけなのですが, .htaccess で php_flag や php_value のオプションが使用できないので, .htaccess のものはコメントアウトし, php.ini や httpd.conf で設定します.
パフォーマンスとか
今回, VMWare Fusion 上の Solaris 10 にインストールしたので, 負荷テストなど未実施です.
設定を詰めれば, おそらくモジュール版の PHP より良い性能を出してくれるはず...
EC-CUBE は, Linux のホストで稼動しているものがほとんどだと思いますが, 今では Solaris 10 も無償利用可能ですし, サポートを付けても, ベーシック・プランなら RHEL の半額程度です. OpenSolaris も気軽に利用できます.
レンタルサーバーでは難しいかもしれませんが, 専用サーバーの場合は Solaris 10 や OpenSolaris を検討しても良いかも.