Next Previous Contents

5. Build the database

The work of creating the database files is all handled by the countryhtsetup.php program. It will do all the work for you while you sit back and wait for it to finish.

If you think you're ready, go ahead and click on "Generate Database".

Go to the refrigerator and get a Coke or something. Don't be alarmed, on a slow server, this can take several minutes. It might appear as though your web browser is stalling, but it's just waiting for the page to come back after all the new files are created. Be patient.

There are 256 files being created, all beginning with a number from 0 to 255 and ending with .php. Also, one additional file called countries.php will be created at the end. These are all being created in your "country2" directory.

Don't interrupt the process - don't hit the stop button in your browser. Give it time to complete the task of building the files.

A modern-day fast server will probably get the job done quite rapidly, but some of us are still using some older equipment.

NOTE: If something goes wrong or the process gets interrupted, don't panic. Just do it again. Any existing files that were created will be deleted and replaced by new ones. This would be no different than the actual process of updating each month when an updated .csv database file is installed.

When your browser comes back to life, the setup job should be all finished. However, if something went wrong, you'll likely see an error message of some sort, most likely from php complaining that it can't create the files. Check the permissions applied to the directory you are using. That should be the only problem you are likely to encounter.

I doubt the problem would be a lack of disk space. Most users nowadays have gigs and gigs of storage space. In any case, the php files take up very little space, the .csv file eats up about 3MB-6MB and the newly created database files use about another 3MB-5MB. Plus later on, after selecting the countries you wish to block, a little more disk space will be used, but it's very minimal. So, less than 7MB-12MB of free space will do the job. If you don't have that much available, I'd be looking for another host to run your web site on.

5.1 Updating the database

Now that the database files are built, we are all done with both the .csv database file and the countryhtsetup.php file. However, the .csv database file gets updated periodically, maybe every couple of months or so. Whenever that happens, just go download a new version of it, copy it in place of the existing .csv database file and then rerun the countryhtsetup.php program either by loading it directly into your browser or by accessing it from the menu.php file in your country2 directory and clicking on "Database Setup". It will upgrade all the existing database files for you. It's as simple as clicking on "Generate Database".

NOTE: You will also want to rerun countryhtaccess.php which is described later on.

Whenever you recreate new updated database files, the countries.php file is also recreated. This file stores the list of countries that you wish to block. Your existing settings will be preserved and restored when the new countries.php file is created.

NOTE: If you decide to switch from one database to the other (IP-to-Country vs. MaxMind), be sure to either delete the countries.php file or rename it to something else if you'd like to preserve it. The reason for this is due to the slightly different names each database gives to some of the countries. When you switch, your default settings are not preserved. This need not be done if you stick with the same database provider.


Next Previous Contents