Deploying Trac using Python Selector

Navigation:  Python and Ruby Selector >

Deploying Trac using Python Selector

Previous pageReturn to chapter overviewNext page

1. In Setup Python App create an application. Trac project WSGI script will be located in App Directory (e.g. trac).

 

App URI – is a URL where web-interface is located. (e.g. Trac – web-interface is located in YOUR_DOMAIN/trac).

 

Trac needs Python version from 2.5 to 3.0, in actual example version 2.7 is used.

 

2. When the App is created, add the following modules: Trac, Genshi, MySQL-python.

 

2.1. Alternatively connect to the server via SSH and perform the following steps:

 

source ~/virtualenv/trac/2.7/bin/activate;

 

then:

 

~/virtualenv/trac/2.7/bin/easy_install Trac mysql-python (using easy_install);

 

or

 

~/virtualenv/trac/2.7/bin/pip install trac mysql-python  (using pip).

 

3. In cPanel create MySQL database and a user. Add user to database.

 

trac1

In this example DB tractest_trac and user tractest_trac were created.

 

4. Connect to the server via SSH using your cPanel account.

 

Create Trac project:

~/virtualenv/trac/2.7/bin/trac-admin  ~/trac_project initenv

 

For "Database connection string" parameter enter the following: mysql://user:[email protected]/database_name – here the data for connecting MySQL database are specified.

         

Note. In case of "... The charset and collation of database are 'latin1' and 'latin1_swedish_ci' error the database must be created with one of (('utf8', 'utf8_bin'), ('utf8mb4', 'utf8mb4_bin')) ..."  while creating the project, you should change database encoding.

 

To change encoding, in cPanel run phpMyAdmin, choose DB, go to Operations, choose the necessary encoding in Collation section and click Go.

 

trac2

 

After that you have to repeat the procedure of creating a project. When done, the Trac project must appear: ~/trac_project

 

5. To create project frontend run the following:

 

~/virtualenv/trac/2.7/bin/trac-admin ~/track_project deploy ~/trac

 

~/track_project — is the path to the project,

~/trac — is the path, that was specified while setting App Directory.

 

Create topic directory by default:

 

cd ~/public_html/trac

 

mkdir chrome

cp -R ~/trac/htdocs/ ~/public_html/trac/chrome/ - all project static files are located in this directory; the changes can be added here as well.

 

6. To add path to WSGI file in created application:

 

Go back to cPanel Setup Python App, change “WSGI file location” for your application to cgi-bin/trac.wsgi, click Update to apply changes and then click Restart.

 

Your Existing application now must look like the following:

 

trac3

 

7. Adding authorization:

 

In ~/public_html/trac/.htaccess after CLOUDLINUX PASSENGER CONFIGURATION section add the following lines:

 

AuthType Basic

AuthName "trac"

AuthUserFile /home/tractest/trac/passwd

Require valid-user

 

8. Add new user and create passwd file /usr/local/apache/bin/htpasswd with ~/trac/passwd admin.

 

Enter password.

 

~/virtualenv/trac/2.7/bin/trac-admin  ~/track_project permission add admin TRAC_ADMIN

 

Add admin user to TRAC_ADMIN group.

 

Here the path trac directory is equal to App Directory in your project.

 

Now Trac is available via YOUR_DOMAIN/trac.