Skip to content

Instantly share code, notes, and snippets.

@jamonholmgren
Last active April 4, 2021 07:37
Show Gist options
  • Save jamonholmgren/7238324 to your computer and use it in GitHub Desktop.
Save jamonholmgren/7238324 to your computer and use it in GitHub Desktop.
I installed Mac OS X Server to check it out. Problem was, it blew away my virtual host setup. Here's how I got them back.

OS X Server disables virtual host setup

I've been using the excellent VirtualHostX to set up my virtual hosts on OS X for a while now. It works great for setting up Apache virtual hosts and local domains.

A couple days ago, I decided to install OS X Server. When I enabled the web server portion, it seemingly disabled my virtual hosts and started showing its own page:

http://d.pr/i/loKD

Apparently, there's no easy way to uninstall OS X Server.

I called AppleCare and they transferred me to the enterprise Mac support line. The tech sent me to this page:

http://help.apple.com/advancedserveradmin/mac/10.8/#apd9eb9f4ab-1377-47e6-a2c4-1311e25a74df

OS X Server uses a different httpd.conf file

Using that document, I found the main configuration file.

sudo pico /Library/Server/web/config/apache2/httpd_server_app.conf

In that file, I found the following comment:

# When Server App is installed, this file is used instead of /etc/apache2/httpd.conf
# At Server.app promotion time this file is copied to 
# /Library/Server/Web/Config/apache2/httpd_server_app.conf and Apache's launchd.plist is 
# modified to use it as the main config file.

So, OS X Server changes the way OS X configures Apache and actually loads a completely different httpd.conf file. In fact, in my testing, this httpd.conf file is copied over every time you visit the Server panel.

Re-enabling virtual hosts

Luckily, it's a super easy fix.

1. Disable Websites in the Server panel

http://d.pr/i/ObmP

2. Edit two files; the default file (that gets copied over) and the actual file

sudo pico /Library/Server/web/config/apache2/httpd_server_app.conf.default
sudo pico /Library/Server/web/config/apache2/httpd_server_app.conf

Uncomment the line (line number 548 in my case) that looks like this:

# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

You might also have to uncomment PHP:

LoadModule php5_module libexec/apache2/libphp5.so

Make sure to do this to both files.

3. Restart your Apache server

You can do this in VirtualHostX or from the Terminal:

sudo apachectl -k restart

If you have any trouble with this, feel free to tweet me at @jamonholmgren.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment