Next Previous Contents

3. Requirements

Your web site must be running on the Apache web server. You must also have PHP4 or PHP5 running on the server. Preferably, your web site should be running on a server that is using Linux as the operating system.

NOTE: This package will probably work OK on a Windows Server, however, as of the date of this writing, it has not been tested other than with several Linux Servers.

3.1 File Requirements

If you've downloaded the complete countryhtblock.tar.gz package or package, then you have almost everything you need. You will also need one more file which contains all of the country and ip address info.

You have your choice of two different databases.

One can be downloaded from This file is called ip-to-country.csv and can be found in the downloads section of their website. On the website, the downloadable file is called

The other one can be found at This file is called GeoIPCountryWhois.csv once it is unzipped. In it's zipped format when you download it, it is called It's also found as GeoIP-lite on the site. This is the free download. You can also use their more accurate GeoIP file from their paid service. Be sure to get the .csv version and not the binary version.

Whichever file you choose, be sure to unzip it and copy it to the directory you will be using for this package.

The file you download from one of these two souces is used just one time during the initial setup. The information database is built from the file and is used for the operation of the programs in this package.

However, once you begin using this package, you will want to check periodically for new updates to the database file that you choose to use. Both database files are updated approximately every month or so.

NOTE: For the rest of this documentation, the country database file you have chosen to use will be referred as the ".csv database file".

3.2 Summary of setup

Here's a brief summary of what you need to do to get this entire package running:

  1. Download and unpack or unzip this package.
  2. Download either the IP-TO-COUNTRY or the MaxMind database file and unpack it.
  3. Create two new directories with "hard to guess" names on your website.
  4. Upload all the files to the two new directories.
  5. Run the countryhtsetup.php program from this package to set up all the database files that are used by countryhtaccess.php and iptocountry.php
  6. Run countryhtaccess.php to select the countries you wish to block.
  7. Create one or more .htaccess files or modify your existing ones.

Optionally (or instead): Run iptocountry.php to look up countries according to their IP address.

For a much more detailed installation description, keep reading...

Next Previous Contents