How to Install Open Web Analytics on nixOS Latest?

Open Web Analytics (OWA) is an open source web analytics software that can be used to track and analyze website traffic. Here is a step-by-step guide on how to install OWA on nixOS Latest.

Prerequisites

Before installing OWA, you should have the following prerequisites installed on your nixOS Latest system:

  • Nginx
  • PHP (version 7.4 or higher)
  • MySQL or MariaDB

Step 1: Install Nginx, PHP, and MySQL

First, update your package lists and then install Nginx, PHP, and MySQL/MariaDB:

sudo nix-channel --update
sudo nix-env -i nginx php mariadb

Step 2: Configure MySQL/MariaDB

Next, you will need to create a database and user for OWA in MySQL/MariaDB. To do this, start the MySQL/MariaDB client:

sudo mysql

Then, create a database for OWA:

CREATE DATABASE owa;

Create a user and grant it access to the database:

CREATE USER 'owauser'@'localhost' IDENTIFIED BY 'owapassword';
GRANT ALL PRIVILEGES ON owa.* TO 'owauser'@'localhost';
FLUSH PRIVILEGES;

Replace 'owapassword' with a strong password of your choice.

Exit the MySQL/MariaDB client:

exit;

Step 3: Download and Extract OWA

Download the latest version of OWA from the official website and extract the archive:

wget https://github.com/padams/Open-Web-Analytics/archive/1.7.6.tar.gz
tar -xvf 1.7.6.tar.gz

Move the extracted files to the Nginx web root directory:

sudo mv Open-Web-Analytics-1.7.6 /usr/share/nginx/html/owa

Step 4: Configure Nginx

Create a new Nginx configuration file for OWA:

sudo nano /etc/nginx/conf.d/owa.conf

And paste the following configuration:

server {
    listen 80;
    server_name example.com; # Replace with your domain name
    root /usr/share/nginx/html/owa;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Replace 'example.com' with your domain name or server IP address.

Save the configuration file and exit.

Step 5: Install Dependencies and Run Installer

OWA requires some dependencies that can be installed using the following command:

sudo nix-env -i php-mysql php-gd php-mbstring php-zip

Next, navigate to the OWA directory and run the installer script:

cd /usr/share/nginx/html/owa
sudo php bin/owa-install.php

The installer will prompt you to enter the database details that you created earlier. Follow the instructions and complete the installation.

Step 6: Finalize Configuration

After the installation is complete, you will need to finalize the configuration by editing the config.php file:

sudo nano /usr/share/nginx/html/owa/config.php

Change the following lines to match your database settings:

define('OWA_DB_HOST', 'localhost');
define('OWA_DB_NAME', 'owa');
define('OWA_DB_USER', 'owauser');
define('OWA_DB_PASSWORD', 'owapassword');

Replace 'owapassword' with the password you set earlier.

Save the config.php file and exit.

Step 7: Restart Nginx

Restart the Nginx web server so that the changes take effect:

sudo systemctl restart nginx

Step 8: Access OWA

You should now be able to access the OWA dashboard by visiting http://example.com/owa/ in your web browser, where 'example.com' is your domain or server IP address.

Conclusion

You have now successfully installed Open Web Analytics on nixOS Latest. You can use OWA to track and analyze website traffic, and customize it as needed.