macでPHP開発環境構築 完結編

やっとこさ、実用レベルのPHPが入れられそうなので。

ここまでの経緯は、macでPHP開発環境の構築macでPHP環境構築の続き。を参照。

2013/4/3段階の最新版のPHPは5.4.13と5.3.23。
php-buildには記述がないバージョンなので、それぞれ記述する。

/usr/local/share/php-build/definitions/5.4.13

install_package “http://php.net/distributions/php-5.4.13.tar.bz2”
install_pyrus
install_xdebug_master

/usr/local/share/php-build/definitions/5.3.23

install_package “http://php.net/distributions/php-5.3.23.tar.bz2”
install_pyrus
install_xdebug_master

こんな感じ。
いずれはここからPHP5.1.6と5.2.17も入れたいが、とりあえず今は5.3系と5.4系だけで。

さて、ここで少し脱線。
EC-CUBEを入れる前提でやっているのだが、このまま入れるとPHPからfreetype2が使えない。
freetype2自体はXCodeにも入ってるみたいだけど、何か変更があると嫌なのでHomebrewで入れて、
そこにパスを通してPHPのconfigureを構築しようと思う。

XCodeで入れるって人はここを省略して下へ…。

freetype2をHomebrewで入れる方法はこちらを参照。

/usr/local/Library/Formula/freetype2.rb

require 'formula'

class Freetype2 <Formula
  url 'http://sourceforge.net/projects/freetype/files/freetype2/2.4.4/freetype-2.4.4.tar.gz/download'
  homepage 'http://freetype.sourceforge.net/index2.html'
  md5 '9273efacffb683483e58a9e113efae9f'
  version '2.4.4'

  # depends_on 'cmake'

  def install
    system "./configure", "--disable-debug", "--disable-dependency-tracking",
                          "--prefix=#{prefix}"
    # system "cmake . #{std_cmake_parameters}"
    system "make install"
  end
end

上記を設置してから、

brew install freetype2

で完了。
次はPHPのconfigureを書きます。

/usr/local/share/php-build/default_configure_options

–without-pear
–with-gd
–enable-sockets
–with-jpeg-dir=/usr
–with-png-dir=/usr
–enable-exif
–enable-zip
–with-zlib
–with-zlib-dir=/usr
–with-kerberos
–with-openssl
–with-mcrypt=/usr
–enable-soap
–enable-xmlreader
–with-xsl
–enable-ftp
–enable-cgi
–with-curl=/usr
–with-tidy
–with-xmlrpc
–enable-sysvsem
–enable-sysvshm
–enable-shmop
–with-mysql=mysqlnd
–with-mysqli=mysqlnd
–with-pdo-mysql=mysqlnd
–with-pdo-sqlite
–enable-pcntl
–with-readline
–enable-mbstring
–disable-debug
–with-apxs2=/usr/local/sbin/apxs
–with-freetype-dir=/usr/local/include/freetype2

うちの場合はこんな感じ。
freetype2をXCodeのものを使う場合は、最終行が

–with-freetype-dir=/opt/X11/include/freetype2

って感じになるのではないかと。

実際に追記したのは下の2行だけなので、他は必要があれば書き換える感じですかね。

ではインストール。
PHP5.4.13から。

php-build 5.4.13 ~/.phpenv/versions/5.4.13
mv /usr/local/Cellar/httpd/2.2.23/libexec/libphp5.so ~/.phpenv/versions/5.4.13

これでOK。
続いてPHP5.3.23。

php-build 5.3.23 ~/.phpenv/versions/5.3.23
mv /usr/local/Cellar/httpd/2.2.23/libexec/libphp5.so ~/.phpenv/versions/5.3.23

これでOK。
phpenv versionsでちゃんと入ってるか確認して、
phpenv global 5.4.13とかやってCLI側を切り替えて、
php -vでCLI側のバージョン切り替わるか確認して、
phpenv apache-version 5.4.13とかやってapache側を切り替えて、
phpinfo.phpとか作ってapache側のバージョン切り替わるか確認して。

…確認作業についてはサラっと流しました。
細かい確認としては、phpinfoを見る時にGD内のFreeType Support欄があるかどうか、ですかね。

やっとここまで来ました…。
apacheの設定とかも必要ですが、とりあえずPHPに関しては相当カスタマイズできる環境ができたので
うれしい限りです。

なにせ、同じPHPのバージョンでもconfigure optionを変えた版、とかも作って置いておけますしね。
phpenv + php-build、最高です。

  1. コメントはまだありません。

  1. トラックバックはまだありません。