{"id":1077,"date":"2013-03-21T15:10:26","date_gmt":"2013-03-21T15:10:26","guid":{"rendered":"http:\/\/invisiblezero.net\/?p=571"},"modified":"2013-03-21T15:10:26","modified_gmt":"2013-03-21T15:10:26","slug":"compiling-latest-version-of-php-on-mac-os-x","status":"publish","type":"post","link":"http:\/\/ndthanh.com\/compiling-latest-version-of-php-on-mac-os-x\/","title":{"rendered":"Compiling latest version of PHP on Mac OS X"},"content":{"rendered":"

\"upgrade-banner\"<\/p>\n

Mac OSX has a lot of Unix utilities, they’re very useful. You can start using many of your favorite Unix\/Linux application out-of-the-box. But when it come to PHP, it’s not as good as PHP on Linux, What you have is an outdated version and you don’t have new features and performance of latest PHP .In this article, i’ll show you how to upgrade php on your Mac to latest version.<\/p>\n

<\/p>\n

To find out current version of PHP, use this command :<\/p>\n

\n$ php --version\n\nPHP 5.3.8 with Suhosin-Patch (cli) (built: Nov 15 2011 15:33:15)\n\nCopyright (c) 1997-2011 The PHP Group\n\nZend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies\n\n<\/pre>\n

To install PHP, you will need to install several other components like : libjpeg8d , libpng, freetype, openssl, libbcrypt.<\/p>\n

you can install it all with Brew<\/a> using these commands :<\/p>\n

\nbrew install libjpeg\nbrew install pcre\nbrew install libxml2\nbrew install mcrypt\nbrew install icu4c\nbrew link icu4c --force\nbrew install imap-uw\n<\/pre>\n

After that I configured PHP with the following options (apxs config apache to use this version of php, it’s importain):<\/p>\n

\n.\/configure  \\\n--prefix=\/usr  \\\n--mandir=\/usr\/share\/man  \\\n--infodir=\/usr\/share\/info  \\\n--sysconfdir=\/private\/etc  \\\n--with-apxs2=\/usr\/sbin\/apxs  \\\n--enable-cli  \\\n--with-config-file-path=\/etc  \\\n--with-libxml-dir=\/usr  \\\n--with-openssl=\/usr  \\\n--with-kerberos=\/usr  \\\n--with-zlib=\/usr  \\\n--enable-bcmath  \\\n--with-bz2=\/usr  \\\n--enable-calendar  \\\n--with-curl=\/usr  \\\n--enable-dba  \\\n--enable-exif  \\\n--enable-ftp  \\\n--with-gd  \\\n--enable-gd-native-ttf  \\\n--with-icu-dir=\/usr\/local\/opt\/icu4c  \\\n--with-iodbc=\/usr  \\\n--with-ldap=\/usr  \\\n--with-ldap-sasl=\/usr  \\\n--with-libedit=\/usr  \\\n--enable-mbstring  \\\n--enable-mbregex  \\\n--with-mysql=mysqlnd  \\\n--with-mysqli=mysqlnd  \\\n--without-pear  \\\n--with-pdo-mysql=mysqlnd  \\\n--with-mysql-sock=\/tmp\/mysql.sock  \\\n--with-readline=\/usr  \\\n--enable-pcntl \\\n--enable-shmop  \\\n--with-snmp=\/usr  \\\n--enable-soap  \\\n--enable-sockets  \\\n--enable-sysvmsg  \\\n--enable-sysvsem  \\\n--enable-sysvshm  \\\n--with-tidy  \\\n--enable-wddx  \\\n--with-xmlrpc  \\\n--with-iconv-dir=\/usr  \\\n--with-mcrypt \\\n--with-xsl=\/usr  \\\n--enable-zip  \\\n--with-imap=\/usr\/local\/imap-2007 \\\n--with-kerberos \\\n--with-imap-ssl \\\n--enable-intl \\\n--with-pcre-regex  \\\n--with-pgsql=\/usr  \\\n--with-pdo-pgsql=\/usr \\\n--with-freetype-dir=\/usr\/X11 \\\n--with-jpeg-dir=\/usr  \\\n--with-png-dir=\/usr\/X11\n<\/pre>\n

Followed by:<\/p>\n

\nmake\nmake test\n\n<\/pre>\n

Some tests may failed, but it’s ok we have nothing to do with it. Finally, you can install PHP with:<\/p>\n

\n\nsudo make install\n\n<\/pre>\n
\n

To install other modules like intl, check out pecl to install it. This is my quick guide for system that already has PHP installed.<\/p>\n

\n\ncd \/usr\/lib\/php\nsudo php install-pear-nozlib.phar\n\n<\/pre>\n

Edit\/etc\/php.ini and find the line: ;include_path = “.:\/php\/includes” and change it to:
\ninclude_path = “.:\/usr\/lib\/php\/pear”<\/p>\n

Then, execute following commands to update & add new channels<\/p>\n

\n\nsudo pear channel-update pear.php.net\nsudo pecl channel-update pecl.php.net\nsudo pear upgrade-all\nsudo pear channel-discover pear.phpunit.de\nsudo pear channel-discover components.ez.no\nsudo pear channel-discover pear.symfony-project.com\n\n<\/pre>\n

From this point, you can install many other PHP utilities as you wish<\/p>\n

\n\nsudo pear install phpunit\/PHPUnit\nsudo pear install phpunit\/phpcpd\nsudo pear install PHP_CodeSniffer\nsudo pecl install apc\nsudo pecl install intl\nsudo pecl install xdebug\n\n<\/pre>\n

note: remember to follow output instruction after install each module from pecl or pear from console screen.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"

Mac OSX has a lot of Unix utilities, they’re very useful. You can start using many of your favorite Unix\/Linux application out-of-the-box. But when it come to PHP, it’s not as good as PHP on Linux, What you have is an outdated version and you don’t have new features and performance of latest PHP .In…<\/p>\n

Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[86,46,53],"tags":[92,61,62],"aioseo_notices":[],"views":5,"_links":{"self":[{"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/posts\/1077"}],"collection":[{"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/comments?post=1077"}],"version-history":[{"count":0,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/posts\/1077\/revisions"}],"wp:attachment":[{"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/media?parent=1077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/categories?post=1077"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ndthanh.com\/wp-json\/wp\/v2\/tags?post=1077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}