読者です 読者をやめる 読者になる 読者になる

It's raining cats and dogs.

無駄なことなんてないはず

anyenvのphpenvでphp5.5を入れた時にapcの設定でハマった件

anyenvでphpenvを入れて、php5.5を入れて適当なphp書いて、ビルトインサーバで実行してみたら以下の様なnoticeが出た。

Notice: Unknown: 1. h->opened_path=[null] h->filename=[/private/var/apps/sample/index.php] in Unknown on line 0
Notice: Unknown: apc_cache_find [220575364] in Unknown on line 0
Notice: Unknown: 2. h->opened_path=[/private/var/apps/sample/index.php] h->filename=[/private/var/apps/sample/index.php] in Unknown on line 0
Notice: Unknown: apc_cache_make_file_entry: entry->data.file.filename is [/private/var/apps/sample/index.php] in Unknown on line 0
Notice: Unknown: Inserting [/private/var/apps/sample/index.php] in Unknown on line 0

php5.5からデフォルトOpecacheになったのになんでapcとか使われてるんだろうとおもって、php -iしてみたら

$ php -i | grep apc
Configure Command =>  './configure'  '--with-apxs2=/usr/sbin/apxs' '--enable-option-checking' '--enable-phar' '--disable-intl' '--with-libxml-dir=/usr/local/opt/libxml2' '--with-openssl=/usr/local/opt/openssl' '--with-openssl-dir=/usr/local/opt/openssl' '--with-kerberos=/usr' '--with-zlib' '--with-zlib-dir=/usr/local/opt/zlib' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--enable-exif' '--with-png-dir=/usr/local/opt/libpng' '--with-jpeg-dir=/usr/local/opt/jpeg' '--with-freetype-dir=/usr/local/opt/freetype' '--with-xpm-dir=/usr/X11' '--with-gd=/usr/local' '--enable-gd-native-ttf' '--with-pear' '--enable-mbstring' '--enable-mbregex' '--enable-shmop' '--enable-soap' '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--enable-wddx' '--with-xmlrpc' '--with-xsl=/usr/local/opt/libxslt' '--enable-zip' '--with-pcre-regex=/usr/local/opt/pcre' '--with-vpx-dir=/usr/local/opt/libvpx' '--with-pcre-dir=/usr/local/opt/pcre' '--with-curl=/usr/local/opt/curl' '--with-iconv-dir=/usr/local/opt/libiconv' '--with-mcrypt=/usr/local/opt/mcrypt' '--with-libexpat-dir=/usr/local/opt/expat' '--with-gettext=/usr/local/opt/gettext' '--enable-pcntl' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-mysql-sock=/tmp/mysql.sock' '--with-readline=/usr/local/opt/readline' '--enable-apc' '--enable-apc-debug' '--enable-apc-filehits' '--enable-igbinary' '--enable-memcached' '--with-libmemcached-dir=/usr/local/opt/libmemcached' '--enable-memcached-igbinary' '--with-http-curl-requests=/usr/local/opt/curl' '--with-http-curl-libevent=/usr/local/opt/libevent' '--with-http-zlib-compression=/usr/local/opt/zlib' '--with-http-magic-mime=/usr/local/opt/libmagic' '--with-config-file-path=/Users/t-yamaguchi/.anyenv/envs/phpenv/versions/5.5.9/etc' '--with-config-file-scan-dir=/Users/t-yamaguchi/.anyenv/envs/phpenv/versions/5.5.9/etc/conf.d' '--prefix=/Users/t-yamaguchi/.anyenv/envs/phpenv/versions/5.5.9'
apc
apc.cache_by_default => On => On
apc.canonicalize => On => On
apc.coredump_unmap => Off => Off
apc.enable_cli => Off => Off
apc.enabled => On => On
apc.file_md5 => Off => Off
apc.file_update_protection => 2 => 2
apc.filters => no value => no value
apc.gc_ttl => 3600 => 3600
apc.include_once_override => Off => Off
apc.lazy_classes => Off => Off
apc.lazy_functions => Off => Off
apc.max_file_size => 1M => 1M
apc.mmap_file_mask => no value => no value
apc.num_files_hint => 1000 => 1000
apc.preload_path => no value => no value
apc.report_autofilter => Off => Off
apc.rfc1867 => On => On
apc.rfc1867_freq => 0 => 0
apc.rfc1867_name => APC_UPLOAD_PROGRESS => APC_UPLOAD_PROGRESS
apc.rfc1867_prefix => upload_ => upload_
apc.rfc1867_ttl => 3600 => 3600
apc.serializer => igbinary => igbinary
apc.shm_segments => 1 => 1
apc.shm_size => 32M => 32M
apc.shm_strings_buffer => 4M => 4M
apc.slam_defense => On => On
apc.stat => On => On
apc.stat_ctime => Off => Off
apc.ttl => 0 => 0
apc.use_request_time => On => On
apc.user_entries_hint => 4096 => 4096
apc.user_ttl => 0 => 0
apc.write_lock => On => On

なぜかapcが有効になっているし、コンパイルオプションでも--enable-apcとか付いてる。ひとまずphp.ini

-apc.enabled=1
+apc.enabled=0

な感じでapcを無効にしたらnoticeはでなくなりました。

ところで、anyenvで入れたphpenvはよくあるCHH/phpenvではなくて、phpenv/phpenvが使われる。CHH/phpenvでphp5.5を使っていた時はこんなことはなかったので、phpenv/phpenv側の設定だろうとおもってgithubリポジトリを眺めていたら、↓あたりでそれっぽい感じのことをしていた。

https://github.com/phpenv/phpenv/blob/dev/etc/php-5.5.Darwin.source https://github.com/phpenv/phpenv/blob/dev/etc/ext/apc.ini

そもそもphp5.5でapcって動かせたっけ?APCuじゃなくて。