Changes between Version 10 and Version 11 of PostgresqlRecipe
- Timestamp:
- Feb 22, 2015, 5:17:58 PM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
PostgresqlRecipe
v10 v11 1 == Recipe Installing Trac with PostgreSQL on CentOS4.2 == 2 3 4 HOWTO: 5 Install trac-0.9.4 on Centos4.2 (RH-ES4) with PostgreSQL-8.1.3 using psycopg2-2. 6 7 You should refer to the trac documentation wiki for current details respecting installing trac at [wiki:TracInstall]. 8 9 The instructions that follow are more detailed but the details are likely to date swiftly. 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. 10 6 11 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. … … 13 9 1. Verify that Python is installed and note the version; 14 10 15 16 {{{ 17 # 11 {{{ 18 12 # rpm -qa python # should report something like: 19 13 python-2.3.4-14.1. 20 #21 22 14 }}} 23 15 24 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. 25 17 26 27 {{{ 28 # 18 {{{ 29 19 # cd ~/software 30 20 # curl http://subversion.tigris.org/downloads/subversion-1.3.0.tar.gz > subversion-1.3.0.tar.gz … … 35 25 # ./configure 36 26 ... 37 38 }}} 39 40 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 27 }}} 28 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 41 30 not cover this eventuality here. 42 31 43 44 {{{ 45 ... 32 {{{ 46 33 # <optional build and install of subversion> 47 34 ... … … 51 38 }}} 52 39 53 54 40 3. Verify that subversion is installed, configured, and running: 55 56 41 57 42 {{{ … … 63 48 }}} 64 49 65 66 67 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. 68 51 69 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. 70 71 72 {{{ 73 # 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 {{{ 74 55 # cd ./software 75 56 # curl curl http://initd.org/pub/software/psycopg/psycopg2-2.0b8.tar.gz > psycopg2-2.0b8.tar.gz … … 79 60 # more INSTALL 80 61 # python setup.py install 81 # 82 }}} 83 62 }}} 84 63 85 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. 86 65 87 88 {{{ 89 # 66 {{{ 90 67 # cd ~/software 91 68 # curl http://ftp.edgewall.com/pub/trac/trac-0.9.4.tar.gz > trac-0.9.4.tar.gz … … 96 73 }}} 97 74 98 99 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: 100 76 101 102 {{{ 103 ... 77 {{{ 104 78 # python ./setup.py install 105 #106 107 79 }}} 108 80 109 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: 110 82 111 112 {{{ 113 # 83 {{{ 114 84 # export PYTHONPATH=/usr/local/lib/svn-python 115 # 116 }}} 117 118 119 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: 120 121 /usr/local/lib/svn-python 122 123 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: 124 125 126 {{{ 127 # 85 }}} 86 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 {{{ 128 94 # python 129 95 Python 2.3.4 (#1, Feb 22 2005, 04:09:37) … … 138 104 '/usr/lib/python2.3/site-packages/gtk-2.0'] 139 105 >>><ctrl>D 140 # 141 }}} 142 106 }}} 143 107 144 108 Placing 'trac_svn.pth' in '/usr/lib/python2.3/site-packages' seems to me the best solution. 145 109 146 147 {{{ 148 # 110 {{{ 149 111 # echo /usr/local/lib/svn-python > /usr/lib/python2.3/site-packages/trac_svn.pth 150 #151 112 # cat /usr/lib/python2.3/site-packages/trac_svn.pth 152 113 /usr/local/lib/svn-python … … 164 125 '/usr/lib/python2.3/site-packages/gtk-2.0', '/usr/local/lib/svn-python'] 165 126 >>><ctrl>D 166 # 167 }}} 168 169 170 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. 171 172 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: 173 174 175 {{{ 176 # 127 }}} 128 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 {{{ 177 134 # trac-admin /path/to/trac_project_env initenv 178 # 179 }}} 180 135 }}} 181 136 182 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". 183 138 184 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). 185 186 187 {{{ 188 # 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 {{{ 189 142 # createuser --username <postgres user with CREATEROLE permission> \ 190 143 # --password --pwprompt --createdb --createrole --echo \ 191 144 # <trac_DB_admin_user_name> 192 # 193 }}} 194 145 }}} 195 146 196 147 Example: 197 148 198 199 {{{ 200 # 149 {{{ 201 150 # createuser --username superuser --password --pwprompt --createdb --createrole --echo trac_db_admin 202 151 Enter password for new role: … … 207 156 CREATEROLE INHERIT LOGIN; 208 157 CREATE ROLE 209 # 210 }}} 211 212 213 The first set of password prompts are used to set the password for the new 214 role being created. The second set is to authenticate the database connection. Read the man(1) page for createuser for further information and options. 158 }}} 159 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. 215 161 216 162 ''Debian Note'' … … 220 166 Next, create the database you wish to use using the new role just established: 221 167 222 223 {{{ 224 # 168 {{{ 225 169 # createdb [--host localhost] --username <trac_DB_admin_user_name> --password \ 226 170 # --owner <trac_DB_admin_user_name> --echo -E UTF8 <trac_DB_name> 227 # 228 }}} 229 171 }}} 230 172 231 173 Example: 232 174 233 234 {{{ 235 # 175 {{{ 236 176 # createdb --host localhost --username trac_db_admin --password --owner trac_db_admin --echo -E UTF8 trac_db 237 177 Password: 238 178 CREATE DATABASE trac_db OWNER trac_db_admin; 239 179 CREATE DATABASE 240 # 241 }}} 242 180 }}} 243 181 244 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. … … 252 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. 253 191 254 255 {{{ 256 # 192 {{{ 257 193 # trac-admin /var/data/trac initenv 258 194 Creating a new Trac environment at /var/data/trac … … 356 292 /var/data/trac/conf/trac.ini 357 293 358 If you'd like to take this new project environment for a test drive, 359 try running the Trac standalone web server `tracd`: 294 If you'd like to take this new project environment for a test drive, try running the Trac standalone web server `tracd`: 360 295 361 296 # tracd --port 8000 /var/data/trac 362 297 363 Then point your browser to http://localhost:8000/trac. 364 There you can also browse the documentation for your installed 365 version of Trac, including information on further setup (such as 366 deploying Trac to a real web server). 367 368 The latest documentation can also always be found on the project 369 website: 298 Then point your browser to `http://localhost:8000/trac`. There you can also browse the documentation for your installed version of Trac, including information on further setup (such as deploying Trac to a real web server). 299 300 The latest documentation can also always be found on the project website: 370 301 371 302 http://projects.edgewall.com/trac/ … … 375 306 }}} 376 307 377 378 Trac is now installed and available. You can test it out using tracd. 379 380 # 308 Trac is now installed and available. You can test it out using tracd. 309 310 {{{ 381 311 # tracd --port <port-number> /var/data/trac 382 # 312 }}} 383 313 384 314 Example: 385 315 386 387 388 {{{ 389 # 316 {{{ 390 317 # tracd --port 3000 /var/data/trac 391 318 brms-02.brockley.harte-lyne.ca - - [06/Mar/2006 14:13:10] "GET / HTTP/1.1" … … 415 342 brms-02.brockley.harte-lyne.ca - - [06/Mar/2006 14:13:12] "GET 416 343 /trac/chrome/common/extlink.gif HTTP/1.1" 200 - 417 418 }}} 419 420 Well, everything seems to work. 421 422 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] 344 }}} 345 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] 423 349 424 350 To find out more about trac-admin just run it: 425 351 426 427 {{{ 428 # 352 {{{ 429 353 # trac-admin /var/data/trac 430 354 Trac [/var/data/trac]> help … … 432 356 }}} 433 357 434 435 358 Or visit [wiki:TracAdmin] 436 359 437 360 More advanced customization is accomplished by modifying or replacing the stylesheets in .trac/templates. 438 361 439 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].440 441 This completes our broadcast day. For information on configuring Apache to run trac see [wiki:TracModPython] or for my specific [wiki:TracApacheRecipe].For alternative methods for installing on Red Hat type systems, particularly Fedora Core see [wiki:TracOnFedoraCore].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 [wiki:TracModPython] or for my specific [wiki:TracApacheRecipe]. For alternative methods for installing on Red Hat type systems, particularly Fedora Core see [wiki:TracOnFedoraCore]. 442 365 443 366 Regards,