| 6 | == Live Server == |
| 7 | |
| 8 | === Install === |
| 9 | |
| 10 | {{{ |
| 11 | cd /web |
| 12 | cd stats.transitionnetwork.org/ |
| 13 | wget http://piwik.org/latest.zip |
| 14 | unzip latest.zip |
| 15 | cd piwik |
| 16 | chown -R www-data:www-data tmp/ |
| 17 | chown -R www-data:www-data config/ |
| 18 | chown -R www-data:www-data themes/ |
| 19 | }}} |
| 20 | |
| 21 | === Apache === |
| 22 | |
| 23 | Create {{{stats.transitionnetwork.org.conf}}} in {{{cd /etc/apache2/sites-available/}}}: |
| 24 | |
| 25 | {{{ |
| 26 | <VirtualHost *:80> |
| 27 | ServerName stats.transitionnetwork.org |
| 28 | ServerAlias stats.transitionnetwork.org.webarch.net |
| 29 | ServerSignature Off |
| 30 | UseCanonicalName On |
| 31 | |
| 32 | ErrorLog /var/log/apache2/stats.transitionnetwork.org_error.log |
| 33 | ErrorLog /var/log/apache2/error.log |
| 34 | SetEnvIf Remote_Addr "127\.0\.0\.1" loopback |
| 35 | SetEnvIf Remote_Addr "kiwi\.transitionnetwork\.org" loopback |
| 36 | CustomLog /var/log/apache2/stats.transitionnetwork.org_access.log combined env=!loopback |
| 37 | CustomLog /var/log/apache2/access.log combined env=!loopback |
| 38 | |
| 39 | Redirect / https://stats.transitionnetwork.org/ |
| 40 | </VirtualHost> |
| 41 | |
| 42 | <VirtualHost *:443> |
| 43 | ServerName stats.transitionnetwork.org |
| 44 | ServerAlias stats.transitionnetwork.org.webarch.net |
| 45 | ServerSignature Off |
| 46 | UseCanonicalName On |
| 47 | |
| 48 | LogLevel warn |
| 49 | ErrorLog /var/log/apache2/stats.transitionnetwork.org_ssl_error.log |
| 50 | ErrorLog /var/log/apache2/error.log |
| 51 | SetEnvIf Remote_Addr "127\.0\.0\.1" loopback |
| 52 | SetEnvIf Remote_Addr "kiwi\.transitionnetwork\.org" loopback |
| 53 | CustomLog /var/log/apache2/stats.transitionnetwork.org_ssl_access.log combined env=!loopback |
| 54 | CustomLog /var/log/apache2/access.log combined env=!loopback |
| 55 | |
| 56 | SSLEngine on |
| 57 | SSLCipherSuite HIGH |
| 58 | SSLProtocol all -SSLv2 |
| 59 | SSLCertificateFile /etc/ssl/transitionnetwork.org/transitionnetwork.org.pem |
| 60 | SSLCertificateChainFile /etc/ssl/transitionnetwork.org/gandi.pem |
| 61 | |
| 62 | DocumentRoot "/web/stats.transitionnetwork.org/piwik" |
| 63 | <Directory "/web/stats.transitionnetwork.org/piwik"> |
| 64 | DirectoryIndex index.php |
| 65 | Options -Indexes |
| 66 | AddType 'image/x-icon' .ico |
| 67 | AddHandler php5-script .php |
| 68 | AddType text/html .php |
| 69 | SSLOptions +StdEnvVars |
| 70 | AllowOverride None |
| 71 | order allow,deny |
| 72 | allow from all |
| 73 | </Directory> |
| 74 | <Directory "/web/stats.transitionnetwork.org/piwik/tmp"> |
| 75 | Options Indexes |
| 76 | RemoveHandler .php |
| 77 | AllowOverride None |
| 78 | order allow,deny |
| 79 | allow from all |
| 80 | </Directory> |
| 81 | <Location /config> |
| 82 | Order deny,allow |
| 83 | Deny from all |
| 84 | Allow from 127.0.0.1 |
| 85 | </Location> |
| 86 | |
| 87 | <FilesMatch "\.(cgi|shtml|phtml|php)$"> |
| 88 | SSLOptions +StdEnvVars |
| 89 | </FilesMatch> |
| 90 | <Directory /usr/lib/cgi-bin> |
| 91 | SSLOptions +StdEnvVars |
| 92 | </Directory> |
| 93 | |
| 94 | </VirtualHost> |
| 95 | }}} |
| 96 | |
| 97 | Enable it and restart: |
| 98 | |
| 99 | {{{ |
| 100 | /etc/apache2/sites-enabled |
| 101 | ln -s ../sites-available/stats.transitionnetwork.org.conf 35-stats.transitionnetwork.org.conf |
| 102 | apache2ctl configtest |
| 103 | apache2ctl restart |
| 104 | }}} |
| 105 | |
| 106 | === MySQL === |
| 107 | |
| 108 | As MySQL root user: |
| 109 | |
| 110 | {{{ |
| 111 | CREATE USER 'stats'@'localhost' IDENTIFIED BY '********'; |
| 112 | GRANT USAGE ON * . * TO 'stats'@'localhost' IDENTIFIED BY '********' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; |
| 113 | CREATE DATABASE IF NOT EXISTS `stats` ; |
| 114 | GRANT ALL PRIVILEGES ON `stats` . * TO 'stats'@'localhost'; |
| 115 | FLUSH PRIVILEGES; |
| 116 | }}} |
| 117 | |
| 118 | === Web Install === |
| 119 | |
| 120 | MySQL settings: |
| 121 | |
| 122 | * database server: 127.0.0.1 |
| 123 | * login: stats |
| 124 | * password: ******** |
| 125 | * database name: stats |
| 126 | * table prefix: (blank - we don't need one, the default is piwik_) |
| 127 | * adapter: PDO_MYSQL |
| 128 | |
| 129 | Super User settings: |
| 130 | |
| 131 | * super user login: webproject |
| 132 | * password: ******** |
| 133 | * email: webproject (at) transitionnetwork.org |
| 134 | |
| 135 | Suggested JS code: |
| 136 | |
| 137 | {{{ |
| 138 | <!-- Piwik --> |
| 139 | <script type="text/javascript"> |
| 140 | var pkBaseURL = (("https:" == document.location.protocol) ? "https://stats.transitionnetwork.org/" : "http://stats.transitionnetwork.org/"); |
| 141 | document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E")); |
| 142 | </script><script type="text/javascript"> |
| 143 | try { |
| 144 | var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1); |
| 145 | piwikTracker.trackPageView(); |
| 146 | piwikTracker.enableLinkTracking(); |
| 147 | } catch( err ) {} |
| 148 | </script><noscript><p><img src="http://stats.transitionnetwork.org/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript> |
| 149 | <!-- End Piwik Tracking Code --> |
| 150 | }}} |
| 151 | |
| 152 | Suggested image code: |
| 153 | |
| 154 | {{{ |
| 155 | <!-- Piwik Image Tracker --> |
| 156 | <img src="https://stats.transitionnetwork.org/piwik.php?idsite=1&rec=1" style="border:0" alt="" /> |
| 157 | <!-- End Piwik --> |
| 158 | }}} |
| 159 | |
| 160 | === Configure === |
| 161 | |
| 162 | In the General Settings page: |
| 163 | |
| 164 | * Allow Piwik archiving to trigger when reports are viewed from the browser: no |
| 165 | * Reports for today (or any other Date Range including today) will be processed at most every: 1800 |
| 166 | |
| 167 | Set up cron: |
| 168 | |
| 169 | {{{ |
| 170 | crontab -u www-data -e |
| 171 | |
| 172 | 5 * * * * /web/stats.transitionnetwork.org/piwik/misc/cron/archive.sh > /dev/null |
| 173 | }}} |
| 174 | |
| 175 | Test it: |
| 176 | |
| 177 | {{{ |
| 178 | su www-data -c "sh /web/stats.transitionnetwork.org/piwik/misc/cron/archive.sh" |
| 179 | }}} |
| 180 | |
| 181 | This generated this error: |
| 182 | |
| 183 | {{{ |
| 184 | ALERT - script tried to increase memory_limit to 134217728 bytes which is above the allowed value (attacker 'REMOTE_ADDR not set', file '/web/stats.transitionnetwork.org/piwik/core/Piwik.php', line 947) |
| 185 | }}} |
| 186 | |
| 187 | Which can be ignored because in {{{/etc/php5/apache2/php.ini}}} it's set to double that already, 256M, so I don't understand why it tried to raise it. |
| 188 | |
| 189 | Things added to {{{/web/stats.transitionnetwork.org/piwik/config/config.ini.php}}}, taken from {{{global.ini.php}}}: |
| 190 | |
| 191 | {{{ |
| 192 | [General] |
| 193 | force_ssl_login = 1 |
| 194 | feedback_email_address = "webproject (at) transitionnetwork.org" |
| 195 | assume_secure_protocol = 1 |
| 196 | }}} |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |