Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://kodomo.cmm.msu.ru/trac/tanchiki/wiki/TracModWSGI?action=diff&version=2
Äàòà èçìåíåíèÿ: Unknown
Äàòà èíäåêñèðîâàíèÿ: Mon Apr 11 21:01:22 2016
Êîäèðîâêà: IBM-866
TracModWSGI (diff) òÀÓ Tanchiki

Changes between Version 1 and Version 2 of TracModWSGI


Ignore:
Timestamp:
08/21/13 19:46:14 (3 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracModWSGI

    v1 v2 ˆà
    11= Trac and mod_wsgi =ˆà
    22ˆà
    3ˆà'''Important note:''' ''Please use either version 1.6, 2.4 or later of `mod_wsgi`. Versions prior to 2.4 in the 2.X branch have problems with some Apache configurations that use WSGI file wrapper extension. This extension is used in Trac to serve up attachments and static media files such as style sheets. If you are affected by this problem attachments will appear to be empty and formatting of HTML pages will appear not to work due to style sheet files not loading properly. See mod_wsgi tickets [http://code.google.com/p/modwsgi/issues/detail?id=100 #100] and [http://code.google.com/p/modwsgi/issues/detail?id=132 #132].''ˆà
    4ˆàˆà
    5ˆà[http://code.google.com/p/modwsgi/ mod_wsgi] is an Apache module for running WSGI-compatible Python applications directly on top of Apache. The mod_wsgi adapter is written completely in C and provides significantly better performance than using existing WSGI adapters for mod_python or CGI.ˆà
    6ˆàˆà
    7ˆàTrac can be run on top of mod_wsgi with the help of the following application script, which is just a Python file, though usually saved with a .wsgi extension). This file can be created using '''trac-admin <env> deploy <dir>''' command which automatically substitutes required paths.ˆà
    8ˆàˆà
    9ˆà{{{ˆà
    10ˆà#!pythonˆà
    ˆà3ˆà
    ˆà4[http://code.google.com/p/modwsgi/ mod_wsgi] is an Apache module for running WSGI-compatible Python applications directly on top of the Apache webserver. The mod_wsgi adapter is written completely in C and provides very good performances.ˆà
    ˆà5ˆà
    ˆà6[[PageOutline(2-3,Overview,inline)]]ˆà
    ˆà7ˆà
    ˆà8== The `trac.wsgi` scriptˆà
    ˆà9ˆà
    ˆà10Trac can be run on top of mod_wsgi with the help of the following application script, which is just a Python file, though usually saved with a `.wsgi` extension). ˆà
    ˆà11ˆà
    ˆà12=== A very basic scriptˆà
    ˆà13In its simplest form, the script could be:ˆà
    ˆà14ˆà
    ˆà15{{{#!pythonˆà
    1116import osˆà
    1217ˆà
    òÀæ òÀæ ˆà
    2025The `TRAC_ENV` variable should naturally be the directory for your Trac environment (if you have several Trac environments in a directory, you can also use `TRAC_ENV_PARENT_DIR` instead), while the `PYTHON_EGG_CACHE` should be a directory where Python can temporarily extract Python eggs.ˆà
    2126ˆà
    22ˆà'''Important note:''' If you're using multiple `.wsgi` files (for example one per Trac environment) you must ''not'' use `os.environ['TRAC_ENV']` to set the path to the Trac environment. Using this method may lead to Trac delivering the content of another Trac environment. (The variable may be filled with the path of a previously viewed Trac environment.) To solve this problem, use the following `.wsgi` file instead:ˆà
    23ˆàˆà
    24ˆà{{{ˆà
    25ˆà#!pythonˆà
    ˆà27=== A more elaborate scriptˆà
    ˆà28ˆà
    ˆà29If you're using multiple `.wsgi` files (for example one per Trac environment) you must ''not'' use `os.environ['TRAC_ENV']` to set the path to the Trac environment. Using this method may lead to Trac delivering the content of another Trac environment, as the variable may be filled with the path of a previously viewed Trac environment. ˆà
    ˆà30ˆà
    ˆà31To solve this problem, use the following `.wsgi` file instead:ˆà
    ˆà32{{{#!pythonˆà
    2633import osˆà
    2734ˆà
    òÀæ òÀæ ˆà
    3441}}}ˆà
    3542ˆà
    36ˆàFor clarity, you should give this file a `.wsgi` extension. You should probably put the file in it's own directory, since you will open up its directory to Apache. You can create a .wsgi files which handles all this for you by running the TracAdmin command `deploy`.ˆà
    37ˆàˆà
    38ˆàIf you have installed trac and eggs in a path different from the standard one you should add that path by adding the following code on top of the wsgi script:ˆà
    39ˆàˆà
    40ˆà{{{ˆà
    41ˆà#!pythonˆà
    ˆà43For clarity, you should give this file a `.wsgi` extension. You should probably put the file in its own directory, since you will expose it to Apache. ˆà
    ˆà44ˆà
    ˆà45If you have installed Trac and eggs in a path different from the standard one you should add that path by adding the following code at the top of the wsgi script:ˆà
    ˆà46ˆà
    ˆà47{{{#!pythonˆà
    4248import siteˆà
    4349site.addsitedir('/usr/local/trac/lib/python2.4/site-packages')ˆà
    4450}}}ˆà
    4551ˆà
    46ˆàChange it according to the path you installed the trac libs at.ˆà
    47ˆàˆà
    48ˆàAfter you've done preparing your wsgi-script, add the following to your httpd.conf.ˆà
    ˆà52Change it according to the path you installed the Trac libs at.ˆà
    ˆà53ˆà
    ˆà54=== Recommended `trac.wsgi` scriptˆà
    ˆà55ˆà
    ˆà56A somewhat robust and generic version of this file can be created using the `trac-admin <env> deploy <dir>` command which automatically substitutes the required paths (see TracInstall#cgi-bin).ˆà
    ˆà57ˆà
    ˆà58ˆà
    ˆà59== Mapping requests to the scriptˆà
    ˆà60ˆà
    ˆà61After you've done preparing your .wsgi script, add the following to your Apache configuration file (`httpd.conf` for example).ˆà
    4962ˆà
    5063{{{ˆà
    òÀæ òÀæ ˆà
    5871}}}ˆà
    5972ˆà
    60ˆàHere, the script is in a subdirectory of the Trac environment. In order to let Apache run the script, access to the directory in which the script resides is opened up to all of Apache. Additionally, the {{{WSGIApplicationGroup}}} directive ensures that Trac is always run in the first Python interpreter created by mod_wsgi; this is necessary because the Subversion Python bindings, which are used by Trac, don't always work in other subinterpreters and may cause requests to hang or cause Apache to crash as a result. After adding this configuration, restart Apache, and then it should work.ˆà
    61ˆàˆà
    62ˆàTo test the setup of Apache, mod_wsgi and Python itself (ie. without involving Trac and dependencies), this simple wsgi application can be used to make sure that requests gets served (use as only content in your .wsgi script):ˆà
    63ˆàˆà
    64ˆà{{{ˆà
    ˆà73Here, the script is in a subdirectory of the Trac environment.ˆà
    ˆà74ˆà
    ˆà75If you followed the directions [http://trac.edgewall.org/wiki/TracInstall#cgi-bin Generating the Trac cgi-bin directory], your Apache configuration file should look like following:ˆà
    ˆà76ˆà
    ˆà77{{{ˆà
    ˆà78WSGIScriptAlias /trac /usr/share/trac/cgi-bin/trac.wsgiˆà
    ˆà79ˆà
    ˆà80<Directory /usr/share/trac/cgi-bin>ˆà
    ˆà81    WSGIApplicationGroup %{GLOBAL}ˆà
    ˆà82    Order deny,allowˆà
    ˆà83    Allow from allˆà
    ˆà84</Directory>ˆà
    ˆà85}}}ˆà
    ˆà86ˆà
    ˆà87In order to let Apache run the script, access to the directory in which the script resides is opened up to all of Apache. Additionally, the `WSGIApplicationGroup` directive ensures that Trac is always run in the first Python interpreter created by mod_wsgi; this is necessary because the Subversion Python bindings, which are used by Trac, don't always work in other sub-interpreters and may cause requests to hang or cause Apache to crash as a result. After adding this configuration, restart Apache, and then it should work.ˆà
    ˆà88ˆà
    ˆà89To test the setup of Apache, mod_wsgi and Python itself (ie. without involving Trac and dependencies), this simple wsgi application can be used to make sure that requests gets served (use as only content in your `.wsgi` script):ˆà
    ˆà90ˆà
    ˆà91{{{#!pythonˆà
    6592def application(environ, start_response):ˆà
    6693        start_response('200 OK',[('Content-type','text/html')])ˆà
    òÀæ òÀæ ˆà
    6895}}}ˆà
    6996ˆà
    70ˆàSee also the mod_wsgi [http://code.google.com/p/modwsgi/wiki/IntegrationWithTrac installation instructions] for Trac.ˆà
    71ˆàˆà
    72ˆàFor troubleshooting tips, see the [TracModPython#Troubleshooting mod_python troubleshooting] section, as most Apache-related issues are quite similar, plus discussion of potential [http://code.google.com/p/modwsgi/wiki/ApplicationIssues application issues] when using mod_wsgi.ˆà
    ˆà97For more information about using the mod_wsgi specific directives, see the [http://code.google.com/p/modwsgi/wiki/ mod_wsgi's wiki] and more specifically the [http://code.google.com/p/modwsgi/wiki/IntegrationWithTrac IntegrationWithTrac] page.ˆà
    ˆà98ˆà
    ˆà99ˆà
    ˆà100== Configuring Authenticationˆà
    ˆà101ˆà
    ˆà102We describe in the the following sections different methods for setting up authentication.ˆà
    ˆà103ˆà
    ˆà104See also [http://httpd.apache.org/docs/2.2/howto/auth.html Authentication, Authorization and Access Control] in the Apache guide.ˆà
    ˆà105ˆà
    ˆà106=== Using Basic Authentication ===ˆà
    ˆà107ˆà
    ˆà108The simplest way to enable authentication with Apache is to create a password file. Use the `htpasswd` program to create the password file:ˆà
    ˆà109{{{ˆà
    ˆà110$ htpasswd -c /somewhere/trac.htpasswd adminˆà
    ˆà111New password: <type password>ˆà
    ˆà112Re-type new password: <type password again>ˆà
    ˆà113Adding password for user adminˆà
    ˆà114}}}ˆà
    ˆà115ˆà
    ˆà116After the first user, you dont need the "-c" option anymore:ˆà
    ˆà117{{{ˆà
    ˆà118$ htpasswd /somewhere/trac.htpasswd johnˆà
    ˆà119New password: <type password>ˆà
    ˆà120Re-type new password: <type password again>ˆà
    ˆà121Adding password for user johnˆà
    ˆà122}}}ˆà
    ˆà123ˆà
    ˆà124  ''See the man page for `htpasswd` for full documentation.''ˆà
    ˆà125ˆà
    ˆà126After you've created the users, you can set their permissions using TracPermissions.ˆà
    ˆà127ˆà
    ˆà128Now, you'll need to enable authentication against the password file in the Apache configuration:ˆà
    ˆà129{{{ˆà
    ˆà130<Location "/trac/login">ˆà
    ˆà131  AuthType Basicˆà
    ˆà132  AuthName "Trac"ˆà
    ˆà133  AuthUserFile /somewhere/trac.htpasswdˆà
    ˆà134  Require valid-userˆà
    ˆà135</Location>ˆà
    ˆà136}}}ˆà
    ˆà137ˆà
    ˆà138If you're hosting multiple projects you can use the same password file for all of them:ˆà
    ˆà139{{{ˆà
    ˆà140<LocationMatch "/trac/[^/]+/login">ˆà
    ˆà141  AuthType Basicˆà
    ˆà142  AuthName "Trac"ˆà
    ˆà143  AuthUserFile /somewhere/trac.htpasswdˆà
    ˆà144  Require valid-userˆà
    ˆà145</LocationMatch>ˆà
    ˆà146}}}ˆà
    ˆà147Note that neither a file nor a directory named 'login' needs to exist.[[BR]]ˆà
    ˆà148See also the [http://httpd.apache.org/docs/2.2/mod/mod_auth_basic.html mod_auth_basic] documentation.ˆà
    ˆà149ˆà
    ˆà150=== Using Digest Authentication ===ˆà
    ˆà151ˆà
    ˆà152For better security, it is recommended that you either enable SSL or at least use the òÀÜdigestòÀÝ authentication scheme instead of òÀÜBasicòÀÝ. ˆà
    ˆà153ˆà
    ˆà154You'll have to create your `.htpasswd` file with the `htdigest` command instead of `htpasswd`, as follows:ˆà
    ˆà155{{{ˆà
    ˆà156# htdigest -c /somewhere/trac.htpasswd trac adminˆà
    ˆà157}}}ˆà
    ˆà158ˆà
    ˆà159The "trac" parameter above is the "realm", and will have to be reused in the Apache configuration in the !AuthName directive:ˆà
    ˆà160ˆà
    ˆà161{{{ˆà
    ˆà162<Location "/trac/login">ˆà
    ˆà163ˆà
    ˆà164    AuthType Digestˆà
    ˆà165    AuthName "trac"ˆà
    ˆà166    AuthDigestDomain /tracˆà
    ˆà167    AuthUserFile /somewhere/trac.htpasswdˆà
    ˆà168    Require valid-userˆà
    ˆà169</Location>ˆà
    ˆà170}}}ˆà
    ˆà171ˆà
    ˆà172For multiple environments, you can use the same `LocationMatch` as described with the previous method.ˆà
    ˆà173ˆà
    ˆà174Don't forget to activate the mod_auth_digest. For example, on a Debian 4.0r1 (etch) system:ˆà
    ˆà175{{{ˆà
    ˆà176    LoadModule auth_digest_module /usr/lib/apache2/modules/mod_auth_digest.soˆà
    ˆà177}}}ˆà
    ˆà178ˆà
    ˆà179ˆà
    ˆà180See also the [http://httpd.apache.org/docs/2.2/mod/mod_auth_digest.html mod_auth_digest] documentation.ˆà
    ˆà181ˆà
    ˆà182=== Using LDAP Authentication ˆà
    ˆà183ˆà
    ˆà184Configuration for [http://httpd.apache.org/docs/2.2/mod/mod_ldap.html mod_ldap] authentication in Apache is a bit tricky (httpd 2.2.x and OpenLDAP: slapd 2.3.19)ˆà
    ˆà185ˆà
    ˆà1861. You need to load the following modules in Apache httpd.confˆà
    ˆà187{{{ˆà
    ˆà188LoadModule ldap_module modules/mod_ldap.soˆà
    ˆà189LoadModule authnz_ldap_module modules/mod_authnz_ldap.soˆà
    ˆà190}}}ˆà
    ˆà191ˆà
    ˆà1922. Your httpd.conf also needs to look something like:ˆà
    ˆà193ˆà
    ˆà194{{{ˆà
    ˆà195<Location /trac/>ˆà
    ˆà196  # (if you're using it, mod_python specific settings go here)ˆà
    ˆà197  Order deny,allowˆà
    ˆà198  Deny from allˆà
    ˆà199  Allow from 192.168.11.0/24ˆà
    ˆà200  AuthType Basicˆà
    ˆà201  AuthName "Trac"ˆà
    ˆà202  AuthBasicProvider "ldap"ˆà
    ˆà203  AuthLDAPURL "ldap://127.0.0.1/dc=example,dc=co,dc=ke?uid?sub?(objectClass=inetOrgPerson)"ˆà
    ˆà204  authzldapauthoritative Offˆà
    ˆà205  Require valid-userˆà
    ˆà206</Location>ˆà
    ˆà207}}}ˆà
    ˆà208ˆà
    ˆà209ˆà
    ˆà2103. You can use the LDAP interface as a way to authenticate to a Microsoft Active Directory:ˆà
    ˆà211ˆà
    ˆà212ˆà
    ˆà213Use the following as your LDAP URL:ˆà
    ˆà214{{{ˆà
    ˆà215    AuthLDAPURL "ldap://directory.example.com:3268/DC=example,DC=com?sAMAccountName?sub?(objectClass=user)"ˆà
    ˆà216}}}ˆà
    ˆà217ˆà
    ˆà218You will also need to provide an account for Apache to use when checkingˆà
    ˆà219credentials. As this password will be listed in plaintext in theˆà
    ˆà220config, you should be sure to use an account specifically for this task:ˆà
    ˆà221{{{ˆà
    ˆà222    AuthLDAPBindDN ldap-auth-user@example.comˆà
    ˆà223    AuthLDAPBindPassword "password"ˆà
    ˆà224}}}ˆà
    ˆà225ˆà
    ˆà226The whole section looks like:ˆà
    ˆà227{{{ˆà
    ˆà228<Location /trac/>ˆà
    ˆà229  # (if you're using it, mod_python specific settings go here)ˆà
    ˆà230  Order deny,allowˆà
    ˆà231  Deny from allˆà
    ˆà232  Allow from 192.168.11.0/24ˆà
    ˆà233  AuthType Basicˆà
    ˆà234  AuthName "Trac"ˆà
    ˆà235  AuthBasicProvider "ldap"ˆà
    ˆà236  AuthLDAPURL "ldap://adserver.company.com:3268/DC=company,DC=com?sAMAccountName?sub?(objectClass=user)"ˆà
    ˆà237  AuthLDAPBindDN       ldap-auth-user@company.comˆà
    ˆà238  AuthLDAPBindPassword "the_password"ˆà
    ˆà239  authzldapauthoritative Offˆà
    ˆà240  # require valid-userˆà
    ˆà241  require ldap-group CN=Trac Users,CN=Users,DC=company,DC=comˆà
    ˆà242</Location>ˆà
    ˆà243}}}ˆà
    ˆà244ˆà
    ˆà245Note 1: This is the case where the LDAP search will get around the multiple OUs, conecting to Global Catalog Server portion of AD (Notice the port is 3268, not the normal LDAP 389). The GCS is basically a "flattened" tree which allows searching for a user without knowing to which OU they belong.ˆà
    ˆà246ˆà
    ˆà247Note 2: You can also require the user be a member of a certain LDAP group, instead ofˆà
    ˆà248just having a valid login:ˆà
    ˆà249{{{ˆà
    ˆà250    Require ldap-group CN=Trac Users,CN=Users,DC=example,DC=comˆà
    ˆà251}}}ˆà
    ˆà252ˆà
    ˆà253See also:ˆà
    ˆà254  - [http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html mod_authnz_ldap], documentation for mod_authnz_ldapˆà
    ˆà255    ˆà
    ˆà256 - [http://httpd.apache.org/docs/2.2/mod/mod_ldap.html mod_ldap], documentation for mod_ldap, which provides connection pooling and a shared cache.ˆà
    ˆà257 - [http://trac-hacks.org/wiki/LdapPlugin TracHacks:LdapPlugin] for storing TracPermissions in LDAP.ˆà
    ˆà258ˆà
    ˆà259=== Using SSPI Authenticationˆà
    ˆà260ˆà
    ˆà261If you are using Apache on Windows, you can use mod_auth_sspi to provideˆà
    ˆà262single-sign-on. Download the module from the !SourceForge [http://sourceforge.net/projects/mod-auth-sspi/ mod-auth-sspi project] and then add theˆà
    ˆà263following to your !VirtualHost:ˆà
    ˆà264{{{ˆà
    ˆà265    <Location /trac/login>ˆà
    ˆà266        AuthType SSPIˆà
    ˆà267        AuthName "Trac Login"ˆà
    ˆà268        SSPIAuth Onˆà
    ˆà269        SSPIAuthoritative Onˆà
    ˆà270        SSPIDomain MyLocalDomainˆà
    ˆà271        SSPIOfferBasic Onˆà
    ˆà272        SSPIOmitDomain Offˆà
    ˆà273        SSPIBasicPreferred Onˆà
    ˆà274        Require valid-userˆà
    ˆà275    </Location>ˆà
    ˆà276}}}ˆà
    ˆà277ˆà
    ˆà278Using the above, usernames in Trac will be of the form `DOMAIN\username`, soˆà
    ˆà279you may have to re-add permissions and such. If you do not want the domain toˆà
    ˆà280be part of the username, set `SSPIOmitDomain On` instead.ˆà
    ˆà281ˆà
    ˆà282Some common problems with SSPI authentication: [trac:#1055], [trac:#1168] and [trac:#3338].ˆà
    ˆà283ˆà
    ˆà284See also [trac:TracOnWindows/Advanced].ˆà
    ˆà285ˆà
    ˆà286=== Using Apache authentication with the Account Manager plugin's Login form ===ˆà
    ˆà287ˆà
    ˆà288To begin with, see the basic instructions for using the Account Manager plugin's [http://trac-hacks.org/wiki/AccountManagerPlugin/Modules#LoginModule Login module] and its [http://trac-hacks.org/wiki/AccountManagerPlugin/AuthStores#HttpAuthStore HttpAuthStore authentication module].ˆà
    ˆà289ˆà
    ˆà290'''Note:''' If is difficult to get !HttpAuthStore to work with WSGI when using any Account Manager version prior to acct_mgr-0.4. Upgrading is recommended.ˆà
    ˆà291ˆà
    ˆà292Here is an example (from the !HttpAuthStore link) using acct_mgr-0.4 for hosting a single project:ˆà
    ˆà293{{{ˆà
    ˆà294[components]ˆà
    ˆà295; be sure to enable the componentˆà
    ˆà296acct_mgr.http.HttpAuthStore = enabledˆà
    ˆà297ˆà
    ˆà298[account-manager]ˆà
    ˆà299; configure the plugin to use a page that is secured with http authenticationˆà
    ˆà300authentication_url = /authFileˆà
    ˆà301password_store = HttpAuthStoreˆà
    ˆà302}}}ˆà
    ˆà303This will generally be matched with an Apache config like:ˆà
    ˆà304{{{ˆà
    ˆà305<Location /authFile>ˆà
    ˆà306   òÀæHTTP authentication configurationòÀæˆà
    ˆà307   Require valid-userˆà
    ˆà308</Location>ˆà
    ˆà309}}}ˆà
    ˆà310Note that '''authFile''' need not exist. See the !HttpAuthStore link above for examples where multiple Trac projects are hosted on a server.ˆà
    ˆà311ˆà
    ˆà312=== Example: Apache/mod_wsgi with Basic Authentication, Trac being at the root of a virtual hostˆà
    ˆà313ˆà
    ˆà314Per the mod_wsgi documentation linked to above, here is an example Apache configuration that a) serves the Trac instance from a virtualhost subdomain and b) uses Apache basic authentication for Trac authentication.ˆà
    ˆà315ˆà
    ˆà316ˆà
    ˆà317If you want your Trac to be served from e.g. !http://trac.my-proj.my-site.org, then from the folder e.g. `/home/trac-for-my-proj`, if you used the command `trac-admin the-env initenv` to create a folder `the-env`, and you used `trac-admin the-env deploy the-deploy` to create a folder `the-deploy`, then first:ˆà
    ˆà318ˆà
    ˆà319Create the htpasswd file:ˆà
    ˆà320{{{ˆà
    ˆà321cd /home/trac-for-my-proj/the-envˆà
    ˆà322htpasswd -c htpasswd firstuserˆà
    ˆà323### and add more users to it as needed:ˆà
    ˆà324htpasswd htpasswd seconduserˆà
    ˆà325}}}ˆà
    ˆà326(keep the file above your document root for security reasons)ˆà
    ˆà327ˆà
    ˆà328Create this file e.g. (ubuntu) `/etc/apache2/sites-enabled/trac.my-proj.my-site.org.conf` with the following contents:ˆà
    ˆà329ˆà
    ˆà330{{{ˆà
    ˆà331<Directory /home/trac-for-my-proj/the-deploy/cgi-bin/trac.wsgi>ˆà
    ˆà332  WSGIApplicationGroup %{GLOBAL}ˆà
    ˆà333  Order deny,allowˆà
    ˆà334  Allow from allˆà
    ˆà335</Directory>ˆà
    ˆà336ˆà
    ˆà337<VirtualHost *:80>ˆà
    ˆà338  ServerName trac.my-proj.my-site.orgˆà
    ˆà339  DocumentRoot /home/trac-for-my-proj/the-env/htdocs/ˆà
    ˆà340  WSGIScriptAlias / /home/trac-for-my-proj/the-deploy/cgi-bin/trac.wsgiˆà
    ˆà341  <Location '/'>ˆà
    ˆà342    AuthType Basicˆà
    ˆà343    AuthName "Trac"ˆà
    ˆà344    AuthUserFile /home/trac-for-my-proj/the-env/htpasswdˆà
    ˆà345    Require valid-userˆà
    ˆà346  </Location>ˆà
    ˆà347</VirtualHost>ˆà
    ˆà348ˆà
    ˆà349}}}ˆà
    ˆà350ˆà
    ˆà351Note: for subdomains to work you would probably also need to alter `/etc/hosts` and add A-Records to your host's DNS.ˆà
    ˆà352ˆà
    ˆà353ˆà
    ˆà354== Troubleshootingˆà
    ˆà355ˆà
    ˆà356=== Use a recent versionˆà
    ˆà357ˆà
    ˆà358Please use either version 1.6, 2.4 or later of `mod_wsgi`. Versions prior to 2.4 in the 2.X branch have problems with some Apache configurations that use WSGI file wrapper extension. This extension is used in Trac to serve up attachments and static media files such as style sheets. If you are affected by this problem attachments will appear to be empty and formatting of HTML pages will appear not to work due to style sheet files not loading properly. Another frequent symptom is that binary attachment downloads are truncated. See mod_wsgi tickets [http://code.google.com/p/modwsgi/issues/detail?id=100 #100] and [http://code.google.com/p/modwsgi/issues/detail?id=132 #132].ˆà
    73359ˆà
    74360''Note: using mod_wsgi 2.5 and Python 2.6.1 gave an Internal Server Error on my system (Apache 2.2.11 and Trac 0.11.2.1). Upgrading to Python 2.6.2 (as suggested [http://www.mail-archive.com/modwsgi@googlegroups.com/msg01917.html here]) solved this for me[[BR]]-- Graham Shanks''ˆà
    75361ˆà
    76ˆà== Trac with PostgreSQL ==ˆà
    77ˆàˆà
    78ˆàWhen using the mod_wsgi adapter with multiple Trac instances and PostgreSQL (or MySQL?) as a database back-end the server can get a lot of open database connections. (and thus PostgreSQL processes)ˆà
    79ˆàˆà
    80ˆàA workable solution is to disabled connection pooling in Trac. This is done by setting poolable = False in trac.db.postgres_backend on the PostgreSQLConnection class.ˆà
    81ˆàˆà
    82ˆàBut it's not necessary to edit the source of trac, the following lines in trac.wsgi will also work:ˆà
    83ˆàˆà
    84ˆà{{{ˆà
    85ˆàimport trac.db.postgres_backendˆà
    86ˆàtrac.db.postgres_backend.PostgreSQLConnection.poolable = Falseˆà
    87ˆà}}}ˆà
    88ˆàˆà
    89ˆàNow Trac drops the connection after serving a page and the connection count on the database will be kept minimal.ˆà
    90ˆàˆà
    91ˆà== Getting Trac to work nicely with SSPI and 'Require Group' ==ˆà
    ˆà362If you plan to use `mod_wsgi` in embedded mode on Windows or with the MPM worker on Linux, then you'll even need version 0.3.4 or greater (see [trac:#10675] for details).ˆà
    ˆà363ˆà
    ˆà364=== Getting Trac to work nicely with SSPI and 'Require Group' ===ˆà
    92365If like me you've set Trac up on Apache, Win32 and configured SSPI, but added a 'Require group' option to your apache configuration, then the SSPIOmitDomain option is probably not working.  If its not working your usernames in trac are probably looking like 'DOMAIN\user' rather than 'user'.ˆà
    93366ˆà
    94367This WSGI script 'fixes' things, hope it helps:ˆà
    95ˆà{{{ˆà
    ˆà368{{{#!pythonˆà
    96369import osˆà
    97370import trac.web.mainˆà
    òÀæ òÀæ ˆà
    105378    return trac.web.main.dispatch_request(environ, start_response)ˆà
    106379}}}ˆà
    ˆà380ˆà
    ˆà381ˆà
    ˆà382=== Trac with PostgreSQL ===ˆà
    ˆà383ˆà
    ˆà384When using the mod_wsgi adapter with multiple Trac instances and PostgreSQL (or MySQL?) as a database back-end, the server ''may'' create a lot of open database connections and thus PostgreSQL processes.ˆà
    ˆà385ˆà
    ˆà386A somewhat brutal workaround is to disabled connection pooling in Trac. This is done by setting `poolable = False` in `trac.db.postgres_backend` on the `PostgreSQLConnection` class.ˆà
    ˆà387ˆà
    ˆà388But it's not necessary to edit the source of Trac, the following lines in `trac.wsgi` will also work:ˆà
    ˆà389ˆà
    ˆà390{{{ˆà
    ˆà391import trac.db.postgres_backendˆà
    ˆà392trac.db.postgres_backend.PostgreSQLConnection.poolable = Falseˆà
    ˆà393}}}ˆà
    ˆà394ˆà
    ˆà395orˆà
    ˆà396ˆà
    ˆà397{{{ˆà
    ˆà398import trac.db.mysql_backendˆà
    ˆà399trac.db.mysql_backend.MySQLConnection.poolable = Falseˆà
    ˆà400}}}ˆà
    ˆà401ˆà
    ˆà402Now Trac drops the connection after serving a page and the connection count on the database will be kept minimal.ˆà
    ˆà403ˆà
    ˆà404//This is not a recommended approach though. See also the notes at the bottom of the [http://code.google.com/p/modwsgi/wiki/IntegrationWithTrac mod_wsgi's IntegrationWithTrac] wiki page.//ˆà
    ˆà405ˆà
    ˆà406=== Other resourcesˆà
    ˆà407ˆà
    ˆà408For more troubleshooting tips, see also the [TracModPython#Troubleshooting mod_python troubleshooting] section, as most Apache-related issues are quite similar, plus discussion of potential [http://code.google.com/p/modwsgi/wiki/ApplicationIssues application issues] when using mod_wsgi. The wsgi page also has a [http://code.google.com/p/modwsgi/wiki/IntegrationWithTrac Integration With Trac] document.ˆà
    ˆà409ˆà
    ˆà410ˆà
    107411----ˆà
    108412See also:  TracGuide, TracInstall, [wiki:TracFastCgi FastCGI], [wiki:TracModPython ModPython], [trac:TracNginxRecipe TracNginxRecipe]ˆà