Install and setup PHP 7 in macOS High Sierra

1. Install PHP in macOS High Sierra

To install php in macOS High Sierra, execute the given below command in the terminal of macOS. We are using Homebrew, an opensource package manager for macOS, to install PHP7.

$brew install php

2. Edit the file /etc/apache2/httpd.conf

LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so

<FilesMatch .php$>
    SetHandler application/x-httpd-php
</FilesMatch>

3. Check DirectoryIndex of the file /etc/apache2/httpd.conf includes index.php

    DirectoryIndex index.php index.html

3. Restart Apache Service

To restart apache service, execute the given below command in macOS terminal.

$sudo apachectl restart

4. The php.ini and php-fpm.ini file can be found in /usr/local/etc/php/7.2/

5. To have launchd start php now and restart at login:

Execute the given below command in macOS terminal.

  $brew services start php

6. If you don’t want/need a background service you can just run:

  $php-fpm

Comments on this post

No comments.

Leave a Reply

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

Trackbacks and Pinbacks on this post

No trackbacks.

TrackBack URL