Enabling mcrypt for php >= 5.4 in Ubuntu 13.10

Ubuntu 13.10 (Saucy) comes with PHP 5.5.3 and does not enable mcrypt by default. I am currently working on a personal project that requires to use mcrypt to encrypt and decrypt data. So I will need to enable it manually.

To enable mcrypt is easy, simply following the steps below:

$ sudo mv /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/
$ sudo php5enmod mcrypt
$ sudo service apache2 restart

What “php5enmod” does is simply enabling a PHP5 module by creating a symbolic link from conf.d directory to the real config file under “mods-available”.

So, after we run “php5enmod mcrypt” command, the following files will be created:


which are symlinks to


The prefix “20” is the priority of module, and the default is 20 when you run “php5enmod” command.

If you don’t need the mcrypt module for the command line, you can simply remove the symlink under /etc/php5/cli/20-mcrypt.ini.

Hope this helps.

Remove .php Extension In Apache

If you have a small site without any framework that provides nice rewrite rules for you, but you still want to hide the “.php” extension from the rest of the world, then simply add the following lines into your virtual host configuration file under Apache or .htaccess file under the root of your host:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

And if you want to add the trailing slash to the URL, use the following code instead:

# the following deals with the removal of the extension
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php

# addition of the trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

For more information regarding apache’s rewrite module, please visit here.

Of course this would require the rewrite module to be enabled on the hosted server which I won’t cover in this post, please refer to Apache’s online documentation.

Ubuntu add php gd support to Apache

PHP is used mainly in server-side application software along with various addons. I have recently signed up a virtual server from VSPLAND with pre-configured LAMP, however,
the PHP5 doesn’t come with the GD support, which breaks my website.

The GD Graphics Library is for dynamically manipulating images, and it is a core part of my photo gallery application. Luckily Ubuntu (and Debian) comes with package called php5-gd, which simplifies the
solution to this problem.

Just type following command to install this module:

apt-get install php5-gd


sudo apt-get install php5-gd

Restart Apache

/etc/init.d/apache2 restart

Now you can print out the phpinfo() to see whether GD library is enabled or not, or simply type in

php -m

to see whether gd is in the result list or not.

Install Apache 2, MySQL 5, PostgreSQL 8 and PHP 5 under Ubuntu Desktop

Ubuntu is a free, open source Linux-based operating system that starts with the breadth of Debian and adds regular releases (every six months), a clear focus on the user and usability (it should “Just Work”, TM) and a commitment to security updates with 18 months of support for every release (and with 6.06 LTS you get 3 years on the desktop and 5 on the server!). Ubuntu ships with the latest GNOME release as well as a selection of server and desktop software that makes for a comfortable desktop experience off a single installation CD.

I recently got the Ubuntu desktop insallation CD from one of my friends in Hitwise, and successfully installed as dual boot on my home computer. The next step was to install all the server software necessary for me to setup the development environment at home.


I have found very easy steps to install Apache 2, PHP 5, MySQL 5 and PostgreSQL 8. All you need to do is to run the following command from the shell in Ubuntu, Upon password request, just enter the password for your personal account.

To install Apache 2

sudo apt-get install apache2-mpm-worker

To install MySQL 5

sudo apt-get install mysql-server

To install PostgreSQL 8

sudo apt-get install postgresql-8.1

To install PHP 5

autoconf automake1.4 autotools-dev libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php-pear php5-ldap php5-mhash php5-mysql php5-pgsql php5-mysqli php5-snmp php5-sqlite php5-xmlrpc php5-xsl php5-imap php5-mcrypt php5-pspell php5-gd

This command will install most commonly used PHP libraries.

It used to take me the whole day even without successfully installing and configure those software packages, but it only took me less than 2 hours to finish all the installation and configure properly to suit my needs on Ubuntu. Plus, I really like the interface of Ubuntu desktop and now I will move my freelance project development to Ubuntu environment from Windows.

A few reasons to install Ubuntu:
[li]Absolutely Free of Charge – you can download any time from their official website[/li]
[li]Fast, Easy Install – only around 10 mins[/li]
[li]Immediately Useful – contains all basic software for home and office applications[/li]
[li]More securer than Windows[/li]

The following are some screenshot I took from my Ubuntu desktop:

Directory Explorer


Firefox in Ubuntu


OpenOffice 2.0


I would recommand you guys to try it out and see whether you like it or not.