Edgewall Software

Changes between Version 13 and Version 14 of PostgresqlRecipe


Ignore:
Timestamp:
Nov 8, 2017, 9:16:00 PM (6 years ago)
Author:
figaro
Comment:

Further cosmetic changes

Legend:

Unmodified
Added
Removed
Modified
  • PostgresqlRecipe

    v13 v14  
    1 = Recipe: Installing Trac with PostgreSQL on CentOS4.2
    2 
    3 This is a howto on installing Trac-0.9.4 on Centos-4.2 (RH-ES4) with PostgreSQL-8.1.3 using psycopg2-2.
    4 
    5 You should refer to the Trac documentation wiki at [wiki:TracInstall]. The instructions that follow are more detailed but the details are likely to date swiftly.
    6 
    7 These instructions assume that you have superuser access to both the operating system and postgresql as required.  If this is not the case then some of these activities must be performed on your behalf by a user with those privileges.  I do not attempt to systematically identify those tasks that require superuser capability.
    8 
    9 1.  Verify that Python is installed and note the version;
    10 
    11 {{{
     1= Recipe: Installing Trac with PostgreSQL on CentOS-4.2
     2
     3This is a how-to on installing Trac-0.9.4 on Centos-4.2 (RH-ES4) with PostgreSQL-8.1.3 using psycopg2-2.
     4
     5You should refer to the Trac documentation wiki at [wiki:TracInstall]. The instructions that follow are more specific to the given setup.
     6
     7These instructions assume that you have superuser access to both the operating system and Postgresql as required. If this is not the case, then some of these activities must be performed on your behalf by a user with those privileges. 
     8
     91. Verify that Python is installed and note the version:
     10
     11 {{{
    1212# rpm -qa python                # should report something like:
    1313python-2.3.4-14.1.
    1414}}}
    1515
    16 2.  You will require the swig-py bindings for trac.  These must be built from the subversion source distribution. Note that as of subversion-1.2 the swig sources themselves are not required to build the python bindings.
    17 
    18 {{{
     162. You will require the swig-py bindings for Trac. These must be built from the subversion source distribution. Note that as of subversion-1.2 the swig sources themselves are not required to build the Python bindings.
     17
     18 {{{
    1919# cd ~/software
    2020# curl http://subversion.tigris.org/downloads/subversion-1.3.0.tar.gz >  subversion-1.3.0.tar.gz
     
    2727}}}
    2828
    29 At this point, if you have a binary rpm of subversion >= 1.2 already installed then you just need to make the swig bindings for python. Otherwise, you need build and install subversion itself first. We will
    30 not cover this eventuality here.
    31 
    32 {{{
     29 At this point, if you have a binary rpm of subversion >= 1.2 already installed, then you just need to make the swig bindings for Python. Otherwise, you need build and install Subversion first. We will not cover this eventuality here.
     30
     31 {{{
    3332# <optional build and install of subversion>
    3433...
     
    3837}}}
    3938
    40 3.  Verify that subversion is installed, configured, and running:
    41 
    42 {{{
     393. Verify that subversion is installed, configured and running:
     40
     41 {{{
    4342# svn help
    4443usage: svn <subcommand> [options] [args]
     
    4847}}}
    4948
    50 4.  Obtain a postgresql adaptor for python. This HOWTO employs psycopg2 which is obtained from [http://initd.org/pub/software/psycopg]/. Other possibilites are psycopg1 and pyPgSQL.  Google is your friend here.
    51 
    52 5.  Using curl, ftp or wget from the command line, or http from your web-browser, download the adaptor source into a working directory on the target machine, expand the archives, build  and install the adaptor.
    53 
    54 {{{
     494. Obtain a Postgresql adaptor for Python. This how-to employs psycopg2 which is obtained from [http://initd.org/pub/software/psycopg]/. Other possibilities are psycopg1 and pyPgSQL.
     50
     515. Using curl, ftp or wget from the command line, or http from your web-browser, download the adaptor source into a working directory on the target machine, expand the archives, build  and install the adaptor:
     52
     53 {{{
    5554# cd ./software
    5655# curl curl http://initd.org/pub/software/psycopg/psycopg2-2.0b8.tar.gz > psycopg2-2.0b8.tar.gz
     
    6261}}}
    6362
    64 6.  Now get trac from [wiki:TracDownload]. Move to your working directory (cd ~/software) and download the trac distribution that you wish to use.
    65 
    66 {{{
     636. Get Trac from [wiki:TracDownload]. Go to your working directory (cd ~/software) and download the Trac distribution that you wish to use:
     64
     65 {{{
    6766# cd ~/software
    6867# curl http://ftp.edgewall.com/pub/trac/trac-0.9.4.tar.gz > trac-0.9.4.tar.gz
     
    7372}}}
    7473
    75 You will note in the INSTALL notes the requirements for the subversion swig-py bindings and clearsilver. As detailed above, the former must be built locally from the subversion source distribution while the second can be obtained as an rpm for Red Hat EL-4 from [http://dag.wieers.com/packages/clearsilver/]. If all of the prerequisites are met then install trac:
     74 You will note in the INSTALL notes the requirements for the Subversion swig-py bindings and Clearsilver. As detailed above, the former must be built locally from the subversion source distribution while the second can be obtained as an rpm for Red Hat EL-4 from [http://dag.wieers.com/packages/clearsilver/]. If all of the prerequisites are met, then install Trac:
    7675 
    77 {{{
     76 {{{
    7877# python ./setup.py install
    7978}}}
    8079
    81 7.  The utiltiy trac-admin is used to setup trac environments and to configure the environment thereafter.  On Centos4 the trac bindings are installed by default beneath "/usr/local/lib/svn-python" which must be added to the python load path. This can be done through the environment variable PYTHONPATH:
    82 
    83 {{{
     807. The utility trac-admin is used to setup Trac environments and to configure the environment thereafter. On Centos4 the Trac bindings are installed by default beneath "/usr/local/lib/svn-python" which must be added to the Python load path. This can be done through the environment variable PYTHONPATH:
     81
     82 {{{
    8483# export PYTHONPATH=/usr/local/lib/svn-python
    8584}}}
    8685
    87 and adding a similar Apache httpd.conf `SetEnv` directive inside the relevent location. Alternatively, one can create a file called trac_svn.pth containing a single line:
    88 
    89 `/usr/local/lib/svn-python`
    90 
    91 and place this somewhere in python's default load path. The file name is not important, but the .pth extension is. You can determine the default path thus:
    92 
    93 {{{
     86 and adding a similar Apache httpd.conf `SetEnv` directive inside the relevant location. Alternatively, one can create a file called trac_svn.pth containing a single line:
     87
     88 `/usr/local/lib/svn-python`
     89
     90 and place this somewhere in Python's default load path. The file name is not important, but the .pth extension is. You can determine the default path thus:
     91
     92 {{{
    9493# python
    9594Python 2.3.4 (#1, Feb 22 2005, 04:09:37)
     
    106105}}}
    107106
    108 Placing 'trac_svn.pth' in '/usr/lib/python2.3/site-packages' seems to me the best solution.
    109 
    110 {{{
     107 Placing 'trac_svn.pth' in '/usr/lib/python2.3/site-packages' seems to me the best solution.
     108
     109 {{{
    111110# echo /usr/local/lib/svn-python > /usr/lib/python2.3/site-packages/trac_svn.pth
    112111# cat /usr/lib/python2.3/site-packages/trac_svn.pth
     
    127126}}}
    128127
    129 We can see that /usr/local/lib/svn-python has been added to python's search path. The only thing to note is that a version upgrade of python will require that we move trac_svn.pth to the new site-packages directory. Now trac-admin, apache and tracd should all find the necessary bindings and run without any further ado.
    130 
    131 8.  At this point everything is wired up and ready to go with tracd as the server and SQLite3 as the backend database. You can create your first trac environment by issuing the following command:
    132 
    133 {{{
     128 We can see that /usr/local/lib/svn-python has been added to Python's search path. Note that a version upgrade of Python will require that we move trac_svn.pth to the new site-packages directory. Now trac-admin, apache and tracd should all find the necessary bindings and run without any further ado.
     129
     1308. At this point everything is wired up and ready to go with tracd as the server and SQLite3 as the backend database. You can create your first Trac environment:
     131
     132 {{{
    134133# trac-admin /path/to/trac_project_env initenv
    135134}}}
    136135
    137 You must answer the questions regarding the database connection and subversion repository. To use a different DB backend you must first initialize the alternative database environment before runing "trac-admin /path/to/trac_project_env initenv". 
    138 
    139 9.  To use postgresql as the backend one must first setup a target database user and a database instance to pass to trac-admin when it asks for a connection string. The postgresql command line utilities for this are createuser(1) and createdb(1).
    140 
    141 {{{
     136 You must answer the questions regarding the database connection and subversion repository. To use a different database backend you must first initialize the alternative database environment before running "trac-admin /path/to/trac_project_env initenv". 
     137
     1389. To use Postgresql as the database backend you must first setup a target database user and a database instance to pass to trac-admin when it asks for a connection string. The postgresql command line utilities for this are createuser(1) and createdb(1).
     139
     140 {{{
    142141# createuser --username <postgres user with CREATEROLE permission> \
    143142#   --password --pwprompt --createdb --createrole --echo \
     
    145144}}}
    146145
    147 Example:
    148 
    149 {{{
     146 Example:
     147
     148 {{{
    150149# createuser --username superuser --password --pwprompt --createdb --createrole --echo trac_db_admin
    151150Enter password for new role:
     
    158157}}}
    159158
    160 The first set of password prompts are used to set the password for the new role being created. The second set is to authenticate the database connection.  Read the man(1) page for createuser for further information and options.
    161 
    162 ''Debian Note''
    163 
    164 Please, note that a typical postgres authentication setup assumes that you connect to postgres database via the 'postgres' system user account for the first time using UNIX domain socket (the default) - see /etc/postgresql/8.x/main/pg_hba.conf
    165 
    166 Next, create the database you wish to use using the new role just established:
    167 
    168 {{{
     159 The first set of password prompts are used to set the password for the new role being created. The second set is to authenticate the database connection. Read the man(1) page for createuser for further information and options.
     160
     161 '''Debian note''': A typical postgresql authentication setup assumes that you connect to the postgresql database via the 'postgres' system user account for the first time using UNIX domain socket (the default) - see /etc/postgresql/8.x/main/pg_hba.conf
     162
     163 Next, create the database you wish to use using the new role just established:
     164
     165 {{{
    169166# createdb [--host localhost] --username <trac_DB_admin_user_name> --password \
    170167#   --owner <trac_DB_admin_user_name> --echo -E UTF8 <trac_DB_name>
    171168}}}
    172169
    173 Example:
    174 
    175 {{{
     170 Example:
     171
     172 {{{
    176173# createdb --host localhost --username trac_db_admin --password --owner trac_db_admin --echo -E UTF8 trac_db
    177174Password:
     
    180177}}}
    181178
    182 You have to provide the connection password again as above, but this time you use the password for trac_db_admin since this was used to establish the connection.  You can of course use any established postgresql user/role that has CREATEDB priviliges instead.
    183 
    184 ''Debian Note''
    185 
    186 Note the ''--host'' option - since 'trac_db_admin' is only a postgres database role it doesn't have a real system user counter part. Thus, you may not be able to connect via a Unix domain socket and have to use IPv4/6 socket (specified via --host). See the ''pga_hba.conf'' of your postgres configuration for details.
    187 
    188 10.  With trac and postgresql all set up you must now determine the absolute path to the subversion repostor(y/ies) that you wish to use with trac.  This is a manual task.  A typical repository path might look like "/var/data/svn" or "/var/svn".
    189 
    190 11.  With the information obtained above, the postgresql database name, the path to the trac directory, and the path to the subversion repository, we now invoke trac-admin to create the environment.
    191 
    192 {{{
     179 You have to provide the connection password again as above, but this time you use the password for trac_db_admin, since this was used to establish the connection. You can of course use any established postgresql user/role that has CREATEDB privileges instead.
     180
     181 '''Debian note''' : Note the ''--host'' option - since 'trac_db_admin' is only a postgresql database role it doesn't have a real system user counter part. Thus, you may not be able to connect via a Unix domain socket and have to use IPv4/6 socket (specified via --host). See the ''pga_hba.conf'' of your postgres configuration for details.
     182
     18310. With Trac and Postgresql all set up you must now determine the absolute path to the subversion repostor(y/ies) that you wish to use with Trac. This is a manual task. A typical repository path might look like "/var/data/svn" or "/var/svn".
     184
     18511. With the information obtained above, the postgresql database name, the path to the Trac directory, and the path to the subversion repository, we now invoke trac-admin to create the environment.
     186
     187 {{{
    193188# trac-admin /var/data/trac initenv
    194189Creating a new Trac environment at /var/data/trac
     
    306301}}}
    307302
    308 Trac is now installed and available. You can test it out using tracd.
    309 
    310 {{{
     303 Trac is now installed and available. You can test it out using tracd:
     304
     305 {{{
    311306# tracd --port <port-number> /var/data/trac
    312307}}}
    313308
    314 Example:
    315 
    316 {{{
     309 Example:
     310
     311 {{{
    317312# tracd --port 3000 /var/data/trac
    318313brms-02.brockley.harte-lyne.ca - - [06/Mar/2006 14:13:10] "GET / HTTP/1.1"
     
    344339}}}
    345340
    346 Everything seems to work.
    347 
    348 12.  You will now need to customize your trac installation to suite your project needs. Configuration is carried out through both the trac-admin command line interface (adding and removing trac users, adding, changing or removing priority and severity codes, adding and removing milestones, etc.) and by directly editing the .trac/conf/trac.ini file (setting email and default values for the web interface). See [wiki:TracIni]
    349 
    350 To find out more about trac-admin just run it:
    351 
    352 {{{
     341 Everything seems to work.
     342
     34312. You will now need to customize your Trac installation to suit your project needs. Configuration is carried out through both the trac-admin command line interface (adding and removing trac users, adding, changing or removing priority and severity codes, adding and removing milestones, etc.) and by directly editing the .trac/conf/trac.ini file (setting email and default values for the web interface). See [wiki:TracIni].
     344
     345 To find out more about trac-admin just run it:
     346
     347 {{{
    353348# trac-admin /var/data/trac
    354349Trac [/var/data/trac]> help
     
    356351}}}
    357352
    358 Or visit [wiki:TracAdmin]
    359 
    360 More advanced customization is accomplished by modifying or replacing the stylesheets in .trac/templates.
    361 
    362 13.  You WILL, at some point, wish to use trac plugins. To employ plugins you must install or upgrade setuptools for python.  The easiest way to do this is to obtain ez_setup.py from [http://peak.telecommunity.com/DevCenter/setuptools] and run it as root "#python ez_setup.py". You can get more information about plugins for trac  at [wiki:TracPlugins].
    363 
    364 This completes our broadcast day. For information on configuring Apache to run trac see TracModPython. For alternative methods for installing on Red Hat type systems, particularly Fedora Core see [wiki:TracOnFedoraCore].
    365 
    366 Regards,
    367 Jim
    368 
    369 ***     e-mail is NOT a secure channel     ***
    370 James B. Byrne                mailto:ByrneJB.<token>@Harte-Lyne.ca
    371 Harte & Lyne Limited          http://www.harte-lyne.ca
    372 9 Brockley Drive              vox: +1 905 561 1241
    373 Hamilton, Ontario             fax: +1 905 561 0757
    374 Canada  L8E 3CE               
     353 Or visit [wiki:TracAdmin].
     354
     355 More advanced customization is accomplished by modifying or replacing the stylesheets in .trac/templates.
     356
     35713. You will at some point wish to use Trac plugins. To employ plugins you must install or upgrade setuptools for Python. The easiest way to do this is to obtain ez_setup.py from [http://peak.telecommunity.com/DevCenter/setuptools] and run it as root "#python ez_setup.py". You can get more information about plugins for Trac at [wiki:TracPlugins].
     358
     359For information on configuring Apache to run Trac see TracModPython. For alternative methods for installing on Red Hat type systems, particularly Fedora Core see [wiki:TracOnFedoraCore].
     360
     361
     362* James B. Byrne                mailto:ByrneJB.<token>@Harte-Lyne.ca
     363* Harte & Lyne Limited          http://www.harte-lyne.ca
     364* 9 Brockley Drive              vox: +1 905 561 1241
     365* Hamilton, Ontario             fax: +1 905 561 0757
     366* Canada  L8E 3CE