General Configuration

In order to enable php support in OSX 10.5, find apache config file under /etc/apache2/ and open it by editor such as vi. Uncomment following lines:

LoadModule php5_module libexec/apache2/libphp5.so // TO ENABLE PHP
Include /private/etc/apache2/extra/httpd-vhosts.conf // VIRTUAL HOSTS

Then, in /private/etc/php.ini uncomment:

Default Value: E_ALL // under ; error_reporing

Restart apache!

Virtual Hosts and SEO-friendly links

To enable seo-friendly links support, under /etc/apache2/users/ you will find [your_username].conf file; make sure AllowOverride is set to ALL as following:

Options All
AllowOverride All

To add a new virtual host; firstly make sure etc/apache2/users/[your_username].conf contains following lines

<VirtualHost *:80>
DocumentRoot /Users/[your_username]/Sites
ServerName localhost
</VirtualHost>

For every virtual host you create, you must add virtual host info into your [your_username].conf file:

<VirtualHost *:80>
DocumentRoot /Users/[your_username]/Sites/website1
// FOLDER WITH WEBSITE FILES

ServerName website1.local // Local URL - can be pretty much anything
</VirtualHost>

you also need to add

127.0.0.1 website1.local

into /private/etc/hosts. After restarting apache, you should be able to access the website by requesting website1.local in your browser.

Tagged: configuration  development  development environment  mac  mac development  macbook  OSX  web programming