Mac OSX (10.8) Mountain Lion: Fixing Apache, PHP, Subversion, User Sites, Virtual Hosts Directories

While Mountain Lion (OSX 10.8) has brought many enhancements and fixes (mostly performance), it has also caused frustration to old users.

You might have noticed following issues in Mountain Lion:

  1. Web Sharing Preferences Panel has been removed, i.e. you need to launch apache manually or write some launch-agent script or hack to bring web-sharing preferences panel back
  2. User Sites (per-user web directories) is disabled, i.e. http://localhost/~username doesn't work by default, and you need to modify apache config file to enable it
  3. PHP extension for Apache is disabled by default i.e. you need to enable it by modified apache config (httpd.conf)
  4. Subversion is not installed by default, either you can install using homebrew or by install XCode command line tools

You can fix these issues (1-4) by following these two links:

Whenever I upgrade to newer version of OSX, I end up with broken development-setup i.e. custom permissions on directories are messed up, configuration files are overwritten/removed, etc.

I think, I have found a way to keep default directory permissions, so future upgrades don't break things.

My development setup requires my virtual hosts to use directories within my home-directory (and outside of ~/Sites or /Library/WebServer/Documents directories).

I am using following technique to setup my virtual-hosts:

In my case, I have a project inside ~/projects/myproject . I create a symlink of this directory inside ~/Sites, like this using Terminal (command-prompt)

$ ln -s ~/projects/myproject ~/Sites/myproject

I have following virtual-host configuration for this project:

<VirtualHost *:80>
 DocumentRoot "/Users/myusername/Sites/myproject/trunk/web"
 ServerName  myproject
 ServerAdmin myusername@localhost
 Options Indexes MultiViews Includes +FollowSymlinks +SymLinksIfOwnerMatch
 CustomLog "/private/var/log/apache2/myproject_access.log" common
 ErrorLog "/private/var/log/apache2/myproject_error.log"
</VirtualHost>

I use it on my development machine (i.e. my laptop), so I don't really bother about security at Apache level, and I take care of security at firewall/other levels.

If you are going to use above technique/configuration, please understand everything (by reading documentation) before you use it.

This set up works for me and solves some problems for me - I don't have to change default directory permissions, and I don't have to keep my projects within ~/Sites or /Library/WebServer/Documents directory.