On Ubuntu or Debian:

apt-cache search php|egrep ^php5-<br /> apt-get install php5-mcrypt<br />

Ref: Install php extensions on ubuntu