Apache Admin for Mac

 

 

Quickly set up multiple web environments under the built-in Web Sharing feature of Mac OS X, or a standard MAMP Apache Install.

Apache Admin is NOT a swiss army knife, it's just a small utility that will::

- Map aliases to local directories
- Restart Apache

 

NOTE: Mavericks requires "Unidentified Developer" apps downloaded from the internet to be verified by you. After downloading and unzipping, right-click on "Apache Admin" app and choose "open". You'll only have to do this once.

 

 

Using Apache Admin

- Drag and drop a folder on your local machine into the "Aliases" area of the app.
- Edit the "Alias" field to your liking.
- Click the "Save" button.
- Apache Admin will set up the alias and automatically restart Apache.

Once you've set up an alias, you can launch a browser window and type in the new address.

For example

http://localhost/bob

OR

http://localhost/whatever

... you should see the contents of the folder that the alias was "mapped to".

Admin Password
Should be the adminitrator password for you Mac (the user who is allowed to do anything on the Mac).

Apache Path
Used to target where the main Apache "program" lives on your system. If you have a unique Apache installation, or perhaps Apple decides to change things in the future, you can edit this path to target where Apache lives on your system. Don't change this unless you understand what you're doing.

Conf Path
D etermines where the alias configurations go. This is a special path on your system where Apache automatically picks up "conf" files. Don't change this unless you understand what you're doing.

 

About Aliases

On the Mac, the localhost "domain" is set up to pull files from the following folder on your Mac's hard drive:

/Library/WebServer/Documents

In other words, when you enter the following address into a browser on your Mac:

http://localhost

... Apache will direct the requests to (or pull files from) the "/Library/Webserver/Documents" folder.

Developers need a way to run multiple sites locally -- using a unique folder and "address" for each site.

Apache's VirtualHost allows us to manage domains, however, establishing a VirtualHost requires a fiddling around with the Mac's DNS and other scary stuff -- yikes!

Enter Aliases

An easier, and less intrusive way to "point" or "map" an address to a unique folder is to use an "alias".

Unlike a VirtualHost, an alias is just a single word that follows the "localhost" address.

Example:

http://localhost/foo

In the example above "foo" is the alias.

Apache can be configured to direct requests to this "foo" address to a unique folder on your Mac hard drive.

Example:

http://localhost/foo

...can be mapped to:

/Volumes/MyOtherHD/mysite

Now, when you enter "http://localhost/foo", the browser will display the contents of "/Volumes/MyOtherHD/mysite"

 

 

What's going on under the hood?

I've been manually writing aliases for years, but every time I need to set up an alias, I have to dig around for the instructions, deal with shell commands, type out folder paths and so on. It's easy to do manually, but a pain in the arse.

Basically, Apache Admin maintains a simple "conf" file that gets picked up as an "Include" when Apache starts. Apache Admin writes alias' to this file, then restarts Apache.

 

Going a little deeper

In Mac OS X , Apache is configured (by default) to load any "conf" files located in the following system folder:

/etc/apache2/other/*.conf

If you open Apache's main conf file (httpd.conf) you'll see the reference to the "other" folder as an "Include" toward the end of the file. (See the "Not Working" section below for the gorey details.)

Apache Admin maintains a file named "aliases.conf" in this "other" folder:

/etc/apache2/other/aliases.conf

The contents of the "aliases.conf" file will resemble:

...
usually near the end of the file
...

Alias /abc "/Users/bob/Documents/mysite1"
<Directory "/Users/bob/Documents/mysite1">
   Options All Multiviews
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>

Alias /xyz "/Users/bob/Documents/mysite2"
<Directory "/Users/bob/Documents/mysite2">
   Options All Multiviews
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>

 

You can review the file that Apache Admin creates by entering the following into Terminal

vi /etc/apache2/other/aliases.conf

So to recap: Apache Admin creates the aliases.conf file, then restarts Apache. That's really all that's going on.

 

Not Working?

There are 2 versions of Apache Admin, the only difference between version is the command to access the "aliases.conf" file.

So if Apache Admin version 1.0 doesn't work, try using version 1.1.

Depending on how Apache is set up on your system, you may have to discover the path to the "other" folder and/or the path to Apache. (And that's why those fields are available for you to edit!)

You can poke around the Apache conf file by launching Terminal and entering:

vi /etc/apache2/httpd.conf

Scroll down and look for lines that begin with "Include" or "MACOSXSERVER"

<IfDefine !MACOSXSERVER>
   Include /etc/apache2/other/*.conf
</IfDefine>
<IfDefine MACOSXSERVER>
  <IfDefine WEBSERVICE_ON>
     Include /etc/apache2/sites/*.conf
  </IfDefine>
  <IfDefine !WEBSERVICE_ON>
     Include /etc/apache2/sites/virtual_host_global.conf
     Include /etc/apache2/sites/*_.conf
     Include /etc/apache2/sites/*__shadow.conf
  </IfDefine>
</IfDefine>

In the example above, the NOT MACOSXSERVER means, well, my Mac isn't a "server" it's just a personal computer, so Apache will load all of the "conf" files located in the "other" folder.

 

 

 

 

 

Download


Version 1.1
OS X 10.9+ (Mavericks)

 

 


Version 1.0
OS X 10.7.4 (Lion)

 

 

 

 

 

 

 

 

 

 

©2013 Mike Gieson.