Monday, May 31, 2010

Trac Installation On Linux!

Step by Step Installation of Trac on Linux:

Genshi Installation
---------------------------
python setup.py install

install setuptools

python setup.py build install (Trac Installation)

install svn

-----------------------------------

Now Install Mysql-python
$ tar -xfz MySQL-python-1.2.1.tar.gz
$ cd MySQL-python-1.2.1
$ # edit site.cfg if necessary
$ python setup.py build
$ sudo python setup.py install # or su first

If the error comes likes this during building:
error: command 'gcc' failed with exit status 1
then install the python-dev library.......
root@term146:~/Desktop/MySQL-python-1.2.2# sudo apt-get install python-dev


Install additional libraries like neon, neon-devel, python-devel, swig (Simplified Wrapper and Interface Generator)

After the installation, you have to setup the trac Environment Directory. For that create a folder any where in you system.
(mkdir myenv) and give full permission to that environment (chmod -R 777 myenv)

To make this directory as your trac environment , use the following command.
trac-admin /path/to/myenv initenv

It will ask for name of your project, mysql connection string, type of subverstion, repository path, and template of your trac.
1) Provide a name for your project
2) If you are not using mysql, the trac by default use Sqlite database . Just enter the option for blank

-----------------------------------
FOR MySQL:

A proper database can be created with any MySQL client, like this:

CREATE DATABASE trac DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
To check character set settings for your database, issue the following commands:

mysql> USE trac;
Database changed

mysql> SHOW VARIABLES WHERE variable_name IN ('character_set_database', 'collation_database');
+------------------------+----------+
| Variable_name | Value |
+------------------------+----------+
| character_set_database | utf8 |
| collation_database | utf8_bin |
+------------------------+----------+
2 rows in set (0.01 sec)

To create a user and give this user access to the database created above:

GRANT ALL ON trac.* TO tracuser@localhost IDENTIFIED BY 'password';
The connection string will then be:

mysql://tracuser:password@localhost/trac

NOTE: If mysql socket is present at /tmp/mysql.sock then create the symbolic link as--

ncra@localhost:3306 root aksncra /tmp/mysql.sock
because trac will take the Connection String from /var/lib/mysql/mysql.sock
----------------------------------------------------------

3) Enter type of subversion there. Just type ’svn’ if you are using svn subversion.

4) Enter the path to your repository

4. Tell Apache about trac.. Add the following lines to your Apache configuration file:

SetHandler mod_python
PythonHandler trac.web.mod python_frontend
PythonOption TracEnv $pathtoyourtracproject
PythonOption TracUriRoot /trac

BUT FOR MULTIPLE PROJECTS..........

SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /usr/local/trac/
PythonOption TracUriRoot /trac

Finally, restart httpd and try it out by going to:

http://$yourhost/trac/

5. Edit Trac.ini

6. trac-admin /usr/local/..... resync



************************************************

SETTING UP OF AUTHENTICATION TRAC WITH APACHE2

************************************************

Adding Authentication

To enable authentication with Apache is to create a password file. Use the htpasswd program to create the password file:

$ htpasswd -c /somewhere/trac.htpasswd admin
New password:
Re-type new password:
Adding password for user admin
After the first user, you dont need the "-c" option anymore:

$ htpasswd /somewhere/trac.htpasswd akshat
New password:
Re-type new password:
Adding password for user akshat

Now we can set their permissions using TracPermissions.
========================================
Now, you'll need to enable authentication against the password file in the Apache configuration:

AuthType Basic
AuthName "Trac"
AuthUserFile /somewhere/trac.htpasswd
Require valid-user
If you're hosting multiple projects you can use the same password file for all of them:

AuthType Basic
AuthName "Trac"
AuthUserFile /somewhere/trac.htpasswd
Require valid-user

For better security enable SSL or use the “digest” authentication instead of “Basic”.

LoadModule auth_digest_module /usr/lib/apache2/modules/mod_auth_digest.so
AuthType Digest
AuthName "trac"
AuthDigestDomain /trac
AuthUserFile /somewhere/trac.htpasswd
Require valid-user
and you'll have to create your .htpasswd file with htdigest instead of htpasswd as follows:

# htdigest /somewhere/trac.htpasswd trac admin
where the "trac" is the Realm.

=============
Web Admin Plugin
=============
This plugin is for administering Trac projects through the web interface.

Note: Don't forget to give permissions to your user.

trac-admin /path/to/my/project
permission add username-from-htpasswd TRAC_ADMIN
permission list username-from-htpasswd

E.g.:
Trac [/usr/local/trac/GMRTArchive]> permission add /usr/local/trac/trac.htpasswd/akshat TRAC_ADMIN
Trac [/usr/local/trac/GMRTArchive]> permission list akshat
-----> Add permission for each user and each project to have Admin Tab.............


********************
Graphical Admin Tab
********************

To access this tab, a user must have TRAC_ADMIN privileges. This can be performed as follows:

$ trac-admin /path/to/projenv permission add akshat TRAC_ADMIN
E.g. trac-admin -c /usr/local/trac/IYA2009/ permission add admin TRAC_ADMIN
-----> Add permission for each user and each project to have Admin Tab.............
Then, the user akshat will be able to see the Admin tab, and can then access the permissions menu. This menu will allow you to perform all the following actions, but from the browser without requiring root access to the server (just the correct permissions for your user account).


********************
TracAccountManager
********************

A user account management plugin for Trac.

== Installation ==
1. Run: python setup.py bdist_egg
2. If necessary create a folder called "plugins" in your Trac environment.
3. Copy the .egg file from the dist folder created by step 1 into the "plugins"
directory of your Trac environment.

== Configuration ==
Add one of the following sections to trac.ini to manage an Apache htpasswd or
htdigest file.

=== Htpasswd ===
[account-manager]
password_format = htpasswd
password_file = /path/to/trac.htpasswd

=== Htdigest ===
[account-manager]
password_format = htdigest
password_file = /path/to/trac.htdigest
htdigest_realm = TracDigestRealm

=====================
LDAP Authentication for Trac
=====================

VirtualHost *>
ServerAdmin webmaster@localhost
ServerName trac.example.com
DocumentRoot /var/www
ErrorLog /var/log/apache2/error.trac.log
CustomLog /var/log/apache2/access.trac.log combined

SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /usr/local/trac
PythonOption TracUriRoot /trac
PythonOption PYTHON_EGG_CACHE /tmp

# use the following for one authorization for all projects
# (names containing "-" are not detected):
AuthType Basic
AuthName "Authorization Required for NCRA-TIFR Trac"
AuthBasicProvider ldap
AuthLDAPURL "ldap://localhost:389/ou=people,o=ncra,c=in?uid"
AuthLDAPGroupAttribute memberUid
AuthLDAPGroupAttributeIsDN off
AuthzLDAPAuthoritative on
Require valid-user

No comments:

Post a Comment