Reconfiguring Apache and PHP after Mac OS Upgrade

If you've just upgraded to a more recent Mac OS release, then you'll find this post handy as it will walk you through some of the configurations required.

Configure Apache configs

  1. Edit the Apache config file
    sudo vi /etc/apache2/httpd.conf
  2. Update DocumentRoot
    # DocumentRoot "/Library/WebServer/Documents"
    DocumentRoot "/Users/yourUserName/Sites"
  3. Update Directory settings using the new document root
    Note: Also ensure "AllowOverride" is to "All" to allow .htaccess files to override httpd config settings.
    <Directory "/Users/yourUserName/Sites">...</Directory>
  4. Enable Virtual Hosts
    # Virtual hosts
    Include /private/etc/apache2/extra/httpd-vhosts.conf
  5. Load virtual host module
    LoadModule vhost_alias_module libexec/apache2/
  6. Set user and group
    You can find out current user/group setting by typing "id" in terminal.
    #User admin
    #Group staff
    User yourUserName
    Group yourUserGroup
  7. Uncomment PHP and rewrite modules
    #LoadModule rewrite_module libexec/apache2/
    #LoadModule php5_module libexec/apache2/
    LoadModule rewrite_module libexec/apache2/
    LoadModule php5_module libexec/apache2/
  8. Add index.php to the DirectoryIndex
    <IfModule dir_module>
        DirectoryIndex index.html index.php
  9. Restart Apache
    sudo apachectl restart

Configure PHP

  1. Copy default settings
    sudo cp /private/etc/php.ini.default /private/etc/php.ini
  2. Set timezone
    Failing to set timezone may throw out the error message "It is not safe to rely on the system's timezone settings".
    See full list of supported PHP timezones.
    ; date.timezone =
    date.timezone = Pacific/Auckland
  3. Restart Apache
    sudo apachectl restart