How to customize mavericks’ mac osx server apache configuration

apache-2.2mac-osxmac-osx-server

I have installed Mac OSX Mavericks Server and I would like to add some features to the Apache Server (gitolite, redmine, etc.) I've started with updating the httpd_server_app.conf file in /Library/Server/Web/Config/apache2 but unfortunately it has been overwritten by the server to its default. Maybe because I've updated something in the UI, or an update occurred… Anyway, I would like to know how can I update the configuration file in a permanent and persistent way, and still benefit the OSX Server UI and/or updates…

I've probably missed the big : "Put your own things here:" label…

PS: By the way, I wish to modify some of the current configuration, not only adding things…

Best Answer

From the ReadMe.txt in that folder:

httpd_server_app.conf

This is the primary configuration file read by Apache. Note that it differs from the httpd.conf distributed with Apache. It is specific to Server's Apache configuration, and takes the place of the desktop Apache configuration in /etc/apache2/httpd.conf. Certain directives are activated when Websites Service is switched on in the Server application; these are bracketed by the "IfDefine WEBSERVICE_ON" blocks. This file is modified by the server-resident part of the Server application and, in some cases, by webappctl(8). Administrators may make changes directly to this file but it's generally safest to put your changes in separate files and use the Include directive to incorporate them.

I haven't tested this extensively, but the Apple admin tools seem to leave Include directives in this file alone. Another option is to put your settings in a file in /Library/Server/Web/Config/apache2/other/, since the master file Includes everything in that directory automatically. Also, if you need to add settings only to specific virtual sites, you can add Include directives to the files in /Library/Server/Web/Config/apache2/sites/ and the admin tools seem to leave them alone.

Changing settings (rather than just adding) is trickier; I don't know of a general "safe" way to do this, so you'd have to take them on a case-by-case basis. There are probably some things you can't safely change. This is one of the reasons I can't really recommend using OS X Server as a general-purpose web server: it's configuration is extensively modified to support the various web-based services OS X Server provides (profile manager, wiki, webcal, webDAV file sharing, etc) and if you're trying to make extensive modifications of your own... the probability that you and Apple's configs will trip over each other gets unpleasantly high. OS X Server is good for running the built-in web-based services, but I'd use something else if you're going much beyond what's built in.

BTW, a quick note about the rather nonstandard location of apache files in OS X Server: there are at least three apache2 directories full of config files:

  • /Library/Server/Web/Config/apache2/* -- this is the live config for the OS X Server version of apache.
  • /Applications/Server.app/Contents/ServerRoot/etc/apache2/* (actually symlinked to .../ServerRoot/private/etc/...) -- These are used as a template when OS X Server is first set up.
  • /etc/apache2/* (actually /private/etc, but it's symlinked) -- These files are used by the default (non-Server) version of apache that comes with OS X, but is ignored when the Server version of apache is used.