Making built in apache server work in OS X

Steps to make the version of apache that comes pre installed with os x work with vhosts and php.

1) apachectl -V shows where config file is located.

2) sudo vim <path-to-config>

3) uncoment # Virtual hosts include path

edit: In Yosemite remove this line: Require all denied. Also uncomment mod_rewrite;

4) Open that path, copy example and fill required data

5) From main config copy <Directry> settings to the httpd-vhosts.conf file and change directory path. To use .htaccess change AllowOverride All.

6) To enable php uncomment LoadModule php5_module

7) sudo apachectl restart

Update Oct 9 2015

After installing new version of OS X El Capitan, my main config file is overwritten. Fortunatelly, vhosts files are still there.

To make built in PHP work you need to uncoment LoadModule php5_module libexec/apache2/libphp5.so line.

To install other version of php with brew go to [homebrew instruction page](brew tap homebrew/homebrew-php) and read from there.

After successful install, brew will provide usefull info on how to include just installed version to apache.

To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php5_module    /usr/local/opt/php56/libexec/apache2/libphp5.so

The php.ini file can be found in:
    /usr/local/etc/php/5.6/php.ini

...

Of course in the end do sudo apachectl restart

Author

I plan to write more articles about common laravel components. If you are interested let’s stay in touch.
comments powered by Disqus