How to install Httpd, PHP 7.1 and configure Xdebug on Mac Os 10.13

Step 1 – Install Apache (httpd)

sudo apachectl stop
brew install httpd
brew services start httpd

Step 2 – Install php 7.1 and pecl

brew install php@7.1 --with-httpd --with-pear 
brew reinstall php@7.1 --with-httpd --with-pear

Step 3 – Configure httpd 

#open file
sudo vim /usr/local/etc/httpd/httpd.conf

#add index.php to DirectoryIndex index.html
DirectoryIndex index.html index.php

#Add /usr/local/etc/httpd/httpd.conf
<FilesMatch \.php$>
    SetHandler application/x-httpd-php

#change Listen 8080 to Listen 80
Listen 80

#set Server name to be localhost
ServerName localhost

LoadModule rewrite_module lib/httpd/modules/
Include /usr/local/etc/httpd/extra/httpd-vhosts.conf

Add localhost directory

mkdir /Users/yourname/Sites
mkdir /Users/yourname/Sites/logs

#Configure and add:
vim /usr/local/etc/httpd/extra/httpd-vhosts.conf

<VirtualHost *:80>
        ServerName localhost
        DocumentRoot /Users/yourname/Sites
        ErrorLog /Users/yourname/Sites/logs/localhost.log
        CustomLog /Users/yourname/Sites/logs/localhost-custom.log common
        <Directory  "/Users/yourname/Sites">
               Options +Indexes +FollowSymLinks +MultiViews
                AllowOverride All
            Allow from All

Step 4 – Install and configure xdebug

pecl install xdebug

Step 5 – Configure Xdebug in php.ini

vim /usr/local/etc/php/7.1/php.ini

#add at the end of the file:


#Test php and apache

echo "<?php phpinfo()" > ~/Sites/index.php

#restart apache                  
sudo apachectl -k restart
#validate apache service i working with http://localhost

Xdebug Php Extension
Xdebug Php Extension

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.