This article will describe installing Trac which manages user with digest authentication.
Table of Contents
1 Install Trac
Run the following command just once.
1.1 Install trac and apache2-mod_wsgi
Install trac with Fedora 25's src.rpm.
$ sudo zypper -n in rpm-build $ F25=https://dl.fedoraproject.org/pub/fedora/linux/releases/25 $ wget -q ${F25}/Everything/source/tree/Packages/t/trac-1.0.13-1.fc25.src.rpm $ rpm -i trac-1.0.13-1.fc25.src.rpm $ cd ~/rpmbuild $ sudo zypper -n in $(rpmspec -q SPECS/trac.spec --buildrequires) $ rpmbuild -ba SPECS/trac.spec $ sudo zypper -n in RPMS/noarch/trac-1.0.13-1.noarch.rpm $ cd ..
Install apache2-mod_wsgi.
$ sudo zypper -n in apache2-mod_wsgi
Enable Apache2.
$ sudo systemctl enable apache2
1.2 Enable auth_digest
Enable auth_digest.
$ sudo a2enmod auth_digest
1.3 Open 80/tcp port
Open 80/tcp port for apache.
$ firewall_open_service() { for t in FW_CONFIGURATIONS_EXT FW_CONFIGURATIONS_DMZ FW_CONFIGURATIONS_INT; do sudo sed -e "s/^${t}=\"\(.*\)\"/${t}=\"\1 $1\"/g" \ -i /etc/sysconfig/SuSEfirewall2 done sudo systemctl restart SuSEfirewall2 } $ firewall_open_service apache2
1.4 Create project root directory
Create project root directory which has project directories.
$ sudo mkdir /var/lib/trac $ sudo mkdir -p /var/www/html/trac $ sudo chown wwwrun:www /var/www/html/trac
2 Create project
Run the following command for each project.
2.1 Create project directory
Create project directory.
$ sudo trac-admin /var/lib/trac/test initenv test sqlite:db/trac.db $ sudo trac-admin /var/lib/trac/test deploy /var/www/html/trac/test $ sudo chown -R wwwrun:www /var/lib/trac/test $ sudo chown -R wwwrun:www /var/www/html/trac/test
2.2 Create user
Create admin user.
$ sudo htdigest2 -c /var/lib/trac/test/.htdigest "test" admin Adding user admin in realm test New password: Re-type new password: $ sudo trac-admin /var/lib/trac/test permission add admin TRAC_ADMIN
Create user. Run htdigest command without -c option.
$ sudo htdigest2 /var/lib/trac/test/.htdigest "test" hiroom2 Adding user hiroom2 in realm test New password: Re-type new password:
2.3 Create Apache2 conf
Create Apache2 conf for project.
$ sudo su -c ' cat <<EOF > /etc/apache2/conf.d/test.conf WSGIScriptAlias /trac/test /var/www/html/trac/test/cgi-bin/trac.wsgi <Location /trac/test> AuthType Digest AuthName "test" AuthUserFile /var/lib/trac/test/.htdigest Require valid-user </Location> EOF '
Restart Apache2.
$ sudo systemctl restart apache2
3 Access to Trac
Access the following URL with browser.
http://<server>/trac/test
The dialog of digest authentication is displayed.
Trac page is displayed.
4 Script for installing Trac
The following script will install Trac automatically.
#!/bin/sh firewall_open_service() { for t in FW_CONFIGURATIONS_EXT FW_CONFIGURATIONS_DMZ FW_CONFIGURATIONS_INT; do sudo sed -e "s/^${t}=\"\(.*\)\"/${t}=\"\1 $1\"/g" \ -i /etc/sysconfig/SuSEfirewall2 done sudo systemctl restart SuSEfirewall2 } install_trac() { sudo zypper -n in rpm-build F25=https://dl.fedoraproject.org/pub/fedora/linux/releases/25 wget -q ${F25}/Everything/source/tree/Packages/t/trac-1.0.13-1.fc25.src.rpm rpm -i trac-1.0.13-1.fc25.src.rpm cd ~/rpmbuild sudo zypper -n in $(rpmspec -q SPECS/trac.spec --buildrequires) rpmbuild -ba SPECS/trac.spec sudo zypper -n in RPMS/noarch/trac-1.0.13-1.noarch.rpm cd .. sudo zypper -n in apache2-mod_wsgi sudo a2enmod auth_digest sudo systemctl enable apache2 firewall_open_service apache2 sudo mkdir /var/lib/trac sudo mkdir -p /var/www/html/trac sudo chown wwwrun:www /var/www/html/trac } TMP=`mktemp -t linux-trac.sh.XXXXXX` trap "rm $TMP* 2>/dev/null" 0 sudo zypper -n in expect create_digest() { filename=$1 realm=$2 username=$3 password=$4 options= if [ ! -f ${filename} ]; then options=-c fi cat <<EOF > ${TMP} set timeout -1 spawn sudo htdigest2 ${options} ${filename} ${realm} ${username} expect "New password: " send "${password}\n" expect "Re-type new password: " send "${password}\n" expect eof EOF expect ${TMP} } ADMIN_PASSWORD="trac" USER_PASSWORD="trac" create_test_project() { sudo trac-admin /var/lib/trac/test initenv test sqlite:db/trac.db sudo trac-admin /var/lib/trac/test deploy /var/www/html/trac/test sudo chown -R wwwrun:www /var/lib/trac/test sudo chown -R wwwrun:www /var/www/html/trac/test create_digest /var/lib/trac/test/.htdigest "test" admin ${ADMIN_PASSWORD} sudo trac-admin /var/lib/trac/test permission add admin TRAC_ADMIN create_digest /var/lib/trac/test/.htdigest "test" hiroom2 ${USER_PASSWORD} sudo su -c ' cat <<EOF > /etc/apache2/conf.d/test.conf WSGIScriptAlias /trac/test /var/www/html/trac/test/cgi-bin/trac.wsgi <Location /trac/test> AuthType Digest AuthName "test" AuthUserFile /var/lib/trac/test/.htdigest Require valid-user </Location> EOF ' sudo systemctl restart apache2 } install_trac create_test_project