Code by Kevin

About
Code by Kevin, Programming, code, business, and other pursuits

Your Host
Kevin Walzer, software developer.



Home

Subscribe to RSS Feed
Get a syndicated feed of my weblog.

Archives
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011
2010
2009
2008
2007
2006

Categories
Business
Software
General

Privacy Policy

Site design: Skeleton

 

Mon, 05 Dec 2011

Upgrading to Lion Server and configuring websites

While I use some outside providers for Internet services, specifically Amazon S3 for hosting demo versions of my applications, I prefer to keep most of my Internet services in-house; the flexibility and cost-reduction that such a setup offers make the trade-off in administrative time worth it. For this purpose, I have always relied on the server version of OS X for web hosting, mail serving, and related services. It provided a robust platform, and required an investment of time to master, but was worth it.

The new version of Lion server is significantly different from earlier versions of OS X Server. Rather than being a separate build of OS X that's optimized for being a server (with a $500 price tag to match), it's a $50 download from the Mac App Store called Server.app. Apple is promoting Server.app as "The Server for Everyone." That initially caught my eye, but this lower price also comes as a significantly simplified version of the previous server OS: it removes a great deal of functionality that previously existed in the server OS.

For my purposes, the biggest difference (read loss) is the ability to comprehensively configure the Apache web server from a GUI. Older versions of OS X Server allowed you to define domain names and customize the configuration of each domain, all from a single interface. It put the power of Apache configuration at your fingertips without requiring you to hand-hack configuration files, with their arcane syntax. By contrast, Server.app on Lion allows you to define multiple websites, set one or two options, and turn them on from the GUI--that's about it.

For someone who uses the server to host a dozen websites, this is a serious issue. It's one that other reviews have noted as well. It means that if I want to provide advanced configuration of my websites, I have to hand-edit configuration files, much as if I were managing the Apache web server on a Linux or Unix system. Additionally, Apple provides little documentation on how to do this in such a way that won't cause problems with Apache. (To clarify: I am certainly capable of hand-editing Apache configuration files, but previous versions of OS X Server discouraged this because Apple's version of Apache had many Apple-specific customizations that could be best managed from the GUI; manual changes to the config files could be overwritten by the GUI or, even worse, break Apache.)

After a lot of trial and error, I finally worked out a process to configure my sites so that they would support the customizations I wanted (CGI execution, domain alias, and files with *.htm suffixes ). Here it is, with the "Code by Kevin" site as a demonstration:

  • Configure the website in Server.app as provided by the GUI. This will create a basic configuration file to work with.

  • Close down Server.app and, to make sure the web server isn't running, run this command in Terminal: sudo serveradmin stop web

  • Open /etc/apache2/sites using Finder's "Go to folder" menu item.

  • Locate a file named "000_any_80_www.codebykevin.com.conf" in the directory.

  • Edit the file to "+ExecCGI" as a supported option, add "index.htm" as a supported name in DirectoryIndex, and add ServerAlias and AddHandler keys. Editing the file may require you to use a text editor that supports elevated privileges, like TextWrangler, or in the Terminal running under "sudo" (nano or vi). My file looks something like the text below:

    <VirtualHost *:80> ServerName www.codebykevin.com ServerAdmin admin@example.com DocumentRoot "/Users/kevin/Sites/codebykevin" DirectoryIndex index.html index.php /wiki/ default.html index.htm CustomLog "/var/log/apache2/access_log" combinedvhost ErrorLog "/var/log/apache2/error_log" <IfModule mod_ssl.c> SSLEngine Off SSLCipherSuite "ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM" SSLProtocol -ALL +SSLv3 +TLSv1 SSLProxyEngine On SSLProxyProtocol -ALL +SSLv3 +TLSv1 </IfModule> <Directory "/Users/kevin/Sites/codebykevin"> Options All +MultiViews +ExecCGI -Indexes AllowOverride None <IfModule mod_dav.c> DAV Off </IfModule> </Directory> ServerAlias codebykevin.com AddHandler cgi-script .cgi </VirtualHost>

  • Save the file. Then run this command in Terminal: sudo serveradmin start web

    Re-start Server.app. It should read the updated configuration files.

    This approach is mostly undocumented by Apple, and I have not seen it documented in its entirety elsewhere on the Web either. Part of my purpose in documenting this here is to assist anyone else who might be frustrated by the limited functionality of the GUI tools in Lion Server for Apache configuration. (It's a mystery to me why Apple removed this functionality. The other hugely complex configuration that I deal with in the server, mail configuration, can still be managed from the GUI tools in Lion Server; the workflow is a bit different, with the advanced options removed from Server.app and placed in another program (Server Admin), but it's all still there, one way or another.)

    I am certainly please to see the reduced financial cost of server support in Lion, but especially with web configuration, Lion Server incurs other costs. I don't want to discourage anyone from buying Lion Server, but you do need to be aware of its limitations.

    [/general] permanent link