Edgewall Software

Changes between Initial Version and Version 1 of Ubuntu-10.04-Bazaar


Ignore:
Timestamp:
Sep 28, 2010, 5:01:55 AM (14 years ago)
Author:
natewlew@…
Comment:

Added Ubuntu 10.04 install doc

Legend:

Unmodified
Added
Removed
Modified
  • Ubuntu-10.04-Bazaar

    v1 v1  
     1== Install Trac 0.12 with Bazaar ,MySQL and Mod_WSGI on Ubuntu 10.04 ==
     2
     3This tutorial describes how to install Trac 0.12 on Ubuntu 10.04. I assume this would work for and older ubuntu or Debian with minor modifications. It will use MySQL as the Database, Mod_WSGI as the apache module and Bazaar as Source Control (VCS).
     4
     5The tutorial assumes that your project will be called newproject.  If you are not familiar with vi you can change the vi commands to nano, joe or whatever you like. I do not make any guarantee this will work for you.
     6
     7Install a base ubuntu server (this should work for a desktop install as well). I selected ssh during install so I could get into the machine.
     8
     9* Update the System:
     10
     11{{{
     12sudo apt-get update && sudo apt-get upgrade
     13}}}
     14
     15{{{
     16sudo reboot
     17}}}
     18
     19* Install base packages:
     20
     21{{{
     22sudo apt-get install apache2 libapache2-mod-wsgi python-setuptools python-genshi mysql-server python-mysqldb bzr
     23}}}
     24
     25* (optional):
     26
     27{{{
     28sudo apt-get install python-pybabel python-docutils python-pygments python-tz
     29}}}
     30
     31   Enter MySQL root password during mysql install.
     32
     33* Install Trac:
     34
     35{{{
     36sudo easy_install Trac==0.12
     37}}}
     38
     39   This will also install a Geshi egg
     40
     41* Setup Database. Log into MySQL:
     42
     43{{{
     44mysql -u root -pyourpassword
     45}}}
     46
     47* Once logged in, run these mysql commands:
     48
     49{{{
     50CREATE DATABASE trac DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
     51}}}
     52
     53* Create MySQL Password:
     54
     55{{{
     56GRANT ALL ON trac.* TO tracuser@localhost IDENTIFIED BY 'yourpassword';
     57}}}
     58
     59   Change yourpassword to whatever you want the password to be.
     60
     61{{{
     62exit
     63}}}
     64
     65* Create a Project:
     66
     67   I am going to put the trac projects under /var/tracprojects/. The name of the new project is newproject.
     68
     69{{{
     70sudo mkdir /var/tracprojects
     71}}}
     72
     73{{{
     74sudo mkdir /var/tracprojects/newproject
     75}}}
     76
     77{{{
     78sudo trac-admin /var/tracprojects/newproject initenv
     79}}}
     80
     81{{{
     82Project Name [My Project]> newproject (press enter)
     83}}}
     84
     85{{{
     86Database connection string [sqlite:db/trac.db]> mysql://tracuser:yourpassword@localhost/trac (press enter)
     87}}}
     88
     89   Now we need to convert the mysql tables to INNODB
     90
     91* Log back into mysql:
     92
     93{{{
     94mysql -u root -pyourpassword
     95}}}
     96
     97{{{
     98USE trac;
     99}}}
     100
     101{{{
     102SELECT table_name, engine FROM information_schema.tables WHERE table_schema=DATABASE();
     103}}}
     104
     105If the engine is MYISAM it must be converted.
     106
     107* Run the folowing mysql commands on the trac database as one command and press enter at the end to complete the statments:
     108
     109{{{
     110ALTER TABLE `attachment` ENGINE = InnoDB; \
     111ALTER TABLE `auth_cookie` ENGINE = InnoDB; \
     112ALTER TABLE `cache` ENGINE = InnoDB; \
     113ALTER TABLE `component` ENGINE = InnoDB; \
     114ALTER TABLE `enum` ENGINE = InnoDB; \
     115ALTER TABLE `milestone` ENGINE = InnoDB; \
     116ALTER TABLE `node_change` ENGINE = InnoDB; \
     117ALTER TABLE `permission` ENGINE = InnoDB; \
     118ALTER TABLE `report` ENGINE = InnoDB; \
     119ALTER TABLE `repository` ENGINE = InnoDB; \
     120ALTER TABLE `revision` ENGINE = InnoDB; \
     121ALTER TABLE `session` ENGINE = InnoDB; \
     122ALTER TABLE `session_attribute` ENGINE = InnoDB; \
     123ALTER TABLE `system` ENGINE = InnoDB; \
     124ALTER TABLE `ticket` ENGINE = InnoDB; \
     125ALTER TABLE `ticket_change` ENGINE = InnoDB; \
     126ALTER TABLE `ticket_custom` ENGINE = InnoDB; \
     127ALTER TABLE `version` ENGINE = InnoDB; \
     128ALTER TABLE `wiki` ENGINE = InnoDB;
     129}}}
     130
     131* Recheck that all database types are InnoDB:
     132
     133{{{
     134SELECT table_name, engine FROM information_schema.tables WHERE table_schema=DATABASE();
     135}}}
     136
     137{{{
     138exit
     139}}}
     140
     141* Deploy the Project (this creates the .wsgi file):
     142
     143{{{
     144sudo trac-admin /var/tracprojects/newproject/ deploy /var/tracprojects/newproject/deploy
     145}}}
     146
     147* Change permissions to apache on the project:
     148
     149{{{
     150sudo chown -R www-data:www-data /var/tracprojects/newproject/
     151}}}
     152
     153* Set apache for wsgi:
     154
     155{{{
     156sudo vi /etc/apache2/conf.d/trac.newproject.conf
     157}}}
     158
     159* paste the following contents into the file and save it:
     160
     161{{{
     162 WSGIScriptAlias /newproject /var/tracprojects/newproject/deploy/cgi-bin/trac.wsgi
     163
     164    <Directory /var/tracprojects/newproject/deploy/cgi-bin>
     165     WSGIApplicationGroup %{GLOBAL}
     166     Order deny,allow
     167     Allow from all
     168    </Directory>
     169
     170    <Location "/trac/login">
     171     AuthType Basic
     172     AuthName "Trac"
     173     AuthUserFile /var/tracprojects/.htpasswd
     174     Require valid-user
     175    </Location>
     176
     177 WSGIScriptAliasMatch ^/repo/.*/\.bzr/smart$ /var/tracprojects/newproject/deploy/cgi-bin/bzr.wsgi
     178
     179     #The three next lines allow regular GETs to work too
     180     RewriteEngine On
     181     RewriteCond %{REQUEST_URI} !^/code/.*/\.bzr/smart$
     182     RewriteRule ^/code/(.*/\.bzr/.*)$ /var/tracprojects/newproject/repo/$1 [L]
     183
     184    <Directory /var/tracprojects/newproject/repo/>
     185     WSGIApplicationGroup %{GLOBAL}
     186    </Directory>
     187
     188    <Location /repo/>
     189     AuthType Basic
     190     AuthName "Trac Source Access"
     191     AuthUserFile /var/tracprojects/.htpasswd
     192    <LimitExcept GET>
     193        Require valid-user
     194    </LimitExcept>
     195    </Location>
     196}}}
     197
     198We will use the same .htpasswd to authenticate bzr users as the trac install. Anyone you give access to trac will have write access to the bzr repo. You can change the bzr.wsgi setting readonly to true to disable any write access (see below). You could also create a different .htpasswd to seperate trac from bzr or require certain users by changing Require valid-user to Require admin.
     199
     200* Run the following command to create a password for user admin:
     201
     202{{{
     203sudo htpasswd -c /var/tracprojects/.htpasswd admin
     204}}}
     205
     206   Enter your password twice.
     207
     208* Grant admin rights to user admin:
     209
     210{{{
     211trac-admin /var/tracprojects/newproject permission add admin TRAC_ADMIN
     212}}}
     213
     214* Enable rewrite in apache:
     215
     216{{{
     217sudo a2enmod rewrite
     218}}}
     219
     220* Now restart Apache:
     221
     222{{{
     223sudo /etc/init.d/apache2 restart
     224}}}
     225
     226See if it worked:
     227
     228Go to http://your-host/newproject
     229
     230Everything should be working. You should be able to login.
     231
     232Now we need to setup bazaar as our vcs.
     233
     234* Install TracBzr:
     235
     236{{{
     237sudo easy_install TracBzr
     238}}}
     239
     240{{{
     241sudo mkdir /var/tracprojects/newproject/repo
     242}}}
     243
     244{{{
     245sudo chown www-data:www-data /var/tracprojects/newproject/repo/
     246}}}
     247
     248* Open the config file:
     249
     250{{{
     251sudo vi /var/tracprojects/newproject/conf/trac.ini
     252}}}
     253
     254* Find the section [trac]. Change repository_dir and repository_type to look like this:
     255
     256{{{
     257repository_dir = /var/tracprojects/newproject/repo
     258repository_type = bzr
     259}}}
     260
     261* Add this to the bottom of the file add:
     262
     263{{{
     264[components]
     265tracbzr.* = enabled
     266}}}
     267
     268   Save the file.
     269
     270* Create the bzr access file. We will create this in the deploy/cgi-bin directory:
     271
     272{{{
     273sudo vi /var/tracprojects/newproject/deploy/cgi-bin/bzr.wsgi
     274}}}
     275
     276* Paste this in the file:
     277
     278{{{
     279from bzrlib.transport.http import wsgi
     280
     281def application(environ, start_response):
     282    app = wsgi.make_app(
     283        root="/var/tracprojects/newproject/repo/",
     284        prefix="/repo",
     285        readonly=False,
     286        enable_logging=False)
     287    return app(environ, start_response)
     288}}}
     289
     290* Restart apache:
     291
     292{{{
     293sudo /etc/init.d/apache2 restart
     294}}}
     295
     296You should be able to the the Browse Source link at the top. You will see an error because there is no source yet.
     297
     298* Create the brz repo on the server:
     299
     300{{{
     301cd /var/tracprojects/newproject/
     302}}}
     303
     304{{{
     305sudo bzr whoami "Your Name <youremail@mymail.com>"
     306}}}
     307
     308{{{
     309sudo bzr init-repo --no-trees repo/
     310}}}
     311
     312{{{
     313sudo chown -R www-data:www-data /var/tracprojects/newproject/repo/
     314 }}}
     315
     316* Now initialize the project from the client:
     317
     318{{{
     319bzr whoami "Your Name <youremail@mymail.com>"
     320}}}
     321
     322{{{
     323bzr init bzr+http://tracserver/repo/newproject
     324}}}
     325
     326{{{
     327bzr checkout bzr+http://tracserver/repo/newproject dev
     328}}}
     329
     330{{{
     331cd dev
     332}}}
     333
     334{{{
     335touch test.txt
     336}}}
     337
     338{{{
     339bzr add
     340}}}
     341
     342{{{
     343bzr commit -m "Added test.txt"
     344}}}
     345
     346* If you get any errors when commiting make sure perrmissions are set to apache on the server:
     347
     348{{{
     349sudo chown -R www-data:www-data /var/tracprojects/newproject/repo/
     350}}}
     351
     352Now go to http://your-host/newproject and click on Browse Source and you should be able to browse the source.
     353
     354I recommend a GUI app called Bazaar Explorer. See http://wiki.bazaar.canonical.com/BzrExplorer
     355
     356* You can optionally install the default ssl on ubuntu by running:
     357
     358{{{
     359sudo a2enmod ssl
     360}}}
     361
     362{{{
     363sudo a2ensite default-ssl
     364}}}
     365
     366{{{
     367sudo /etc/init.d/apache2 restart
     368}}}
     369
     370* I had to remove python-pycurl on my Ubuntu client to connect to the bzr repo through https:
     371
     372{{{
     373sudo apt-get remove python-pycurl
     374}}}
     375
     376* use:
     377
     378{{{
     379bzr checkout bzr+https://tracserver/repo/newproject dev
     380}}}
     381
     382* instead of:
     383
     384{{{
     385bzr checkout bzr+http://tracserver/repo/newproject dev
     386}}}
     387
     388'''Resources:'''
     389
     390* http://trac.edgewall.org/wiki/TracInstall
     391* http://doc.bazaar.canonical.com/latest/en/index.html
     392
     393* Ubuntu - http://ubuntu.com
     394* Trac - http://trac.edgewall.org/
     395* Bazaar - http://bazaar.canonical.com/
     396* MySQL - http://mysql.com
     397* Mod_WSGI - http://code.google.com/p/modwsgi/
     398
     399