PHP code is not being executed in Apache2

PHP code is not being executed, instead code shows on the page

I have a new MacBook from my company. It was new installation without any applications but Mac default apps. So, I need to setup my working environment fo Laravel based web developer. The first thing that I must install is apache with this command

brew install apache2

After installed I make index.php test file in my DocumentRoot like this

<?php
echo "Hi! this is index.php in ~/Sites";

When I open http://localhost my index.php code not being executed, instead code shows on the web browser. I solve this problem with uncomment LoadModule php7_module.so in /etc/apache2/httpd.conf then restart the apache with this command

sudo apachectl restart

Finally, I solved my problem and ready to work! Enjoy…

Leave a Comment