RSS
people

Highlight terms while tailing a log

Sometimes I want to keep tailing a log and look for a term – for example if you are an e-commerce platform then you may like to keep a running tail somewhere while keeping en eye on “checkout” page.

Following code snippet will highlight the term:

tail -f /var/log/apache2/access.log | perl -p -e 's/(checkout)/\033[46;1m$1\033[0m/g;'

You can highlight two such terms as well:

tail -f /var/log/apache2/access.log | perl -p -e 's/(checkout|another)/\033[46;1m$1\033[0m/g;'

Any perl regex should work for the highlighting, if your terminal supports it.

No Comments | Tags: , , , ,

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: , , , , , , ,

My Experiments with AWS – 2 : Connect to EC2 instance

In order to connect with an ec2 instance there are three prime prerequisites:

  • The key file (.pem extension) created while launching an EC2 instance in AWS.
  • Port 22 of the instance is open while launching the instance.
  • Know the public DNS of your EC2 instance.

read more »

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

My Experiments with AWS – 1 : Basics of Amazon Web Services

I have been with dreamhost for 1400 days before I opted to move everything to AWS. I did not had any particular problem with dreamhost. They are good and their support is even better but I wanted to explore AWS, move away from my comfort zone of hosted services, get my hands dirty and learn things in the process. I will be documenting the solutions of the common problems I face and their solutions.

Starting with the basics – AWS pricing structure can be a pain to understand for normal users as they charge for storage, computation, bandwidth etc. They provide a free tier for first year for new customers – which is a plus. For normal usage, one will not even pay anything for first year.

read more »

2 Comments | Tags: , , , , , , ,