Changes between Version 22 and Version 23 of Ubuntu-11.04-Subversion
- Timestamp:
- Oct 8, 2014, 6:47:44 AM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ubuntu-11.04-Subversion
v22 v23 1 1 = Installing Trac with Subversion on Ubuntu = 2 2 3 The goal of this tutorial is to demostrate how to setup a Subversion <-> Trac enviroment on Ubuntu 10.04. A MySQL database and Subversion Python bindings are going to be used. 4 Please note that only general instructions are provided, and it's asummed that you have basic knowledge on Linux administration. 3 The goal of this tutorial is to demonstrate how to setup a Subversion <-> Trac environment on Ubuntu 14.04. The original version of this document was written for 10.04, please see the History link for more details. 4 5 A MySQL database and Subversion Python bindings are going to be used. Please note that only general instructions are provided, and it's assumed that you have basic knowledge on Linux administration. 5 6 6 7 '''Note''': for a full installation tutorial on Trac, please read TracInstall … … 36 37 == Configuring == 37 38 38 This part is maybe the most important section on this tutorial. You'll learn how to syncronize Trac and Subversion in order to be able to see on your Trac Project website what's going on in your repository and also how to automate some tasks. 39 40 === Subversion === 41 42 ==== Creating the project ==== 39 This part is maybe the most important section on this tutorial. You'll learn how to synchronize Trac and Subversion in order to be able to see on your Trac Project website what's going on in your repository and also how to automate some tasks. 40 41 === Creating the Subversion repository for the project === 43 42 44 43 You may already know how to do this, but let's make a review just in case. … … 69 68 }}} 70 69 70 If you used the command above, you may choose to test that the process is running by issuing: 71 {{{ 72 sudo lsof -i | grep svnserve 73 }}} 74 75 This should show something like: 76 {{{ 77 svnserve 13418 root 3u IPv4 675323469 0t0 TCP *:svn (LISTEN) 78 }}} 79 80 which means the process `svnserve` with PID `13418` was run by `root` and is listening on the `svn` port, which is by default 3690. 81 82 Also, checking out revision 0 should be possible: 83 {{{ 84 svn co svn://localhost/var/lib/svn/YourProject 85 }}} 86 The above command will create a directory with the name `YourProject` within your current directory. 87 88 '''Note''': until users and authentication have been set up, committing will not be allowed. 89 71 90 === Setup the MySQL database === 72 91 … … 90 109 You can now exit the MySQL command line. 91 110 92 === Trac === 93 94 ==== Initiate the enviroment 111 === Initialise the Trac environment === 95 112 96 113 Let's create a directory to contain all the Trac project (just like we did for SVN projects). … … 104 121 }}} 105 122 106 As you did for Subversion, change the ownership of the project files to Apache's user www-data:107 {{{ 108 sudo chown -R www-data :www-data/var/lib/trac/YourProject109 }}} 110 111 Use trac-adminto create the new project:123 As you did for Subversion, change the ownership of the project files to Apache's user `www-data`: 124 {{{ 125 sudo chown -R www-data /var/lib/trac/YourProject 126 }}} 127 128 Use `trac-admin` to create the new project: 112 129 {{{ 113 130 sudo trac-admin /var/lib/trac/YourProject initenv 114 131 }}} 115 132 116 Also you will need to fill in some information, like the project name. It will ask you for the MySQL connection string. Input the following (according to the way we did setup the MySQL database in the step 2.2). 133 This command starts a script that requests some information, like the project name and the MySQL connection string. 134 135 The MySQL connection string should look like the following (according to the way we set up the MySQL database in step 2.2). 117 136 {{{ 118 137 mysql://trac:yourpassword@localhost/trac 119 138 }}} 120 139 121 Pay attention to the question about the location of the Subversion project. Enter the path as discussed before: 140 Once this is done, you may check the setup by running `tracd`: 141 {{{ 142 tracd --port=12345 /var/lib/trac/Apollo 143 }}} 144 145 Your browser should show a basic trac install on `http://localhost:12345/Apollo`. 146 147 ==== Notes ==== 148 You might run into an error when running `trac-admin initenv`, ending in: 149 {{{ 150 AttributeError: 'NullTranslations' object has no attribute 'add' 151 }}} 152 153 For me, making [http://trac.edgewall.org/ticket/10903#comment:5 this patch] in the listed file solved it. 154 155 Pay attention to the question about the location of the Subversion project. This fills the variable `repository_dir` in `trac.ini`. Enter the path as discussed before: 122 156 {{{ 123 157 /var/lib/svn/YourProject 124 158 }}} 125 159 126 If the MySQL default engine wasn't InnoDB, you might need to convert the tables tha trac-adminhas just created. Issue the following within your MySQL client:160 If the MySQL default engine wasn't InnoDB, you might need to convert the tables that `trac-admin` has just created. Issue the following within your MySQL client: 127 161 {{{ 128 162 USE trac; \ … … 148 182 }}} 149 183 150 === = Explicit syncronization ====151 152 '''Note''': For more information about the Explicit Sync ronization method, please read TracRepositoryAdmin#ExplicitSync153 154 First, edit the '''trac.ini''' file, located in ''/var/lib/trac/YourProject/conf/''. Modify the "repository_sync_per_request"directive and set it to an empty value.155 156 Now you need to create the Subversion hooks. First, create the post-commit hook the in ''/var/lib/svn/YourProject/hooks/''directory, with the following content:184 === Explicit synchronization of trac and svn === 185 186 '''Note''': For more information about the Explicit Synchronization method, please read TracRepositoryAdmin#ExplicitSync 187 188 First, edit the `trac.ini` file, located in `/var/lib/trac/YourProject/conf/`. Modify the `repository_sync_per_request` directive and set it to an empty value. 189 190 Now you need to create the Subversion hooks. First, create the ''post-commit'' hook in the `/var/lib/svn/YourProject/hooks/` directory, with the following content: 157 191 {{{ 158 192 #!/bin/sh … … 161 195 }}} 162 196 163 Make sure you give the script execution perm s:197 Make sure you give the script execution permissions: 164 198 {{{ 165 199 sudo chmod +x /var/lib/svn/YourProject/hooks/post-commit 166 200 }}} 167 201 168 Another important hook script to have is post-revprop-change. The procedures are similiar as above, but the script is slightly different:202 Another important hook script to have is ''post-revprop-change''. The procedures are similar, but the script is slightly different: 169 203 {{{ 170 204 #!/bin/sh … … 173 207 }}} 174 208 175 Again, make sure you give exec perms to the script. 176 177 Now Trac will be notified about changes you make to your repository and will make them availables in the timeline. 178 179 180 === Apache === 181 182 ==== Set up Trac handling ==== 209 Again, make sure you give exec permissions to the script. 210 211 Now Trac will be notified about changes you make to your repository and will make them available in the timeline. 212 213 === Instructing Apache to handle Trac === 214 215 Create a new site for your Trac setup. 216 {{{ 217 sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/trac.conf 218 }}} 183 219 184 220 Apache needs to know how to handle Trac. Use the following block to set up Trac handling: … … 192 228 }}} 193 229 194 Note that it's pointing to the main Trac directory. It means it will expose all of your Trac projects. You may need to apply this configuration to Apache :230 Note that it's pointing to the main Trac directory. It means it will expose all of your Trac projects. You may need to apply this configuration to Apache, then reload the server: 195 231 {{{ 196 232 sudo a2ensite trac 233 sudo service apache2 reload 197 234 }}} 198 235 199 236 ==== Authentication ==== 200 237 201 In order to allow users to log in Trac, you will need the following section in your Apache configuration: 238 Make sure that the `apache2-utils` package is installed to use `htpasswd`. 239 240 In order to allow users to log in to Trac, you will need the following section in your Apache configuration: 202 241 {{{ 203 242 <LocationMatch "/projects/[^/]+/login"> … … 209 248 }}} 210 249 211 You should now create the .htpasswdfile, with an admin user:250 You should now create the `.htpasswd` file, with an admin user: 212 251 {{{ 213 252 sudo htpasswd -c .htpasswd admin … … 216 255 Go ahead and restart Apache: 217 256 {{{ 218 sudo /etc/init.d/apache2 restart257 sudo service apache2 restart 219 258 }}} 220 259 … … 224 263 }}} 225 264 226 == Automatic reference to the SVN changesets in Trac tickets==227 228 Something useful is to reference tickets on your commits. That way you can keep a better track of them and also eas ly access them from the timeline.229 230 Make sure you have the following line in your trac.iniconfiguration file:265 === Automatic reference to the SVN changesets in Trac tickets === 266 267 Something useful is to reference tickets on your commits. That way you can keep a better track of them and also easily access them from the timeline. 268 269 Make sure you have the following lines in your `trac.ini` configuration file: 231 270 {{{ 232 271 [components]