Install Trac
# install trac package from Ubuntu repo
sudo apt-get install trac
# init the project files
sudo mkdir -p /var/trac/myproject
cd /var/trac/myproject
sudo trac-admin . initenv
# basic authentication
sudo apt-get install apache2-utils
sudo htpasswd -c .htpasswd adminusername
sudo trac-admin . permission add adminusername TRAC_ADMIN
# folder permissions
sudo chown -R www-data: .
sudo chmod -R 775 .
cp wsgi_trac.py -> /var/trac/myproject/
import os
import sys
import trac.web.main
sys.stdout=sys.stderr
os.environ['TRAC_ENV'] = '/var/trac/myproject'
application = trac.web.main.dispatch_request
cp to /etc/nginx/sites-enabled/trac.conf or add to /etc/nginx/nginx.conf
server {
listen 80;
server_name trac.local;
location / {
auth_basic_user_file /var/trac/myproject/.htpasswd;
auth_basic 'this is not for you';
uwsgi_param REMOTE_USER $remote_user;
include uwsgi_params;
uwsgi_pass 127.0.0.1:5544;
}
}
cp trac_uwsgi.ini -> /etc/uwsgi/apps-enabled/
[uwsgi]
uid=trac
gid=tracsys
chmod-socket=777
chown-socket=trac
chdir = /var/trac/myproject
socket = 127.0.0.1:5544
module = wsgi_trac:application
processes = 2
master = 1
restart the services
sudo service nginx restart && sudo service uwsgi restart
Credits: dev-smart, habrahabr.
P.S. Don’t forget about Nginx uwsgi_param REMOTE_USER for authentication to work.
I spent a lot of nerves fixing Trac Error: Authentication information not available 🙂