[MacPorts] Notification: howto/SetupTracAjpWsgi added

MacPorts noreply at macports.org
Sun Jul 27 14:03:41 PDT 2008


Added page "howto/SetupTracAjpWsgi" by blb at macports.org from 75.163.189.154*
Page URL: <http://trac.macports.org/wiki/howto/SetupTracAjpWsgi>
Comment: New HOWTO on running Trac with ajp-wsgi
Content:

[wiki:howto <- Back to the HOWTO section]

= How to use Trac with ajp-wsgi and Apache =

 * Audience: Those who want to use Trac within a separate process from apache
 * Requires: MacPorts >=1.6, Mac OS X 10.5

== Introduction ==

There are several ways to run Trac with Apache: [http://trac.edgewall.org/wiki/TracModWSGI mod_wsgi], [http://trac.edgewall.org/wiki/TracModPython mod_python], and [http://www.saddi.com/software/ajp-wsgi/ ajp-wsgi] (and probably others...).  This discusses how to get it working with ajp-wsgi, which runs as a single separate process from Apache's httpd.  ajp-wsgi uses the [http://tomcat.apache.org/connectors-doc/ajp/ajpv13a.html Apache JServ Protocol] to communicate with Apache, hence needs some configuration done in httpd.conf.

== Installation ==

Install the necessary ports with:
{{{
sudo port install apache2
sudo port install trac
sudo port install ajp-wsgi +python25
}}}
The {{{+python25}}} variant was selected for ajp-wsgi to use the current Python version, and Trac prefers 2.5 as well so this keeps them using the same version.  By default, ajp-wsgi would otherwise depend on python24.

== Configuration ==

=== Configuring ajp-wsgi ===

First, ajp-wsgi needs to be setup to run with a launchd item.  Create a new launchd plist in {{{/Library/LaunchDaemons}}} called {{{com.example.ajp-wsgi.plist}}} (change com.example to suit your network) with {{{sudo vi /Library/LaunchDaemons/com.example.ajp-wsgi.plist}}} (or a different editor you can run as root).  Place the following into this new file
{{{
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>EnvironmentVariables</key>
	<dict>
		<key>PYTHONHOME</key>
		<string>/opt/local</string>
		<key>PYTHON_EGG_CACHE</key>
		<string>/usr/local/trac/.python-egg-cache</string>
		<key>TRAC_ENV_PARENT_DIR</key>
		<string>/usr/local/trac</string>
	</dict>
	<key>GroupName</key>
	<string>_www</string>
	<key>KeepAlive</key>
	<true/>
	<key>Label</key>
	<string>com.example.ajp-wsgi</string>
	<key>ProgramArguments</key>
	<array>
		<string>/opt/local/bin/ajp-wsgi</string>
		<string>-p</string>
		<string>8990</string>
		<string>trac.web.main</string>
		<string>dispatch_request</string>
		<string>/projects</string>
	</array>
	<key>UserName</key>
	<string>_www</string>
	<key>WorkingDirectory</key>
	<string>/usr/local/trac</string>
</dict>
</plist>
}}}
Be sure to replace {{{/usr/local/trac}}} with the location of your actual Trac project location.  This example uses {{{TRAC_ENV_PARENT_DIR}}} which allows for multiple Trac projects to be located as subdirectories under that path.

Also note the {{{/projects}}} part being passed to ajp-wsgi, which tells it that all the Trac projects will be accessed with a URL whose path starts with {{{/projects}}}.

=== Configuring Apache2 ===
Edit {{{/opt/local/apache2/conf/httpd.conf}}} in a text editor, and in the section pertinent to your server and how you want Trac accessed, add
{{{
   ProxyPass /projects/ ajp://localhost:8990/projects
   <Proxy */projects/*>
      Order Allow,Deny
      Allow from all
   </Proxy>
}}}
This tells Apache that requests to {{{/projects/*}}} to be proxied over to localhost's port 8990 (which is where ajp-wsgi is listening, as specified above).  This excerpt can be placed in the main portion of {{{httpd.conf}}} or in a <VirtualHost> section, depending on your needs.

=== Configuring Trac ===
Setup Trac as specified in [http://trac.edgewall.org/wiki/TracInstall#CreatingaProjectEnvironment Creating a Project Environment].  Since this example uses the multiple-projects-in-a-directory, be sure to use a subdirectory as the project environment; for example, with the {{{/usr/local/trac}}} location used above:
{{{
trac-admin /usr/local/trac/myproject initenv
}}}
Make sure everything in {{{/usr/local/trac}}} is owned by the user _www as that's how ajp-wsgi is running, which will need write access so Trac can update files.

== Testing ==

Try loading {{{http://www.example.com/projects/myproject}}} (replacing the domain and myproject as appropriate) and you should see the Trac page.

[wiki:howto <- Back to the HOWTO section]


* The IP shown here might not mean anything if the user is behind a proxy.

--
MacPorts <http://www.macports.org/>
Ports system for Mac OS

This is an automated message. Someone at http://www.macports.org/
added your email address to be notified of changes on MacPorts.
If it was not you, please report to http://www.macports.org/.


More information about the macports-changes mailing list