How To Install Piwik on an Ubuntu 12.04 Cloud Server

Published on May 6, 2013

Panmetro Web Design & Development

How To Install Piwik on an Ubuntu 12.04 Cloud Server

Status: Deprecated

This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:

Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.

See Instead:
This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.


Piwik is an open-source analytics system, which can be hosted at your cloud sever. It provides a more personalized solution than Google Analytics as it lets you have ownership and more control of your data, shows detailed traffic in real-time, and it has more stylistic graphs to see your data more effectively.


First, update Ubuntu for the latest software versions.

apt-get update
apt-get upgrade

APT will inform you about the available upgrade's number and size. Just type "Y" and press ENTER.

During the Package Configuration, APT will ask you "What would you like to do about menu.lst?" Just press ENTER to choose the default option, "keep the local version currently installed." After a few seconds, it will ask you the same question. Press ENTER again.

Now, install LAMP (Linux-Apache-Mysql-PHP) in Ubuntu, by typing in the console:


Use the down arrow key to go to the option, LAMP server, and select it by pressing the Space key. Press the TAB key to choose the OK button and hit ENTER. Tasksel installs the needed packages.

During the installation process, taskel is asking for a new password for the MYSQL root. Type the password of your choosing and press ENTER. At the next screen, type the same password once more and press ENTER.

After this, install some additional software that will be needed later on.

apt-get install unzip php5-gd

Type "Y" and press Enter to continue.

Installing Piwik

Go to the default root directory of Apache.

cd /var/www

Download latest Piwik zip file.

wget http://builds.piwik.org/latest.zip

Unzip the downloaded file.

unzip latest.zip

Clean up the unneeded files.

rm *html *zip

Set the correct file permissions.

chown -R www-data:www-data /var/www/piwik

Restart apache.

service apache2 restart

The rest of the process will go through the Web installer.

Complete the Piwik Installation Through the Web Installer

Open your web browser (Chrome, Safari, Firefox) and access the web installer of your Piwik installation by typing in the following URL:


You will enter into Piwik's Welcome Screen. Click Next:


At the System Check Screen, everything should be with green checkmarks. Click Next if you see this. If not, confim if you are using Ubuntu 12.04 and ran all the software updates/upgrades.

At the Database Setup screen, set the database server to be "127.0.01". You can use the phrase, "root", as the login and the same password that you setup during tasksel's MySQL installation procedure. Set a name for your database, eg. "piwik", and click Next.


Next screen should show: "Tables created with sucess!". Just click Next.

At the Super User screen, set the user login and password for logging into Piwik Analytics. Then, write your email address and your email preferences. Click Next when finished.

When you enter into Setup a Website screen, set the website's name and URL of the website where you will want to install the Piwik tracking code later. You may also configure the website's timezone, and set if it's an ecommerce site or not.


The next screen gives you the Tracking code which should be copied and pasted just before the closing tag (</body>) of your website.


If you use a CMS (Content Management System) like Wordpress or Drupal, there are two ways to install the piwik tracking code:

1. Either copy and paste the code from this screen at your HTML templates files.


2. Follow the instructions that the piwik modules/extensions for these CMSes provide.

Congratulations! Your Piwik is now installed to your cloud server.

Now, to confirm if your Piwik is fully setup and accessible, enter the URL below at your web browser's address bar.


Then login using your piwik admin login user and password.

Article Submitted by: Panmetro Web Design & Development

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors
Default avatar
Panmetro Web Design & Development


Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

After force_ssl = 1 I am unable to access Piwik at https://ip-address/piwik Is this related to valid ssl certificate? --> https://piwik.org/faq/troubleshooting/faq_20272/ I can’t even test my Piwik instance in my droplet as the ip address is not accepted at https://www.ssllabs.com/ssltest/

Any help is appreciated

hi i am trying to install piwik my droplet, when I ask the database added serve my ip address and I return an erro Error while trying to connect to the database server: SQLSTATE [HY000] [2003] Can not connect to MySQL server on

p.d piwik installation of this in a subdomain that believes

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
July 12, 2014

@info: It should. Try it out and let us know how it goes! :)

Will this also work on Ubuntu 14.04?

I meant change that to “:/my-IP//piwik/”; (substitute your IP or domain name)

I run an OpenCPU (nginx) server on Ubuntu 13.10 in my droplet. At first piwik did not work, then I noticed the tracking code contained “://ocpu/piwik/”;

Once I changed that to “://<my IP>/piwik/”; it worked (the android phone app. The desktop OS browser version still gives me Error: Form security failed. Please reload the form and check that your cookies are enabled. If you use a proxy server, you must configure Piwik to accept the proxy header that forwards the Host header. Also, check that your Referrer header is sent correctly.)

How do you point it do a domain, so I don’t have to use a ip address. thanks!

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
November 3, 2013

@yevgtan: You do not need to uninstall CodeIgniter, it should work fine even with CodeIgniter installed.

<blockquote>And basically i’m installing piwik to have possibility to use GeoIP. May be there is no need to continue the installation of piwik?</blockquote> Piwik is basically a self-hosted version of Google Analytics – is that what you need?

I came to the step “Complete the Piwik Installation Through the Web Installer” but I have an codeigniter installed on my server. (Note: codeigniter redirects urls to its inner functions) So should i need to uninstall codeigniter to finish the piwik installation? And basically i’m installing piwik to have possibility to use GeoIP. May be there is no need to continue the installation of piwik?

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel