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
#or
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
</FilesMatch>
#change Listen 8080 to Listen 80
Listen 80
#set Server name to be localhost
ServerName localhost
#Uncomment:
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
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
</Directory>
</VirtualHost>
Step 4 – Install and configure xdebug
#run
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:
[Xdebug]
zend_extension="xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
#Test php and apache
echo "<?php phpinfo()" > ~/Sites/index.php
#restart apache
sudo apachectl -k restart
#validate apache service i working with http://localhost