RSS
people

Setup IP to city/country detection using geoIP in php

Following instructions are for apache on ubuntu.

# Install GeoIP module for php5
sudo apt-get install php5-geoip
 
# Restart Apache
sudo /etc/init.d/apache2 restart
 
# Now, the country wide data is automatically installed with geoIP module. 
# But, if we want to have it at city level - we need to download the data.
# Here we are downloading the free database. Steps for paid database will be same
wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
 
# Now, extract the file
gunzip GeoLiteCity.dat.gz
 
# Time to copy the file to proper location
sudo cp GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat

Please note that we changed the name of the file. In case of paid version, changing the name won’t be required.

{EAV:a82470a74d7b9ec4}

No Comments | Tags: , , , , , ,

My Experiments with AWS – 3 : lamp server, Elastic IP, DNS for ec2

Now that we can connect to the ec2 instance – we want to setup a basic website. I use ubuntu AMI – so, following instructions are for ubuntu. Similar instructions for other platforms can be ported as well.

Installing LAMP Server

# install Apache , PHP and MySql as a package
sudo tasksel install lamp-server
# we may want to enable some of the apache modules
# without rewrite = rewriting URLs will not work
sudo a2enmod rewrite
# headers and expires module will help in performance
sudo a2enmod headers
sudo a2enmod expires

read more »

1 Comment | Tags: , , , , , , ,

How to write a tiny URL service using Redis, PHP and Apache

There are so many tiny URL services out there. But, sometimes using those may not be suitable for your particular purpose for some reason. I faced a similar situation and came out with a decent solution using Redis (Thanks to @antirez for this brilliant key-value store), PHP and Apache. I used Predis, PHP client library for redis, to connect to redis server.
read more »

No Comments | Tags: , , ,

Deny directory listing using .htaccess

When you do not have an index.html (or index.php) in your folder, then people can see the listing of all the files by typing the URL of that folder. So, if the server does not deny it by default, an user can see the content of the folder.

We can use htaccess file to prevent it.

Step 1.
Create a file name .htaccess in your folder. (If you already have one, open it and edit)
Step 2.
To ignore all file listing, Write: IndexIgnore *
To ignore special file listings, Write: IndexIgnore *.zip *.gif
(The line above will list all files except the files having zip and gif as extension.

Sometimes, the opposite is required. That means, server denies the directory listing by default but you want to enable it for some reason. This can be achieved using htaccess as well.

Step 1.
Create a file name .htaccess in your folder. (If you already have one, open it and edit)
Step 2.
Write: Options +Indexes

No Comments | Tags: ,