Step 1 : Stop the existing apache service and install Apache thru Brew.
$ sudo apachectl stop
$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
$ brew install httpd24 --with-privileged-ports --with-http2
This step takes a little while as it builds Apache from source. Upon completion you should see a message like:
/usr/local/Cellar/httpd24/2.4.23_2: 212 files, 4.4M, built in 1 minute 60 seconds
Step 2 : This is important because you will need that path in the next step.
$ sudo cp -v /usr/local/Cellar/httpd24/2.4.23_2/homebrew.mxcl.httpd24.plist /Library/LaunchDaemons
$ sudo chown -v root:wheel /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
$ sudo chmod -v 644 /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
Now we have installed Homebrew's Apache, and configured it to auto-start with a privileged account.
Server can be reached http://localhost
Step 3 : Apache Configuration
Configuration file Path
if you want to change the configuration , you should make it here
Note : we should now enable mod_rewrite which is commented out by default.
LoadModule rewrite_module libexec/mod_rewrite.so
For Magento installation mod_rewrite should be enable in this configuration file.
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
Step 4 : PHP installation
we can get a full list of available options to include by typing
$ brew install php71 --with-httpd24
We can choose which version we are going to use.
For configure the tweak configuration setting of PHP for our needs for example , memory_limit, date.timezone, display_errors...etc/apache2/2
Step 5 : Apache PHP Setup
Now we have successfully installed your PHP versions, but we need to tell Apache to use them . we need to edit apache configuration file
by modifying the php path.
LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so
Handle the php requests in apache by the following configuration needs to be modified
DirectoryIndex index.php index.html
Save the configuration file and restart the apache.
$ sudo apachectl -k restart
Step 6 : Validating PHP
create an php file info.php in document root directory
Content of info.php is
<?php phpinfo(); ?>
Step 6 : Check the dependency extension of PHP for Magento in php.ini file.
Required PHP extensions for Magento2:
gd, ImageMagick 6.3.7 (or later) or both
PHP 7 only:
Then you can proceed with Magento installation.