Tuesday, November 10, 2020

How To Install Fathom Analytics with Apache on Ubuntu 18.04 LTS

 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 Fathom is a self-hosted open source web analytics platform that provides simple, useful website statistics without tracking or storing your users' personal information. It is a very good alternative to Google Analytics with a simple web interface that can be used for small and medium businesses. Fathom gives you full control over your data without using third-party solutions. Fathom offers you top pages, top referrers, bounce rate and average time spent on your website.
Offcial Website: https://usefathom.com/
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Our Server Specification-     
Os:Ubuntu 18.04 LTS Bionic Beaver 64Bit   |IP address- 192.168.1.50  | Hostname :www.yourdomain.com
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lsb_release -cd ; hostname ; hostname -I ; whoami ; getconf LONG_BIT

MariaDB Repositories:
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 ; add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirror.biznetgio.com/mariadb/repo/10.4/ubuntu bionic main'

apt update ; apt install -y build-essential software-properties-common curl gdebi net-tools wget curl sqlite3 dirmngr nano lsb-release apt-transport-https leafpad apache2 mariadb-server

a2enmod proxy proxy_http ; mysql_secure_installation

Create Mariadb Database :
mysql -u root -p
create database db;
grant all on db.* to 'dbuser'@'localhost' identified by 'dbpass';
flush privileges;
quit

wget https://github.com/usefathom/fathom/releases/download/latest-development/fathom-linux-amd64
mv fathom-linux-amd64 /usr/local/bin/fathom  ; chmod 755 /usr/local/bin/fathom

leafpad .env &>/dev/null
FATHOM_SERVER_ADDR=9000
FATHOM_DEBUG=true
FATHOM_DATABASE_DRIVER="mysql"
FATHOM_DATABASE_NAME="db"
FATHOM_DATABASE_USER="dbuser"
FATHOM_DATABASE_PASSWORD="dbpass"
FATHOM_DATABASE_HOST="localhost"
FATHOM_DATABASE_SSLMODE=""
FATHOM_SECRET="random-secret-string"

fathom --config=.env user add --email=admin@yourdomain.com.com --password=yourpassword123
fathom server

nano /etc/systemd/system/fathom.service
[Unit]
Description=Fathom server management service unit
Requires=network.target
After=network.target

[Service]
Type=simple
User=root
Restart=always
RestartSec=3
WorkingDirectory=/root
ExecStart=/usr/local/bin/fathom server

[Install]
WantedBy=multi-user.target
systemctl daemon-reload ; systemctl enable fathom ; systemctl start fathom ; systemctl status fathom

leafpad /etc/apache2/sites-available/yourdomain.conf &>/dev/null
<VirtualHost *:80>
    ServerName yourdomain.com
    ServerAdmin admin@yourdomain.com
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:9000/
    ProxyPassReverse / http://127.0.0.1:9000/
    TransferLog /var/log/apache2/yourdomain_access.log
    ErrorLog /var/log/apache2/yourdomain_error.log
</VirtualHost>

a2ensite yourdomain ; a2dissite 000-default.conf  ; apache2ctl configtest ; echo "192.168.1.50 www.yourdomain.com" >> /etc/hosts ; systemctl reload apache2
http://www.yourdomain.com

Example email=admin@yourdomain.com.com  || password=yourpassword123

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment