PHP 7 - Installation on Mac OS X


Advertisements

Mac users have a choice of either a binary or a source installation. In fact, your OS X probably came with Apache and PHP preinstalled. This is likely to be quite an old build, and it probably lacks many of the less common extensions.

However, if all you want is a quick Apache + PHP + MySQL/PostgreSQL setup on your laptop, this is certainly the easiest way to fly. All you need to do is edit your Apache configuration file and turn on the Web server.

Just follow the steps given below −

Step 1

Open the Apache config file in a text editor as root.

sudo open -a TextEdit /etc/httpd/httpd.conf

Step 2

Edit the file. Uncomment the following lines −

Load Module php7_module
AddModule mod_php7.c
AddType application/x-httpd-php .php

Step 3

You may also want to uncomment the <Directory /home/*/Sites> block or otherwise tell Apache which directory to serve. Restart the Web server.

sudo apachectl graceful

Step 4

Open a text editor. Type: <?php phpinfo(); ?>. Save this file in your Web server's document root as info.php. Start any Web browser and browse the file. You must always use an HTTP request (http://www.testdomain.com/info.php or http://localhost/info.php or http://127.0.0.1/info.php) rather than a filename (/home/httpd/info.php) for the file to be parsed correctly

You will see a long table of information about your new PHP installation message Congratulations!

php7_environment.htm
Advertisements