2006年07月23日一覧

Apache2.2 + PHP5 + eAccelerator + Pukiwiki1.4.7 on VineLinux3.2

Apache2.2が出てから半年以上経ったので新規に構築してみました。ついでにPHPとPukiwikiもバージョン上げました。

Apache2.2

ダウンロード&解凍

# wget http://www.apache.jp/dist/httpd/httpd-2.2.2.tar.gz
14:56:24 (607.73 KB/s) - `httpd-2.2.2.tar.gz' を保存しました [6282043/6282043]
# tar zxf httpd-2.2.2.tar.gz
# cd httpd-2.2.2

SSLに対応させたいのでopenssl-develを入れておく。

# apt-get install openssl-devel

インストール。オプションは適当に。

# ./configure --enable-mods-shared='auth_digest headers rewrite dav dav-fs ssl' --enable-so --with-ssl=/usr
# make
# make install

起動してみる。

# /usr/local/apache2/bin/apachectl start

ブラウザでアクセスしてみる。

It works!

前バージョンまでに比べ、限りなく寂しい画面が現れる。

ドキュメントルートディレクトリの作成。

# mkdir -p /home/httpd/html

動作ユーザーの作成。

# useradd -s /bin/false -d /dev/null apache

設定ファイルの編集

# vi /usr/local/apache2/conf/httpd.conf
動作ユーザーの設定
User apache
Group apache
サーバ名
ServerName 192.168.0.2:80
ドキュメントルート
DocumentRoot "/home/httpd/html"
htmlディレクトリの設定
Options MultiViews SymLinksIfOwnerMatch Includes
?/でアクセスしたときに表示するファイル
DirectoryIndex index.html index.shtml index.php
ログの設定
ローカルからのアクセスはhomelogに記録
SetEnvIf Remote_Addr 192.168.0. homelog nolog
SetEnvIf Remote_Addr 127.0.0.1 homelog nolog
homelogはhome_logに記録
CustomLog logs/home_log common env=homelog
nolog以外はaccsess_logに記録
CustomLog logs/access_log combined env=!nolog
エイリアス
Alias /cgi-bin/ "/home/httpd/cgi-bin/"
cgi-binディレクトリの設定
AllowOverride None
Options FollowSymLinks MultiViews ExecCGI
Order allow,deny
Allow from all
cgi許可
AddHandler cgi-script .cgi
SSI許可
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

自動起動スクリプトを作成し/etc/init.d/に入れる。

# cp apache2 /etc/init.d/
# chmod 755 /etc/init.d/apache2

起動

# /etc/init.d/apache2 restart
httpdを停止中: [ OK ]
httpdを起動中: [ OK ]

自動起動するようにする。

# ntsysv

PHP5.1.4

ダウンロード&解凍

# wget http://jp2.php.net/get/php-5.1.4.tar.gz/from/jp.php.net/mirror
16:20:53 (2.03 MB/s) - `php-5.1.4.tar.gz' を保存しました [8109575/8109575]
# tar zxf php-5.1.4.tar.gz
# cd php-5.1.4

以下のパッケージを入れておく

# apt-get install flex \
bzip2-devel \
libjpeg-devel \
libpng-devel \
libxml2-devel \
MySQL-server \
MySQL-devel \
t1lib-devel \
zlib-devel

インストール

# ./configure \
--prefix=/usr \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-config-file-path=/etc \
--with-mysql=/usr \
--with-jpeg-dir=/usr \
--with-zlib-dir=/usr \
--with-bz2 \
--with-openssl \
--with-gd \
--with-t1lib \
--with-ttf \
--enable-exif \
--enable-mbregex \
--enable-mbstring \
--enable-zend-multibyte \
--enable-gd-jis-conv \
--enable-gd-native-ttf
# make
# make install

設定ファイルのコピー

# cp php.ini-dist /etc/php.ini

設定ファイルの編集

# vi /etc/php.ini
output_buffering = On
output_handler = mb_output_handler
magic_quotes_gpc = Off

apacheの設定ファイルに以下を追加

# vi /usr/local/apache2/conf/httpd.conf
   AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

apache再起動

# /etc/init.d/apache2 restart
httpdを停止中: [ OK ]
httpdを起動中: [ OK ]

動作確認。以下の内容のphpファイルをドキュメントルートにおいてアクセス。うまくいけば設定情報が見れるはずだ!

# vi /home/httpd/html/info.php
< ?php phpinfo() ?>

eAccelerator

PHPの処理を高速に行うアドイン(?)みたいなもの。今まではPHPAcceleratorを使っていたけど、更新されていないようで、PHP5には対応していないみたい。なので、今回はPHP5.1.xに対応しているeAccelerator-0.9.5-beta2を導入してみた。なにやらスレッドセーフにも対応していそうな雰囲気。

ダウンロード&解凍

# wget http://jaist.dl.sourceforge.net/sourceforge/eaccelerator/eaccelerator-0.9.5-beta2.tar.bz2
17:45:03 (679.89 KB/s) - `eaccelerator-0.9.5-beta2.tar.bz2' を保存しました [113387/113387]
# tar zxf eaccelerator-0.9.5-beta2.tar.bz2
# cd eaccelerator-0.9.5-beta2

インストール

# export PHP_PREFIX="/usr"
# $PHP_PREFIX/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20050922
Zend Extension Api No: 220051025
# ./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
# make
# make install

php.iniに以下の内容を追加

# vi /etc/php.ini
[eaccelerator]
zend_extension = "/usr/lib/php/extensions/no-debug-non-zts-20050922/eaccelerator.so" ;exte
nsion="eaccelerator.so"
eaccelerator.shm_size = "16"
キャッシュディレクトリの指定
eaccelerator.cache_dir = "/tmp/eaccelerator"
eaccelerator.enable = "1"
eaccelerator.optimizer = "1"
eaccelerator.check_mtime = "1"
eaccelerator.debug = "0"
eaccelerator.filter = ""
eaccelerator.shm_max = "0"
eaccelerator.shm_ttl = "0"
eaccelerator.shm_prune_period = "0"
eaccelerator.shm_only = "0"
eaccelerator.compress = "1"
eaccelerator.compress_level = "9"
eaccelerator.keys = "shm_and_disk"
eaccelerator.sessions = "shm_and_disk"
eaccelerator.content = "shm_and_disk"
管理ツールを置く場所を指定
eaccelerator.allowed_admin_path = "/home/httpd/html/admin"

キャッシュディレクトリの作成

# mkdir /tmp/eaccelerator
# chmod 777 /tmp/eaccelerator/

管理ツールのコピー

# mkdir /home/httpd/html/admin
# cp control.php /home/httpd/html/admin

apache再起動

# /etc/init.d/apache2 restart
httpdを停止中: [ OK ]
httpdを起動中: [ OK ]

動作確認。control.phpにアクセスしてCached scriptsの一覧が表示されていればOK。また、info.phpにアクセスすればZend Engineのロゴのところに、

with eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator

が追加されているはず。

例によってPukiwikiのHTML convert timeを比べてみた。

  • 使用前
    HTML convert time: 0.189 sec
    
  • 使用後
    1回目
    HTML convert time: 0.239 sec.
    2回目
    HTML convert time: 0.102 sec.

1回目はキャッシュするため若干遅いが2回目以降は速くなっている。

Pukiwiki-1.4.7



スポンサーリンク