Host Your Own Internet Speed Tester With LibreSpeed

Basic Installation

  1. Log into the Debian/Ubuntu device
  2. Run the following commands in a terminal:
    # update repositories and install any available software updates
    sudo apt update
    sudo apt upgrade
    # install Apache HTTPD, PHP and GIT
    sudo apt install git apache2 php libapache2-mod-php
    # clone the git repo
    sudo git clone https://github.com/adolfintel/speedtest /var/www/html/speedtest
    sudo cp /var/www/html/speedtest/example-singleServer-gauges.html /var/www/html/speedtest/index.html
    # set the owner of the new speedtest directory to www-data
    sudo chown -R www-data:www-data /var/www/html/speedtest
  3. Open a web browser and navigate to http://DNSorIP/speedtest
  4. The basic speed test functionality will be available, but it lacks the abillity to save and share speed test results. Let's add a database to enable those features

Optional Advanced Installation Steps

  1. Continue the installation by running the following commands in a terminal:
    # install MySQL/MariaDB
    sudo apt install mariadb-server mariadb-client php-mysql
    sudo su
    mysql_secure_installation
  2. Press Enter to login as root
  3. Type Y and press Enter to set a root password, type the password twice to confirm
  4. Type Y and press Enter to remove anonymous users
  5. Type Y and press Enter to disallow root login remotely
  6. Type Y and press Enter to remove the test database
  7. Type Y and press Enter to reload privilege tables
  8. Run the following command to login into MySQL: mysql -u root -p
  9. Authenticate with the root password set earlier
  10. Run the following commands to create the speedtest database and database user MariaDB [(none)]> CREATE DATABASE speedtest;
    MariaDB [(none)]> GRANT ALL ON speedtest.* to 'speedtest'@'localhost' IDENTIFIED BY 'Sp33dTest!!';
    MariaDB [(none)]> FLUSH PRIVILEGES;
    MariaDB [(none)]> USE speedtest;
    MariaDB [(none)]> \. /var/www/html/speedtest/results/telemetry_mysql.sql
    MariaDB [(none)]> EXIT;
    exit
  11. Continue with the following commands to setup the speedtest database
    # edit telemetry_settings.php
    sudo nano /var/www/html/speedtest/results/telemetry_settings.php
  12. Verify/change $db_type = 'mysql';
  13. Change $stats_password = 'P@$$w0rD';
  14. Change $enable_id_obfuscation = true;
  15. Update the Mysql Settings variables to the credentials created earlier

    $MySql_username = 'speedtest';
    $MySql_password = 'Sp33dTest!!';
    $MySql_hostname = 'localhost';
    $MySql_databasename = 'speedtest';

  16. Press CTRL+O, Enter, CTRL+X to write the changes to telemetry_settings.php
  17. Continue with the following commands in terminal:
    # copy an example page with telemetry enabled
    sudo cp /var/www/html/speedtest/example-singleServer-full.html /var/www/html/speedtest/index.html
    # restart the apache2 service to enable MySQL
    sudo systemctl restart apache2
  18. Open a web browser and navigate to http://DNSorIP/speedtest
  19. This time around the speedtest results have been saved to the database and a link is provided to share the results

More Info: https://github.com/librespeed/speedtest