A few different issues here all hiding under the concept of PHP version confusion, so will try to address each one as clearly as possible. First this:
I realized that there is a miss matching between the PHP version
php -v (in the CLI).
php -v: 5.6.9
PHP CLI is not the same as the PHP Apache module.
As I explain in the answer to this other question here, don’t panic! If you are concerned about what PHP version your Apache server is using, the output of
phpinfo() is always what you should pay attention to. The Apache PHP module and the PHP command line binary are two different things that don’t interfere with each other.
Just pay attention to the output of
phpinfo() if you are concerned about setting the correct PHP module version in Apache.
That said, you still seem to have issues getting the correct PHP module loaded in Apache:
I tried to write this line in my
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
Make sure your Apache server is loading the correct PHP module.
While what you did technically looks to be correct, the only reason I can see for this to not work is somehow there is another
LoadModule php5_module directive in the Apache config files that is superseding the value you are setting that line.
I would recommend looking through the
httpd.conf—which I assume is located here
/etc/apache2/httpd.conf—and see if perhaps there is indeed another
LoadModule php5_module that you missed or did not notice when editing that file. Looking at my equivalent file in Mac OS X 10.9.5 I see the line is commented out—since I don’t use Mac OS X Apache/PHP setups—and reads something like this:
#LoadModule php5_module libexec/apache2/libphp5.so
Of course in your case it would be uncommented. More details on configuring Apache and PHP for web development can be found on this site.
Seriously consider using MAMP as an alternative to Mac OS X Apache/PHP quirks.
Now all of that said, I don’t know what you are attempting to do, but if you are doing web development on a Mac OS X system you should seriously consider using MAMP instead of hacking the core Mac OS X web stack to get things running.
The benefit of MAMP is it’s an extremely production level Mac OS X equivalent of a LAMP stack. And since it’s geared towards real-world web development, it has all the modules and configs setup exactly as one should have them setup.
The core problem with Apache and PHP on Mac OS X is the software is typically out of date, a pain to configure/tweak and manage and a headache to debug when stuff like this happens. And what if a Mac OS X update comes along that wipes out your carefully setup Apache and PHP settings? You are back to square one.