Getting to know your PHP environment on Mac OS X

When running an Apache, MySQL and PHP environment on your Mac for local development, it’s good to know how to get some basic information about your PHP setup via the command line – especially if you have used several PHP versions over the time, which you may have installed in different ways (e.g. when you first used MAMP before switching to the PHP installation coming with OS X), as this again may lead to several PHP installations running at the same time as well as to several php.ini files flying around in your system.

The possible outcome: confusion when it comes to determining which PHP version is used by the Apache web server and which one by the CLI (what may differ) and which php.ini file is the right one to change.

While getting the PHP version used by your Apache via phpinfo(); should be well known, there are also some simple commands available to get you the needed information for your CLI:

How to get the path to your PHP installation used by CLI? On command line execute:

The output may look similar to:

But this may not help you very much in the first place. How about the PHP version also? Execute:

Which will output something like:

Ok, nice. But where is the corresponding php.ini file? Execute:

Output should look like:

So, here we go. Either locate and edit the php.ini in Finder or just do it on the command line:


1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">