macのphpを入れなおしたら クソハマった話

自宅のmacでもZend_dbを使うため、pdoとか必要になったから
元々入ってるのだと駄目みたいなので、ビルドし直す。

元々

 '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--disable-dependency-tracking' '--with-apxs2=/usr/sbin/apxs' '--with-ldap=/usr' '--with-kerberos=/usr' '--enable-cli' '--with-zlib-dir=/usr' '--enable-trans-sid' '--with-xml' '--enable-exif' '--enable-ftp' '--enable-mbstring' '--enable-mbregex' '--enable-dbx' '--enable-sockets' '--with-iodbc=/usr' '--with-curl=/usr' '--with-config-file-path=/etc' '--sysconfdir=/private/etc' '--with-mysql-sock=/var/mysql' '--with-mysqli=/usr/bin/mysql_config' '--with-mysql=/usr' '--with-openssl' '--with-xmlrpc' '--with-xsl=/usr' '--without-pear'

新しいコンパイルオプション

--prefix=/opt/php526 \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--disable-dependency-tracking \
--with-apxs2=/usr/sbin/apxs \
--with-ldap=/usr \
--with-kerberos=/usr  \
--enable-cli \
--with-zlib-dir=/usr \
--enable-trans-sid \
--with-xml \
--enable-exif \
--enable-ftp \
--enable-zend-multibyte \
--enable-mbstring \
--enable-mbregex \
--enable-dbx \
--enable-sockets \
--with-iodbc=/usr \
--with-curl=/usr \
--with-config-file-path=/etc \
--sysconfdir=/private/etc \
--with-openssl \
--with-xmlrpc \
--with-xsl=/usr \
--with-mcrypt=/opt/local \
--with-zlib \
--with-gd=/opt/local \
--with-jpeg-dir=/opt/local  \
--with-png-dir=/opt/local  \
--with-freetype-dir=/opt/local \
--with-tidy \
--with-pgsql=/opt/local/lib/postgresql83 \
--with-pdo-pgsql=/opt/local/lib/postgresql83 \
--with-mysqli=/opt/local/lib/mysql5/bin/mysql_config \
--with-pdo-mysql=/opt/local/lib/mysql5 \
--with-pear

怒られる

Notice: Following unknown configure options were used:

--disable-dependency-tracking
--enable-trans-sid
--with-xml
--enable-dbx

なので外す。

make

こける

Undefined symbols:
  "_EVP_CIPHER_CTX_block_size", referenced from:
      _zif_openssl_seal in openssl.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [libs/libphp5.bundle] Error 1

opensslがどーだの言ってる
多分この辺の問題。
32と64が混在してるから?
openssl が有効にならない その2(とりあえず解決) - Memo

とりあえず、使わないので外す

make

こける

Undefined symbols:
  "_iconv_close", referenced from:
      _php_iconv_string in iconv.o
      _php_iconv_string in iconv.o
      __php_iconv_strlen in iconv.o
      __php_iconv_strpos in iconv.o
      __php_iconv_mime_decode in iconv.o
      __php_iconv_mime_decode in iconv.o
      __php_iconv_mime_decode in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_substr in iconv.o
      _php_iconv_stream_filter_dtor in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _zif_iconv_mime_encode in iconv.o
  "_iconv_open", referenced from:
      _php_iconv_string in iconv.o
      __php_iconv_strlen in iconv.o
      __php_iconv_strpos in iconv.o
      __php_iconv_mime_decode in iconv.o
      __php_iconv_mime_decode in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _php_iconv_stream_filter_factory_create in iconv.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1

iconvがどーだのいわれる。
http://d.hatena.ne.jp/hetima/20071028/1193576377
を参考に

%s/iconv_open/libiconv_open/gc

に直した

make

通った

Build complete.
Don't forget to run 'make test'.

sudo make install

入った
/opt/php526/binにphpがない
php.dSYSがそれということなのでリンクはる,
/usr/bin/phpにもリンク貼る。

apache起動

起動しない。。


$ sudo apachectl configtest

httpd: Syntax error on line 114 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/libphp5.so into server: dlopen(/usr/libexec/apache2/libphp5.so, 10): no suitable image found.  Did find:\n\t/usr/libexec/apache2/libphp5.so: mach-o, but wrong architecture

たぶんこれが原因
http://www.goodfeelin.net/2008/06/mac_os_x_105_php5.php
を参考に

$ cd /usr/sbin
$ sudo cp httpd httpd.FAT
$ sudo lipo httpd -thin i386 -output httpd

apache再起動

再起動した。
phpinfo();
もオK

とりあえず、大丈夫と思う。