{"id":27242,"date":"2018-06-26T02:16:10","date_gmt":"2018-06-26T07:16:10","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=27242"},"modified":"2022-06-03T03:34:54","modified_gmt":"2022-06-03T08:34:54","slug":"how-to-install-matomo-on-centos-7","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-matomo-on-centos-7\/","title":{"rendered":"How to Install Matomo on CentOS 7"},"content":{"rendered":"
<\/p>\n
This tutorial explains the process of installing an open source web analytic application named\u00a0Matomo (formerly known as Piwik) on a CentOS 7 VPS.\u00a0Matomo helps you gather and analyze important information about your website visitors. Matomo features tracking of visits, goals, conversion rates, A\/B Testing, funnels, heatmaps, downloads, keywords, and many more.\u00a0Let’s get started with the installation of Matomo on your CentOS 7 server.<\/p>\n
<\/p>\n
In order to run Matomo on your CentOS 7 VPS you need the following requirements pre-installed:<\/p>\n
Log in to your CentOS 7 VPS via ssh as user root<\/p>\n
ssh roo@IP_Address -p Port_number<\/pre>\n2. Update all packages<\/strong><\/h3>\n
Once you are logged in to the server run the following command to make sure that all installed packages are up to date<\/p>\n
yum clean all\r\nyum update<\/pre>\n3. Install LAMP stack<\/strong><\/h3>\n
As mention in the requirements section of the tutorial, a LAMP stack (Apache, MySQL\/MariaDB and PHP) is required to run Matomo on the server. We will start with installing Apache web server<\/p>\n
yum -y install httpd<\/pre>\nAfter the Apache installation is complete, start the Apache web server and enable it to start upon server boot<\/p>\n
systemctl enable httpd<\/pre>\nPHP version 7.1 is not available in the default CentOS 7 repositories so we will use the Remi repository.<\/p>\n
To install and enable both EPEL and Remi repositories run the following command:<\/p>\n
yum install epel-release\r\nrpm -Uhv https:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm\r\nyum-config-manager --enable remi-php71<\/pre>\nYou can now proceed and install PHP 7.1 and all necessary PHP modules using the following command:<\/p>\n
yum install php php-common php-mbstring php-gd php-curl php-mysql php-xml<\/pre>\nDuring the installation, the yum package manager will prompt you to install the Remi GPG Signing key. Accept the key by typing ‘y’ and the package manager will install\u00a0 all necessary PHP extensions.<\/p>\n
In order to complete the LAMP installation, install MariaDB database server using the following command:<\/p>\n
yum -y mariadb mariadb-server<\/pre>\nStart the MariaDB service and set it to start on reboot<\/p>\n
systemctl start mariadb\r\nsystemctl enable mariadb<\/pre>\nRun the ‘mysql_secure_installation’ post installation script provided by MariaDB to strengthen the security of the database server and set a root password. You can use the following options:<\/p>\n
Set root password? [Y\/n] Y\r\nRemove anonymous users? [Y\/n] Y\r\nDisallow root login remotely? [Y\/n] Y\r\nRemove test database and access to it? [Y\/n] Y\r\nReload privilege tables now? [Y\/n] Y<\/pre>\n4. Install Matomo on CentOS 7<\/strong><\/h3>\n
Matomo is not available in the official CentOS 7 repositories, so we will have to download Matomo from the official website page at https:\/\/builds.matomo.org\/ and extract the Matomo archive to a directory on the server by executing the following commands:<\/p>\n
cd \/opt\r\nwget https:\/\/builds.matomo.org\/piwik.zip -O matomo.zip\r\nunzip matomo.zip -d \/var\/www\/html\/\r\nmv \/var\/www\/html\/piwik\/ \/var\/www\/html\/matomo\/<\/pre>\nThis will create a new directory named \u2018matomo\u2019 containing the necessary files and directories.
\nChange the ownership of the matomo directory<\/p>\nchown -R apache:apache \/var\/www\/html\/matomo<\/pre>\n5. Configure Apache to serve Matomo<\/h3>\n
Now we will have to setup the Apache configuration so it can serve the Matomo directory, add the following contents below to the \/etc\/httpd\/conf.d\/matomo.conf file with nano or your favorite editor:<\/p>\n
# vi \/etc\/httpd\/conf.d\/matomo.conf<\/pre>\nAdd the following lines:<\/p>\n
<VirtualHost *:80>
\nServerAdmin admin@your-domain.com
\nDocumentRoot \/var\/www\/html\/matomo
\nServerName your-domain.com
\nServerAlias www.your-domain.com<\/p>\nAlias \/matomo “\/var\/www\/html\/matomo\/”
\n<Directory \/var\/www\/html\/matomo\/>
\nOptions +FollowSymlinks
\nAllowOverride All<\/p>\n<\/Directory><\/p>\n
ErrorLog \/var\/log\/httpd\/matomo-error_log
\nCustomLog \/var\/log\/httpd\/matomo-access_log common
\n<\/VirtualHost><\/p>\nSave the changes and restart the Apache web server for the changes to take effect:<\/p>\n
systemctl restart httpd<\/pre>\n6. Create a MySQL database for Matomo<\/h3>\n
Log into MySQL with the root account:<\/p>\n
# mysql -u root -p<\/pre>\nNow we will create a MySQL database for Matomo using the following query:<\/p>\n
mysql> CREATE DATABASE matomo;<\/pre>\nThen execute the following query to add a separate user for Matomo that will interact with the database:<\/p>\n
mysql> GRANT ALL PRIVILEGES ON matomo.* to 'matomo'@'localhost' IDENTIFIED BY '5tr0ng_Pa55w0rd';<\/pre>\nExecute the following command to apply the privileges we set:<\/p>\n
mysql> FLUSH PRIVILEGES;<\/pre>\nNow we can exit the MySQL session:<\/p>\n
mysql> quit<\/pre>\nYou can now open a web browser and access the Matomo application at http:\/\/your-domain.com<\/p>\n
From here you can finish the setup by following the steps below:<\/p>\n
\n
- Matomo will check to make sure that your server meets the Matomo requirements. If everything is OK, click Next<\/li>\n
- Enter localhost or 127.0.0.1 as database server, then enter a database username and password, database name, and once you have filled in the form, click Next<\/li>\n
- You should receive a message: ‘Tables created with success!’. Click on the Next button once again<\/li>\n
- Enter a username, password and email address for the administrator user account<\/li>\n
- On the next page, set up the Website name and URL you want to track.<\/li>\n<\/ul>\n
That’s it, now you should have successfully installed Matomo on your CentOS 7 server. You need to add the JavaScript tracking code on every page of your website before the closing tag so you can track and analyze the websites. You can now log in to the Matomo administration back-end and add more websites and start tracking and analyzing the website traffic. To access Matomo official documentation, please navigate to Matomo Official Documentation<\/a><\/p>\n
<\/p>\n
\nOf course, you don\u2019t have to install and configure Matomo on CentOS 7, if you use one of our\u00a0CentOS Hosting<\/a> solutions, in which case you can simply ask our expert Linux admins to install and configure Matomo on CentOS for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\n
PS<\/strong><\/span>. If you liked this post on how to install and configure Matomo on a CentOS VPS, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"
This tutorial explains the process of installing an open source web analytic application named\u00a0Matomo (formerly known as Piwik) on a … <\/p>\n