Skip to main content

Installing PHP 7 on OS X Yosemite

Yesterday was the release of PHP7.0.0 and I wanted to have it on my mac as fast as possible. Since I'm still using Mac OS X Yosemite I will post here the steps to upgrade my platform, it might be useful for you too.


Since Apple is doing a great job to provide PHP, Apache and MySQL straight out of the box, I'm not worrying about the Apache and MySQL.

In order to to install PHP from source, you need to have XCode installed as it provides required libraries and headers that you will need to have a successful experience.
Of course, get the latest and greatest PHP7.0.0 bundle straight from Don't forget to verify the signatures before you get started unpacking the sources.

Time to bake the sources

I like to build my apps from sources, even though there are package managers that will do it in a single command. There are really some great benefits from building from sources:

  • You can switch on and off modules as you go
  • You can now choose how you want to run PHP (as module, cgi or fpm)
  • You can enable extra debugging and profiling features
  • And my favorite: you can automate it
When you've unpacked the bundle (let's say its in /tmp) go into the directory /tmp/php-7.0.0. Here you will find your master command configure that you will need to set up your PHP installation. When you're requiring to know what options you can use, configure --help|less is your friend.

For my own convenience, I've created a little tool that helps me to configure any version of PHP as it sets the bare minimum I need to achieve a running PHP platform.



if [ -t $PHP ]; then
  echo "Usage: $0 "
  echo "  prefix    A prefix for your installation you would like to use"
  echo "            e.g. 'php7', 'php56'"
  exit 0


./configure \
--prefix=/opt/${PHP} \
--enable-cli \
--with-apxs2 \
--with-iconv=${LIB_PATH} \
--with-config-file-path=/etc/${PHP} \
--with-config-file-scan-dir=/Library/Server/Web/Config/php \
--with-libxml-dir=${XCODE_PATH} \
--with-openssl=/usr \
--with-mysqli \
--with-pdo-mysql \

I made this script ( executable with chmod +x All that's required is to pick a great prefix (where you want php to be installed) and with ./ /opt/php7 you start configuring PHP.

Once your process is completed (and you don't get errors), it's time to run makemake test and make install.

Let's check it out

Now it's time to check if we have a working PHP. Let's find out with /opt/php7/bin/php -v and you should be getting something like this.

In a next article I will explain hot to add xdebug and have PHP7 run as an Apache module in the existing Mac OS environment. Until then.


Popular posts from this blog

Speeding up database calls with PDO and iterators

When you review lots of code, you often wonder why things were written the way they were. Especially when making expensive calls to a database, I still see things that could and should be improved.
No framework development When working with a framework, mostly these database calls are optimized for the developer and abstract the complex logic to improve and optimize the retrieval and usage of data. But then developers need to build something without a framework and end up using the basics of PHP in a sub-optimal way.

$pdo = new \PDO( $config['db']['dsn'], $config['db']['username'], $config['db']['password'] ); $sql = 'SELECT * FROM `gen_contact` ORDER BY `contact_modified` DESC'; $stmt = $pdo->prepare($sql); $stmt->execute(); $data = $stmt->fetchAll(\PDO::FETCH_OBJ); echo 'Getting the contacts that changed the last 3 months' . PHP_EOL; foreach ($data as $row) { $dt = new \DateTime('2015-04-…

PHP Arrays - Associative Arrays or Hash Maps

Associative array or hash maps are listings of key and value pairs with a posibility to nest additional keys and values. An associative array is a very powerful construct within PHP.

In our previous article we discussed simple arrays, which in their turn are indexed associative arrays under the hood. Take the following example:

$array = [

Is in fact an indexed associative array under the hood:

$array = [
0 => 'apple',
1 => 'banana',
2 => 'chocolate',

But associative arrays can be so much more than just an indexed array, and you will find many database operations returning arrays where the fields of a table are the keys in the array while their values are also the values within the array.

$productRowData = [
'product_id' => 1234,
'brand_id' => 321,
'product_name' => 'Our awesome product',
'prodcut_description' => 'This is our most awesome product.&#…

Deploy Docker containers fast to Microsoft Azure

DEPLOY DOCKER CONTAINERS FAST TO MICROSOFT AZURE It’s hard to ignore the fact thatDockeris a way to move forward for rapid application development, distributed architectures and microservices. For developersDockeroffers great advantages as they can build their containers specifically for the task they work on. They grab a base image of a container, modify it for their purpose and prepare the functionality inside the container. Quality, testing and security teams now have a single instance to look at and ensure all functional and regulatory requirements are met. System engineers now don’t have to worry about providing a system with the required specs as the container is already provisioned for that purpose. But where do you deploy yourDockercontainers? You can set up your existing bare metal infrastructure to allow them to run containers, but this also means you need to learn about securing your container infrastructure, which is not an easy task. Luckily “the cloud” offers container …