If you don't like Google having your site's traffic info, you have an alternative. Free and opensource software Piwik
! You can read a Piwik vs Google Analytics here. You're going to need a LAMP stack (Linux/Apache/MySQL or MariaDB/PHP). You can follow my Setting up a Web Server tutorial to setup a server, if you don't have one already.
Tutorial based on Debian 9, should run on Ubuntu 17.04 as is. Total time: less than 10 minutes!
Note! The "Other stuff list" I usualy put here, has moved at the end of the articles. It got pretty long.
We will need root privileges! sudo su
So, if you haven't installed php7.1-gd, do it now! (I assume that you'll be using php 7.1. If you are using php 7.0, change php7.1 to php7.0. If you are using PHP5.x, update to PHP7.1 please!) We will also need unzip
!
apt-get install php7.1-gd unzip
Creating piwik folder & vhost
I will be using examplesite.com as a domain name, so change it to your own domain!
First, we will create the piwik vhost: nano /etc/apache2/sites-enabled/998-stats.examplesite.com.conf
Copy and paste the following block inside. Don't forget to change folders/emails/domains!
<VirtualHost *:80>
ServerName piwik.examplesite.com
ServerAdmin webmaster@examplesite.com
DocumentRoot /var/www/piwik.examplesite.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Restart Apache: service apache2 restart
.
Now we will create the folder we set on DocumentRoot
:
mkdir -p /var/www/piwik.examplesite.com/
We are ready to download and install piwik.
Downloading and extracting the latest Piwik version
We have to go inside /var/www/piwik.examplesite.com, download and extract Piwik.
cd /var/www/piwik.examplesite.com
wget http://builds.piwik.org/latest.zip
unzip latest.zip
Now, by default after extracting, piwik will be inside /var/www/piwik.examplesite.com/piwik
. We will also have a "How to install piwik" file. Go ahead and read it! That's the end of the tutorial!
Kidding of course! Execute these commands to remove "How to install piwik", move Piwik to the root of the domain and remove the now-unneeded folder:
mv piwik/* .
rm -rf How*html piwik
Now we have to change the owner and some permissions:
chmod a+w /var/www/piwik.examplesite.com/tmp
chmod a+w /var/www/piwik.examplesite.com/config
chown -R www-data:www-data /var/www/piwik.examplesite.com
We are now ready! First, generate a Let's Encrypt certificate (read here for more info), and then run the installation by visiting https://piwik.examplesite.com/
Other stuff in the Server 101 series:
- Intro and getting into your server - Single Article
- Basic Server Security - 3 Parts
- Setting up a Web Server - 4 Parts
- Managing Your Server - 4 Parts
- caddy - Lightweight Web Server - 1 Part
- Emailify your server! - 6 Parts
- Setting up a Password-Protected proxy server with Squid - 1 Part
- OpenVPN in less than 2 minutes
If you need a place to host your servers consider Vultr, Digital Ocean and BuyVM.
These are affiliate links. If you sign up through them, you support me and I will have more free time to write more content like this.
Also If you signup for Digital Ocean through my affiliate link, you will get $10 to try them out. Note: to battle abusers of this offer, you'll have to make a $5 deposit via Paypal or add your credit/debit card, so they can confirm that you are a new user. I did a deposit via Paypal to test them out, and then I added my credit card so I won't have to deposit money manually every now and then.
Thanks Dimitrisp for your support to the Piwik community.