Lots of ways to do this, here's a good example that doesn't require a database:
https://www.kavoir.com/2010/05/simplest-php-hit-counter-or-download-counter-count-the-number-of-times-of-access-visits-or-downloads.html