| | 76 | == Apache Basic Authentication for Trac thru mod_wsgi == |
| | 77 | |
| | 78 | Per the mod_wsgi documentation linked to above, here is an example Apache configuration that a) serves the trac from a virtualhost subdomain and b) uses Apache basic authentication for Trac authentication. |
| | 79 | |
| | 80 | |
| | 81 | If 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: |
| | 82 | |
| | 83 | create the htpasswd file: |
| | 84 | {{{ |
| | 85 | cd /home/trac-for-my-proj/the-env |
| | 86 | htpasswd -c htpasswd firstuser |
| | 87 | ### and add more users to it as needed: |
| | 88 | htpasswd htpasswd seconduser |
| | 89 | }}} |
| | 90 | (for security keep the file above your document root) |
| | 91 | |
| | 92 | create this file e.g. (ubuntu) {{{/etc/apache2/sites-enabled/trac.my-proj.my-site.org.conf}}} with these contents: |
| | 93 | |
| | 94 | {{{ |
| | 95 | <Directory /home/trac-for-my-proj/the-deploy/cgi-bin/trac.wsgi> |
| | 96 | WSGIApplicationGroup %{GLOBAL} |
| | 97 | Order deny,allow |
| | 98 | Allow from all |
| | 99 | </Directory> |
| | 100 | |
| | 101 | <VirtualHost *:80> |
| | 102 | ServerName trac.my-proj.my-site.org |
| | 103 | DocumentRoot /home/trac-for-my-proj/the-env/htdocs/ |
| | 104 | WSGIScriptAlias / /home/trac-for-my-proj/the-deploy/cgi-bin/trac.wsgi |
| | 105 | <Location '/'> |
| | 106 | AuthType Basic |
| | 107 | AuthName "Trac" |
| | 108 | AuthUserFile /home/trac-for-my-proj/the-env/htpasswd |
| | 109 | Require valid-user |
| | 110 | </Location> |
| | 111 | </VirtualHost> |
| | 112 | |
| | 113 | }}} |
| | 114 | |
| | 115 | |
| | 116 | (for subdomains to work you would probably also need to alter /etc/hosts and add A-Records to your host's DNS.) |
| | 117 | |