When you want to check how fast/good is your internet connection, you usually do a speedtest. In some cases, you may even want to host such speedtest in your infrastructure (Local network, network of customers,…) or just to provide such service to your community.
Speedtest is a HTML5 self-hosted speedtest that can be installed easily on your server. It offers basic features such as:
- Download
- Upload
- Ping
- Jitter
- IP Address
- Telemetry (optional)
You can give it a try using the official demo.
Now, let’s see how to install speedtest on your own server (Debian in my case)
Installation
You will need first to have a LAMP server. If it is not the case, you can check my previous tutorial on how to install a LAMP server on Debian 9.
1) Install basic requirements
In root (or with sudo), simply run:
apt install libapache2-mod-php php-mcrypt
2) Tweak Apache and PHP configurations
You will need to set the “KeepAlive On” function in Apache and to increase the size limit/memory limit of PHP. Still in root, or with sudo, run:
nano /etc/apache2/apache2.conf
and look for the value KeepAlive. Ensure it is “on” and uncommented.
Now modify php configuration:
nano /etc/php/7.0/apache2/php.ini
And modify the values:
max_execution_time = 90 max_input_time = 90 memory_limit = 128M post_max_size = 50M upload_max_filesize = 50M
And restart Apache
service apache2 restart
3) Clone their repo
You will need git first, then you can clone
apt install git
cd /var/www
git clone https://github.com/adolfintel/speedtest
cd speedtest
Now select one of the speedtest design example to be the main page. You can have more detail here. The best starting point is the example-pretty.html. Simply copy it as index.html
cp example-gauges.html index.html
4) Create a dedicated virtualhost
To server this page as a domain name or subdomain name, you can create a dedicated virtualhost. Here is how I did
sudo nano /etc/apache2/sites-available/speedtest.conf
And add
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName speed.domain.tld
DocumentRoot /var/www/speedtest
<Directory /var/www/speedtest>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/speedtest_error.log
CustomLog ${APACHE_LOG_DIR}/speedtest_access.log combined
</VirtualHost>
Enable the configuration
sudo a2ensite speedtest
and reload your configuration
systemctl reload apache2
Now you should have access to your own speedtest!
That’s it!
You can do further tweak on the configuration, especially on the TCP part, as explained in their github repo.