<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Installing Switch (Mac)</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link type="text/css" rel="stylesheet" title="Default Stylesheet" href="global.css" />
</head>
<body id="constants" class="documentation">
<div id="header">
</div>
<div id="localNav">
<h2>Switch</h2>
<ul id="extensionsNav">
<li><a href="install_mac.html">Installation (Mac)</a></li>
<li><a href="install_windows.html">Installation (Windows)</a></li>
<li><a href="variables.html">Variables</a></li>
<li><a href="constants.html">Constants</a></li>
<li><a href="includes.html">Includes</a></li>
<li><a href="comments.html">Comments</a></li>
<li><a href="ignore.html">Ignore</a>
<li><a href="auto_prepending.html">Automatic Selector Prepending</a></li>
<li><a href="inheritance.html">Inheritance</a></li>
<li><a href="copy.html">Property Duplication</a></li>
<li><a href="property_lookup.html">Property Look-ups</a></li>
</ul>
</div>
<div id="mainContent">
<h2>Installing Switch (Mac OS X)</h2>
<h3>Download Switch Source</h3>
<p>All files needed to run Switch from Apache and the command-line are located in the Switch directory.</p>
<h3>Download/Install Apple Developer Tools (1.5 or higher)</h3>
<p>You will need Apple's developer tools to compile mod_python.</p>
<h4>Panther</h4>
<p>Download and install XCode 1.5</p>
<h4>Tiger</h4>
<p>You will need the latest XCode/Developer Tools release (Xcode Tools 2.3).</p>
<h3>Download/Install GCC Update (3.3)</h3>
<p>Check your GCC version by opening Terminal and typing:</p>
<div class="example">
<div class="terminal">
<code>> gcc -v</code>
</div>
</div>
<p>Your output should look like:</p>
<div class="example">
<div class="terminal">
<pre><code>> gcc -v
> Reading specs from /usr/libexec/gcc/darwin/ppc/3.3/specs
> Thread model: posix
> gcc version 3.3 20030304 (Apple Computer, Inc. build 1671)</code></pre></div>
</div>
<p>Make sure the version is <strong>3.3</strong> and the build is <strong>1671</strong> or later. If not, use the GCC updater (should only be needed on Panther): <a href="http://designdrive/Projects/Design_Tech/resources/Switch_Installers/gcc-1640.tar.gz">http://designdrive/Projects/Design_Tech/resources/Switch_Installers/gcc-1640.tar.gz</a></p>
<h3>Install Apache 2 (2.0.52)</h3>
<p>If you do not have Apache 2 already installed on your machine, a package installer can be found on the <a href="http://serverlogistics.com/apache2.php">Server Logistics website</a></p>
<p class="important">After installing Apache 2, both Apache 1.3 and Apache 2 may fail to automatically start on restart. Stop Apache 1.3 if it is currently running -- this may help prevent the issue.</p>
<h4>Install Apache 2 Preference Pane (Control Panel)</h4>
<p>See if there is a PreferencePane directory already</p>
<div class="example">
<div class="terminal">
<code>> ls -la /Library</code>
</div>
</div>
<p>If the directory "PreferencePanes" does not exist, create it</p>
<div class="example">
<div class="terminal">
<code>> mkdir /Library/PreferencePanes</code>
</div>
</div>
<p>Drag Apache2.prefPane from the disk image to the PreferencePanes directory. The next time you start System Preferences the Apache2 preference pane will appear at the bottom.</p>
<h3>Build mod_python (3.2.8)</h3>
<p>You can <a href="http://www.apache.org/dist/httpd/modpython/mod_python-3.2.8.tgz">download the mod_python (3.2.8) source</a> from the Apache Website, or reference <a href="http://www.modpython.org/">modpython.org</a></p>
<p>Decompress the file on your desktop and Terminal type the following:</p>
<div class="example">
<div class="terminal">
<code>> cd ~/Desktop/mod_python-3.2.8/
./configure --with-apxs=/Library/Apache2/bin/apxs</code>
</div>
</div>
<p>(...compile...)</p>
<div class="example">
<div class="terminal">
<code>> make</code>
</div>
</div>
<p>(...compile...)</p>
<div class="example">
<div class="terminal">
<code>> sudo make install</code>
</div>
</div>
<p>You will need administrator priviliges and may be prompted for a password.</p>
<h3>Update Apache 2 Configuration (<code>/Library/Apache2/conf/httpd.conf</code>)</h3>
<p>(Add after LoadModule...)</p>
<div class="example">
<div class="terminal">
<pre><code># mod_python...
LoadModule python_module /Library/Apache2/modules/mod_python.so
</code></pre></div>
</div>
<p>(Add after VirtualHosts...)</p>
<div class="example">
<div class="terminal">
<pre><code><Directory '/path/to/css/dir'>
AddHandler mod_python .css
PythonPath "['/path/to/switch/dir'] + sys.path"
PythonHandler switch
PythonDebug On
</Directory></code></pre></div>
</div>
<h3>Start/Restart Apache2</h3>
<ul>
<li>Open the Control Panel (Apple > Control Panel)</li>
<li>Verify the syntax of the <code>http.conf</code> file ( Apache2 > Configuration > Check Syntax )</li>
<li>Start/Restart Apache2</li>
</ul>
<h2>Finished!</h2>
<p>Switch should now be installed and running properly.</p>
<p>Now your webserver will now rewite a request for http://mysite.com/<strong>css/</strong>global.css to http://mysite.com/<strong>switch/</strong>global.css and hand this request to Switch, which will look for a file named <strong>global.sss</strong> in that directory (switch/global.sss), parse it, and return the output.</p>
<p>If no .sss file is found, Switch will attempt to serve a .css file with the name requested (global.css in this case), and return a 404 if neither can be found.</p>
</div>
</body>
</html>