Web site and server analytics on a budget.
Background and motivation
Running web sites on a budget is not too hard (especially for Apache, PHP, Mysql people like us) but monitoring web site and server activity is not so easy (and obviously we do not want to spend any money for it).
This tool is suitable for people running their own web sites on their own VMs, droplets etc. You must be able to run operating system commands on your server to run the log processing component and you should know how to deploy PHP apps. You can monitor web site and operating system metrics with minimal effort.
You need to run the log processor, https://github.com/SBOsoft/SBOLogProcessor, to collect web server access logs, web site metrics and operating system metrics. It will monitor your access logs, generate metrics and optionally save logs to a database (for now only mysql is supported).
Use this application to view metrics and logs collected by the log processor. Data generated by the log processor will be saved in a mysql database. SBOanalytics will read data from the mysql database and allow users to view metrics and/or logs.
You can try it yourself using the live demo at https://www.sbosoft.net/sboanalytics-demo/ui/. The demo has minimal data but should give you an idea.
Apache, Php 8.x, Mysql 8.x (tested on 8.4 but it should work with other 8.x versions as well) environment with pdo, pdo mysql support.
By default only deployments on an Apache web server with PHP 8.x are supported. If you want to deploy on a different environment then you will need to migrate url rewrite rules from webapp/DocumentRoot/.htaccess to the other environment.
- Clone the repository from https://github.com/SBOsoft/SBOanalytics.
- containers folder contains docker files and docker-compose.yml. variables.env files in each folder, e.g containers/web/variables.env, contain container settings. containers/web folder contains a dummy private key and certificate, which you should ideally replace with your own.
- db folder contains database scripts which will be applied to the mysql container. Database files will be stored in containers/mysql_data folder which will be mounted by the mysql container.
Warning: Authentication is disabled by default when using the setup in containers folder. It's not for production use.
To set up the containers, change into the containers folder and run docker-compose -f docker-compose.yml build
and then docker-compose -f docker-compose.yml up -d
.
- Go to https://github.com/SBOsoft/SBOanalytics/releases and download a release package, i.e SBOanalytics-xxxx.xx.xx.xxx.zip.
- Copy the zip file into a new folder and unzip it
- Review the .htaccess file in the package. The .htaccess file contains multiple SetEnv directives which are commented out by default. Environment variables are used for application configuration. You can either set them in the .htaccess file or in your VirtualHost configuration. Setting them up in VirtualHost configuration will allow for easier updates. If you set them in the .htaccess file then during upgrades you will need to migrate your changes to the .htaccess file manually.
- Just placing the folder to a path under a php enabled virtual host will work
- To upgrade, download a release package, extract into a new folder and replace your existing deployment folder with the new one after migrating the changes in your existing .htacess file. Do NOT replace the new .htaccess with your existing .htaccess file as there maybe changes required for the new version to function properly.
- Review db/db-for-new-installations.sql file in the package. (Ignore db/upgrades folder for new installations)
- Create a new database for SBOanalytics (or use an existing database, all tables have sbo_ prefix)
- Run db/db-for-new-installations.sql
- To apply database updates, review the files in db/upgrades/ folder in the release package. Run .sql files with names after your old version. For example if your old version was 2025.07.25.0001 you need to run all files with names after 20250725*.sql in db/upgrades folder. You MUST run sql files in alphabetical order.
Please review webapp/DocumentRoot/.htaccess before deployments and upgrades. You can define the required environment variables in VirtualHost settings, e.g /etc/apache2/sites-enabled/yoursite.conf, and leave .htaccess as is. If you set environment variables in the .htaccess file then you will need to manually apply your changes during upgrades. If you configure environment variables in the virtual host and keep the .htaccess file intact then you will not need to manually migrate configuration changes during upgrades.
- SBO_AUTH_TYPE authentication type, only supported values are none and single at the moment. Anonymous access will be enabled when SBO_AUTH_TYPE is none. When SBO_AUTH_TYPE is set to single then there will be only 1 user, defined by SBO_AUTH_SINGLE_USER and SBO_AUTH_SINGLE_PWD environment variables.
- SBO_DB_HOST mysql database host, such as 127.0.0.1 or 127.0.0.1:12345 where 12345 is the mysql port number.
- SBO_DB_NAME name of the sboanalytics database
- SBO_DB_USER mysql user
- SBO_DB_PASSWORD mysql password
- SBO_AUTH_SINGLE_USER username for SBO_AUTH_TYPE single
- SBO_AUTH_SINGLE_PWD password for SBO_AUTH_TYPE single
- SBO_ADMIN_SECRET secret required for accessing the settings page
Always review https://github.com/SBOsoft/SBOanalytics/blob/main/webapp/DocumentRoot/.htaccess for latest updates to configuration options and additional information.