Ubuntu 16.04: Install Trac

This article will describe installing Trac which manages user with digest authentication.

1 Install trac

Install trac with apt.

$ sudo apt install -y trac libapache2-mod-wsgi

2 Create project

Create root directory for projects.

$ sudo mkdir /var/lib/trac

Create project and deploy to /var/www/html.

$ sudo trac-admin /var/lib/trac/test initenv test sqlite:db/trac.db
$ sudo trac-admin /var/lib/trac/test deploy /var/www/html/test
$ sudo chown -R www-data:www-data /var/lib/trac/test
$ sudo chown -R www-data:www-data /var/www/html/test

3 Add user

Add admin user.

$ sudo htdigest -c /var/lib/trac/.test_htdigest "test" admin
Adding password for admin in realm test.
New password:
Re-type new password:
$ sudo trac-admin /var/lib/trac/test permission add admin TRAC_ADMIN

Add normal user. Run htdigest without -c option because password file is already created.

$ sudo htdigest /var/lib/trac/.test_htdigest "test" hiroom2
Adding password for admin in realm test.
New password:
Re-type new password:

4 Apache2

Create site file for project.

$ sudo su -c '
cat <<EOF > /etc/apache2/sites-available/test.conf
WSGIScriptAlias /test /var/www/html/test/cgi-bin/trac.wsgi
<Location /test>
  AuthType Digest
  AuthName "test"
  AuthUserFile /var/lib/trac/.test_htdigest
  Require valid-user
</Location>
EOF
'

Enable site file and auth_digest. Restart Apache2.

$ sudo a2ensite test
$ sudo a2enmod auth_digest
$ sudo systemctl restart apache2

5 Access to Trac

Access the following URL with browser.

http://<server>/test

The dialog of digest authentication is displayed.

0001_digest.png

Trac page is displayed.

0002_trac.png