Step 1

If you are using debian or ubuntu, install the mod-geoip package.

sudo apt-get install libapache2-mod-geoip


Step 2
Enable GeoIPEnable, edit geoip.conf

GeoIPEnable On


Step 3
Find Country Code Lookup:

In Apache vhosts file, outside of the </Directory> tags:

<Location />
        ##ISO 3166 Country Codes
        ## Block China
        ## Block Costa Rica
        ## Block Russia
        SetEnvIf GEOIP_COUNTRY_CODE CN BlockCountry
        SetEnvIf GEOIP_COUNTRY_CODE RU BlockCountry
        SetEnvIf GEOIP_COUNTRY_CODE CR BlockCountry
        Deny from env=BlockCountry

Step 4
service apache2 restart