| 1 | = Install Trac on Ubuntu proxied by Nginx = |
| 2 | [[PageOutline(2-5,Contents,pullout)]] |
| 3 | |
| 4 | How to install and run a single hosted Trac project from https://trac.edgewall.org |
| 5 | |
| 6 | This guide should apply for the following debian variations: |
| 7 | * Debian 9 |
| 8 | * Ubuntu 16.04 |
| 9 | * Ubuntu 16.10 |
| 10 | * !LinuxMint 18.1 |
| 11 | * !LinuxMint 18.2 |
| 12 | |
| 13 | Here is a somewhat basic copy paste #!bash script for this, however, there will be some manual labor for you :P but a find+replace would help you a lot. Be aware you might run all of these commands with the `sudo -H` |
| 14 | |
| 15 | {{{#!div class="important" |
| 16 | **important** remember to replace the `https://trac-hacks.org/svn/fullblogplugin/0.11` with [https://trac-hacks.org/wiki/FullBlogPlugin latest verion] |
| 17 | }}} |
| 18 | |
| 19 | {{{#!bash |
| 20 | apt-get install subversion libapache2-mod-python pypy python python-babel trac python-pip -y |
| 21 | pip install --upgrade pip |
| 22 | pip install --upgrade Babel |
| 23 | pip install --upgrade Trac |
| 24 | pip install --upgrade pillow |
| 25 | pip install dnspython |
| 26 | pip install spambayes |
| 27 | pip install oauth2 |
| 28 | pip install httplib2 |
| 29 | pip install TracTags |
| 30 | pip install TracSpamFilter |
| 31 | pip install TracVote |
| 32 | easy_install --always-unzip https://trac-hacks.org/svn/fullblogplugin/0.11 |
| 33 | mkdir -p /var/www/trac/ |
| 34 | |
| 35 | trac-admin /var/www/trac initenv |
| 36 | |
| 37 | }}} |
| 38 | Follow the trac-admin guide... |
| 39 | |
| 40 | Now lets test the trac before we do more |
| 41 | {{{#!bash |
| 42 | tracd --port 8000 /var/www/trac |
| 43 | lynx localhost:8000/trac |
| 44 | }}} |
| 45 | |
| 46 | Great it's working, then it's time to setup a admin user and password for the admin account. Bad luck if it doesn't as that is beyond this wiki and you'll need to go https://duckduckgo.com to find a solution :( |
| 47 | |
| 48 | {{{#!bash |
| 49 | htpasswd -c /var/www/trac/.htpasswd adminusername |
| 50 | trac-admin /var/www/trac/ permission add adminusername TRAC_ADMIN |
| 51 | }}} |
| 52 | |
| 53 | Replace `adminusername` with your desired username |
| 54 | |
| 55 | Next we set the propper user and group permissions on the Trac folder to allow the !Nginx/Apache/Trac server to access it |
| 56 | |
| 57 | {{{#!bash |
| 58 | chown -R UserName:GroupName /var/www/trac/ |
| 59 | chmod -R 775 /var/www/trac/ |
| 60 | }}} |
| 61 | |
| 62 | == Enable GIT source == |
| 63 | To enable git source brosing we need another subfolder |
| 64 | {{{#!bash |
| 65 | mkdir -p /var/www/trac/git |
| 66 | }}} |
| 67 | |
| 68 | == Systemd startup script == #SystemD |
| 69 | |
| 70 | In your `/etc/systemd/system/` make this new file --> |
| 71 | {{{#!bash |
| 72 | nano /etc/systemd/system/tracd.service |
| 73 | }}} |
| 74 | {{{#!ini |
| 75 | [Unit] |
| 76 | Description=TrackD Daemon |
| 77 | After=network.target |
| 78 | |
| 79 | [Service] |
| 80 | ExecStart=/usr/local/bin/tracd -p 3050 --protocol=http --basic-auth="*,/var/www/trac/.htpasswd,Restricted" -s /var/www/trac |
| 81 | Type=simple |
| 82 | User=UserName |
| 83 | Group=GroupName |
| 84 | |
| 85 | [Install] |
| 86 | WantedBy=multi-user.target |
| 87 | }}} |
| 88 | |
| 89 | == Nginx configs == |
| 90 | Now it's time to do the NginX configureations :) |
| 91 | |
| 92 | First we have to make a reverse proxy to the Trac daemon we have made in [#SystemD Systemd startup script] |
| 93 | |
| 94 | In the `/etc/nginx/nginx.conf` we'll have to add a upstream for our reverse_proxy to Trac |
| 95 | {{{#!nginx-conf |
| 96 | upstream live_trachosts_com { |
| 97 | server 127.0.0.1:3050; |
| 98 | } |
| 99 | }}} |
| 100 | |
| 101 | Now make the site.conf file in your preferred location, which by default would be `/etc/nginx/conf.d/` for other it would be in `/etc/nginx/sites-available` but we go whit the default [[br]] |
| 102 | `nano /etc/nginx/conf.d/site.conf` |
| 103 | |
| 104 | {{{#!nginx-conf |
| 105 | server { |
| 106 | listen 123.123.123.123:80; |
| 107 | server_name trac.local; |
| 108 | |
| 109 | charset utf8; |
| 110 | access_log /var/log/nginx/trac.access.log; |
| 111 | error_log /var/log/nginx/trac.debug.log; |
| 112 | |
| 113 | location / { |
| 114 | proxy_pass http://live_trachosts_com; |
| 115 | proxy_set_header Host $host; |
| 116 | } |
| 117 | |
| 118 | # redirect server error pages to the static page /50x.html |
| 119 | # |
| 120 | error_page 500 502 503 504 /50x.html; |
| 121 | location = /50x.html { |
| 122 | root /usr/share/nginx/html; |
| 123 | } |
| 124 | |
| 125 | # deny access to .htaccess files, if Apache's document root |
| 126 | # concurs with nginx's one |
| 127 | # |
| 128 | location ~ /\.ht { |
| 129 | deny all; |
| 130 | } |
| 131 | } |
| 132 | }}} |
| 133 | == Apache == |
| 134 | And since you properly anyway use apache :( well here is that piece of code :( |
| 135 | |
| 136 | {{{#!bash |
| 137 | a2enmod python |
| 138 | nano /etc/apache2/sites-available/trac.conf |
| 139 | }}} |
| 140 | |
| 141 | {{{#!apacheconf |
| 142 | <VirtualHost 123.123.123.123:80> |
| 143 | ServerName trac.local |
| 144 | <Location /> |
| 145 | SetHandler mod_python |
| 146 | PythonInterpreter main_interpreter |
| 147 | PythonHandler trac.web.modpython_frontend |
| 148 | PythonOption TracEnv /var/www/trac |
| 149 | PythonOption TracEnvParentDir /var/www/trac |
| 150 | PythonOption TracUriRoot / |
| 151 | PythonOption TracEnv /var/www/trac |
| 152 | # PythonOption TracEnvIndexTemplate /var/www/trac/templates/index-template.html |
| 153 | PythonOption TracLocale en_US.UTF8 |
| 154 | PythonOption PYTHON_EGG_CACHE /tmp |
| 155 | Order allow,deny |
| 156 | Allow from all |
| 157 | </Location> |
| 158 | <Location /login> |
| 159 | AuthType Basic |
| 160 | AuthName "myproject" |
| 161 | AuthUserFile /var/www/trac/.htpasswd |
| 162 | Require valid-user |
| 163 | </Location> |
| 164 | </VirtualHost> |
| 165 | }}} |
| 166 | |
| 167 | To enable the trac site run `a2ensite trac.conf` |
| 168 | |
| 169 | == !Find/Replace == |
| 170 | The following paths is to be replaced with your preferences [[br]] |
| 171 | `/var/www/trac` --> `/full/path/to/trac` [[br]] |
| 172 | `adminusername` --> `YourUserName` to be used as the track admin [[br]] |
| 173 | `UserName` --> The username for which trac daemon runs as ex. `Your login UserName` [[br]] |
| 174 | `GroupName` --> The group name for which trac daemon runs as ex `www-data` [[br]] |
| 175 | `trac.local` --> `full.domain.tld` [[br]] |
| 176 | `live_trachosts_com` --> to what suits your needs [[br]] |
| 177 | `123.123.123.123` --> if you are running both NginX and Apache on port 80/443 you'll need to set the IP, but if you only runs Nginx or Apache you can delete the ip to listen on all address |
| 178 | |
| 179 | == Versions == |
| 180 | In this tutorial I have used the following software versions |
| 181 | {{{#!bash |
| 182 | $ uname -a |
| 183 | Linux hostname 4.11.0-14-generic #20~16.04.1-Ubuntu SMP Wed Aug 9 09:06:22 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux |
| 184 | $ tracd --version |
| 185 | tracd 1.2.2 |
| 186 | $ nginx -v |
| 187 | nginx version: nginx/1.13.6 |
| 188 | }}} |
| 189 | |
| 190 | === Which list === |
| 191 | A complete HOWTO copy/paste guide to make Nginx running as "Front-end" of trac |