memo.xight.org

日々のメモ

PHP + Apacheのチューニング

PHPのコンパイル

  いらないものはdisable.
  ApacheはDSOにしない.
  必要なextensionでもたまにしか使わない物はshared objectにしてdl()する.

./configure --with-apache=../apache_1.3.29 --with-mysql=/usr
--enable-mbstring --disable-ipv6 --disable-xml --disable-ctype
--disable-tokenizer --disable-path-info-check --disable-overload
--disable-posix --disable-cli --disable-cgi


Apacheのコンパイル

  まず src/include/httpd.h の HARD_SERVER_LIMIT 256 を 2048 へ変更
  その後configure.
  いらない物は入れない.
  DSOにしない.

./configure --disable-module=actions --disable-module=alias
--disable-module=asis --disable-module=autoindex --disable-module=cgi
--disable-module=imap --disable-module=include
--disable-module=setenvif --disable-module=status
--disable-module=userdir --activate-module=src/modules/php4/libphp4.a


httpd.confの主要な部分の変更

StartServers → リクエスト数の半分くらい?
MaxClients → サーバーが処理できる最大プロセス数の半分以下くらい?
AllowOverride → none (.htaccessを使用しない)
ServerSignature → off (ちょこっとだけ無駄を省く)


mmcacheをインストールしてphp.iniを編集

session.save_handler = mmcache (sessionはmmcacheにおまかせする)
mmcache.sessions="shm_only" (セッション情報は全てメモリ上に)
mmcache.shm_only="1" (キャッシュも全てメモリ上に)
output_buffering = On (ためてWrite()のコールを少なくする)
register_globals = Off
expose_php = Off (ちょこっとだけ無駄を省く)
register_argc_argv = Off


Reference

  PHP-J.com ブログ
  http://phpj.jugem.cc/?eid=6