Trac server installation on CentOS 6.4 with apache, MySQL and wsgi

The documentation on the Trac website is clear but I was on the wrong track trying to use fcgi on CentOS and to make that Trac server working. After couple of days of research this is my solution to install (migrate) the Trac server.

##Start with epel and remi repo installation##

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

##Enable remi repo

vi /etc/yum.repo.d/remi.repo

##Change first “enable=0” to “enable=1“;
## Because the previous server was using MySQL with utf8mb4 database, I had to install mysql 5.5
##Check first what version of mysql will be installed

yum info mysql-server

##Should be something like 5.5.xx
##Proceed with the installation

yum install mysql mysql-server php-xml php php-mysql MySQL-python python python-setuptools mod_wsgi -y

##Enable autostart for mysql and apache

chkconfig httpd on
chkconfig mysqld on

service mysqld start
service httpd start

##Because we use Trac on our internal network I have disabled the firewall and setup selinux as permissive. After the changes has been done Reboot the server.

chkconfig iptables off
service iptables stop

 ##Install Genshi and Trac. At the time of writing this tutorial the latest version of Trac was 1.0.1

easy_install Genshi
easy_install Trac==1.0.1

##Create the folder for your project

mkdir -p /trac/project1

##Create the project. As you can see I didn’t create the database r the user for Trac in MySQL so i will use the default Trac sqlite db

trac-admin /trac/project1 initenv

## Test your project

tracd –port 8000 /trac/project1

## On your browser type the ip address of the CentOS server. Should be something like xx.xx.xx.xxx:8000
 ##Create the wsgi file

trac-admin /trac/project1 deploy /trac/project1

##Configure authentication

sudo htpasswd -c /trac/htpasswd firstuser

##Create configuration file for apache

vi /etc/httpd/conf.d/trac.conf

##Add the following lines

WSGIScriptAlias /trac /trac/project1/cgi-bin/trac.wsgi
<Directory /trac>
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
</Directory>

<Location “/trac/login”>
    AuthType Digest
    AuthName “trac”
    AuthUserFile /trac/htpasswd
    Require valid-user
</Location>

##Create database, in my case import database; In order to be able to import the database with utf8mb4 you will have to create one database with utf8mb4. So proceed with the following steps.

CREATE DATABASE trac DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
GRANT ALL ON trac.* TO tracuser@localhost IDENTIFIED BY ‘password’;
FLUCH PRIVILEGES;

 ##Import the database from the old server

mysql trac < /trac/test1/trac.sql

##Enable Trac to communicate with your new created/imported database.

vi /trac/project1/conf/trac.ini

##Change

sqlite:db/trac.db

##to

mysql://tracuser:password@localhost/trac

##Change permissions on /trac to allow apache access

chown apache:apache -R /trac

 ##Restart apache server and check you browser at the address xx.xx.xx.xx/trac

service httpd restart

Hope will work as it worked for me. 🙂

Leave a Reply

Time limit is exhausted. Please reload the CAPTCHA.