If you have another version installed in the Brew's Cellar directory, make sure to brew unlink php
it and possibly also delete the version folder.
Then, simply download the latest version of PHP source and run the configure command below, then continue as usual with make && make install
. Afterwards, activate the installation by brew link php
.
Note: You will need to install any pecl extensions (like xdebug) again after this procedure.
Nope - I do not use PHP with Apache. If you require this add relevant configuration to the configure
command below as needed.
If you wish to use the openssl version provided by OS X (which is outdated, mind you!) simply remove the path from the command below.
brew install \
gettext \
libedit \
mcrypt \
openssl
The command in the prefix
extracts the current PHP version from the NEWS file and uses it as a subdirectory of the installation (as Brew expects).
./configure \
--prefix=/usr/local/Cellar/php/$(head -n 3 NEWS | tail -n 1 | tr " " "\n" | tail -n 1) \
--with-config-file-path=/usr/local/etc \
--enable-cli \
--enable-exif \
--enable-maintainer-zts \
--enable-mbregex \
--enable-mbstring \
--enable-pcntl \
--enable-zip \
--with-bz2=shared \
--with-curl=shared \
--with-gettext=shared,/usr/local/opt/gettext \
--with-kerberos=shared \
--with-ldap-sasl \
--with-ldap=shared \
--with-libedit=shared,/usr/local/opt/libedit \
--with-mcrypt=shared,/usr/local/opt/mcrypt \
--with-mysqli=mysqlnd \
--with-openssl=shared,/usr/local/opt/openssl \
--with-pdo-mysql=mysqlnd \
--with-snmp=shared \
--with-tidy=shared \
--with-xsl=shared \
--with-zlib=shared
You can generate a list of installed PHP extensions using this command:
find `php-config --extension-dir` -name "*.so" | sed 's!^.*/!extension=!'
The first part is simply a find
within the PHP extensions directory. Because find
prints the full path to the found files to output, the second part removes the path to the extensions directory from it and replaces it with extension=, so it can be copy/pasted directly into php.ini:
extension=module_name.so
...
Make sure you have PHP and its extensions configured properly before installing Composer.
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer