Tuesday, January 15, 2013

Why upgrade to Gimp 2.8

After a rather long wait, Gimp has finally rolled out the new version 2.8 . This version comes with most of the features I was missing in the previous version. The new Gimp 2.8 has

Single window mode : I am out of words how much I was waiting for this.

Multi-column dialogs : It's just so useful when you are doing some complex designs. and have to use two dialogs at the same time without letting yourself bogged down with multiple windows.

Group Layers: Anybody who worked on Photoshop was missing this here. Thanks to the developers for this nice update.

Detailed release notes : http://www.gimp.org/release-notes/gimp-2.8.html

Monday, January 14, 2013

.htaccess in apache2.2/2.4 on Ubuntu LAMP setup

.htaccess not working after installing Apache

htaccess files don't work on Apache server server by default and anybody who moved from using wamp/xampp to apache encounter this problem.

htaccess is a file which can be placed in the folders of document root and is meant to override apache configurations for that particular folder. It is loaded by apache while serving request i.e. during runtime. htaccess being located inside the document root can be accessed by anybody editing the application and thus pose a security risk by it's ability to override server configuration. Hence, an Apache installation installed with default virtual hosts in /etc/apache2/sites_available/ have htaccess disallowed.

But wait! I have used wamp without any such configuration. Why this mess? If you have any experience with XAMPP or WAMP, you might have noted they allow the htaccess files by default. The reason is that while these two are for development purposes only, Apache on Linux is built for production environments. Hence, it has most of the security arrangements in place by default.

So what should you do?

It is therefore recommended to add the htaccess commands inside a directive tag in the apache configurations. Edit the virtual host file under
/etc/apache2/sites-available/
and replace
Allowoverride None with Allowoverride all . Save the file and reload apache server with

sudo service apache2 reload

Now the .htacces files located in the document folder should start working.

Why not to use .htaccess? What could be problems with .htaccess?

On a production environment, if you have access to the apache configuration files, it's always better to edit apache.conf or virtual-hosts file instead of allowing .htaccess. Why?
It decreases server load, decreases page load time resulting in better user experience. If htaccess is set to allowed and you are serving a request for /scripts/js/jslib/myjavascript.js, the server searches for a .htaccess at each folder i.e. it first searches for /.htaccess, then /scripts/.htaccess ,then /scripts/js/.htaccess ,then /scripts/js/js-lib/.htaccess . This has a direct effect on server load.

How to edit apache configuration instead of allowing .htaccess?

Case: You need to put a .htaccess file in the folder /var/www/master/ to redirect users from example.com to www.example.com. Thus, the contents of your .htaccess should be roughly the following
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php

Alternative: Edit the apache virtual host file corresponding to your site and add the following directive instead inside the virtual host tags

<VirtualHost *:80>
 ......
 <Directory /var/www/master/>
  RewriteEngine on
  # if a directory or a file exists, use it directly
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  # otherwise forward it to index.php
  RewriteRule . index.php
 </Directory>
 .....
</VirtualHost>

Reference :
1. http://httpd.apache.org/docs/2.2/howto/htaccess.html#when