PHP apc Xdebugのインストール
PHPと各種ライブラリのインストール
yum --enablerepo=remi,epel,rpmforge install php php-mbstring php-devel php-pear php-mysql php-gd php-mcrypt php-pcre php-xml
インストールに必要なパッケージをインストール
PECLを使うためにmake, gcc、APCインストール時にpcre-develが必要になる。
yum --enablerepo=remi,epel,rpmforge install make gcc pcre-devel
他にも後々必要になると思われるパッケージをここでまとめてインストールしておく。
(minimalでインストールしているのでほとんど何も入っていない状態)
yum --enablerepo=remi,epel,rpmforge install readline-devel curl-devel ImageMagick ImageMagick-devel yum --enablerepo=remi,epel,rpmforge install wget rsync subversion git
APCのインストール
いくつか入力を求められるが全てデフォルトで設定
pecl install apc
インストール完了後に出るメッセージにしたがって設定ファイルを編集する
Build process completed successfully Installing '/usr/lib/php/modules/apc.so' Installing '/usr/include/php/ext/apc/apc_serializer.h' install ok: channel://pecl.php.net/APC-3.1.9 configuration option "php_ini" is not set to php.ini location You should add "extension=apc.so" to php.ini
/etc/php.ini には、
; Note: packaged extension modules are now loaded via the .ini files ; found in the directory /etc/php.d; these are loaded by default.
とあるので、apc用の設定ファイル(apc.ini)を作り、extension=apc.so も含めて管理する。
extension=apc.so apc.enabled=1 apc.shm_segments=1 apc.shm_size=128M apc.ttl=7200 apc.user_ttl=7200 apc.num_files_hint=1024 apc.mmap_file_mask=/tmp/apc.XXXXXX apc.enable_cli=1
タイムゾーンの設定
date.timezoneの設定をしないと、Warningが発生するのでphp.iniに設定しておく。
PHP Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for 'JST/9.0/no DST' instead in Unknown on line 0
vi /etc/php.ini
[Date] ; Defines the default timezone used by the date functions ; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone date.timezone = "Asia/Tokyo"
Xdebugのインストール
pecl install xdebug
インストール完了時に下記メッセージが出るので、APCと同様にxdebug.iniを作る
Build process completed successfully Installing '/usr/lib/php/modules/xdebug.so' install ok: channel://pecl.php.net/xdebug-2.2.1 configuration option "php_ini" is not set to php.ini location You should add "extension=xdebug.so" to php.ini
remote_host にはXdebugを利用するクライアント、今回だとホストOSのWMnet8のIPアドレスを設定する。
extension=xdebug.so zend_extension=/usr/lib/php/modules/xdebug.so xdebug.remote_enable=on xdebug.remote_handler=dbgp xdebug.remote_host=192.168.136.1 xdebug.remote_port=9000
apacheを再起動して・・
[root@localhost ]# /etc/init.d/httpd restart httpd を停止中: [ OK ] httpd を起動中: [ OK ]
確認
[root@localhost ]# php -i | grep xdebug PHP Warning: Xdebug MUST be loaded as a Zend extension in Unknown on line 0 PHP Warning: Module 'xdebug' already loaded in Unknown on line 0
インストール時に出た「You should add "extension=xdebug.so" to php.ini」はウソってことか・・
Xdebug: Documentation にも
> Note: You should ignore any prompts to add "extension=xdebug.so" to php.ini ― this will cause problems.
とあった。
extension=xdebug.so の設定を削除し、apacheを再起動
- extension=xdebug.so
再度確認
[root@localhost ]# php -i | grep xdebug xdebug support => enabled