Wordpress Permalinks with Lighttpd

Friday, April 11th, 2008

I found few url-rewrite based solution for enabling Permalinks in Wordpress+Lighttpd but none of them worked flawlessly. Guys, all we need here is a simple equivalent of this code (without any side effect, like 404 header etc).

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

So I continued searching for the perfect solution, and here is what I found. It works like charm on Wordpress 2.5 :-) Another victory for KISS! (keep it sweet and simple)

Content of /etc/lighttpd/lighttpd.conf

$HTTP["host"] =~ “dev\.sudhaker\.com$” {
server.document-root = “/shared/sites/htdocs_wordpress”
magnet.attract-physical-path-to = ( server.document-root + “/rewrite.lua” )
}

Please make sure mod_magnet is enabled :-)

And content of $WP_ROOT/rewrite.lua

attr = lighty.stat(lighty.env["physical.path"])

if (not attr) then
lighty.env["uri.path"] = “/index.php”
lighty.env["physical.rel-path"] = lighty.env["uri.path"]
lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. lighty.env["physical.rel-path"]
end

A similar workaround for Drupal is suggested here :-)

Note: It only works on lighttpd 1.4.2+ ;-)

Cheers,
Sudhaker

Drupal Clean URL with Lighttpd

Friday, April 11th, 2008

I found few url-rewrite based solution for enabling CleanURL in Drupal + Lighttpd but none of them worked flawlessly. Guys, all we need here is a simple equivalent of this code (without any side effect, like 404 header etc).

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

So I continued searching for the perfect solution, and here is what I found. It works like charm on Drupal5 and Drupal6 :-) Another victory for KISS! (keep it sweet and simple)

Content of /etc/lighttpd/lighttpd.conf

$HTTP["host"] =~ "dev\.sudhaker\.com$" {
  server.document-root = "/shared/sites/htdocs_drupal5"
  magnet.attract-physical-path-to = ( server.document-root + "/rewrite.lua" )
}

Please make sure mod_magnet is enabled :-)

And content of $DRUPAL_ROOT/rewrite.lua

attr = lighty.stat(lighty.env["physical.path"])

if (not attr) then
  lighty.env["uri.query"] = "q=" .. lighty.env["uri.path"]
  lighty.env["uri.path"] = "/index.php"
  lighty.env["physical.rel-path"] = lighty.env["uri.path"]
  lighty.env["physical.path"] = lighty.env["physical.doc-root"] .. lighty.env["physical.rel-path"]
end

A similar workaround for Wordpress is suggested here :-)

Note: It only works on lighttpd 1.4.2+ ;-)

Cheers,
Sudhaker

Install Firefox without adminstrator rights

Monday, March 24th, 2008

Source: WikiPedia

Mozilla Firefox (abbreviated officially as Fx, but also unofficially as FF) is a web browser descended from the Mozilla Application Suite, managed by the Mozilla Corporation. Firefox had about 15% of the recorded usage share of Web browsers as of January 2008 making Firefox the second-most popular browser in current use worldwide after Internet Explorer.Firefox uses the open-source Gecko layout engine, which implements some current Web standards plus a few features which are intended to anticipate likely additions to the standards.

Firefox includes tabbed browsing, a spell checker, incremental find, live bookmarking, a download manager, and a search system that uses Google. Functions can be added through around 2,000 add-ons created by third party developers;[2] the most popular include NoScript (script blocker), FoxyTunes (controls music players), Adblock Plus (ad blocker), StumbleUpon (website discovery), DownThemAll! (download functions) and Web Developer (web tools).

Firefox runs on various versions of Microsoft Windows, Mac OS X, Linux, and many other Unix-like operating systems. Its current stable release is version 2.0.0.12, released on February 7, 2008. Firefox’s source code is free software, released under a tri-license GPL/LGPL/MPL.

No wonder why you want to use Firefox for your day to day browsing experience. But your network administrator has not given you required rights and you are unable to install this wonderful browser on your laptop/desktop. Pretty bad, huh!

Well, there is an easy answer to it without breaking any rules.

Browse to PortableApps and download Mozilla Firefox, Portable Edition. Install it on to USB drive (or any local writable folder) and ENJOY!

This technique can be useful even if you have administrator rights. With Firefox your private information (like cookie, history, bookmarks, cache etc) are stored on the disk and exposes some risk. My suggestion will be to create a virtual encrypted disk using TrueCrypt and install Firefox PE into that. Now you can relax because your private informations are secured using some strong encryption algorithms.

Cheers,

Do not leak your million dollar idea unknowingly

Thursday, March 13th, 2008

Tom is discussing his next venture with his friend Sameer. They have done all the number crunching and are very excited about the opportunity. Everything is finalized and details are worked out. Right, they must be talking about an internet based idea (similar to youtube, orkut, facebook etc).

Next big thing is finding and reserving a perfect domain name for the operation. They started their favorite browser Firefox and jumped on to one of very popular registrar’s website. They started searching their name. They did like some of them but not very catchy. All of sudden someone popped the “perfect name” and got excited to find that it is still available. BINGO! They are happy but still not sure so did not reserve the domain name. They wanted to discuss more and decided to wait for few more days.

After 3 days when they were finally ready to register the domain :-) Guess what? It’s gone! They now see a web-spam there which is trying to sell everything from Viagra to “cheap flight tickets”.

This domain was not taken by anyone for years. What happened all of sudden? YOU LEAKED YOUR IDEA.

It is no longer a trade secret that domain-registrars sell their domain search history to “domain junkies” for a decent subscription fee. These junkies grab any good and catchy names immediately and try to re-sell it for bigger bucks. Many simply add them to their pool of domains engaged in pay-per-click based advertisement.

Moral of story is “never wait after finding your perfect domain, reserve it immediately”. If you still want to go with search and wait policy, do not use any registrar site to perform search queries. This can be also done using “whois” command that comes with most of Linux distributions.

A second piece of advice is “make sure you also reserve any similar domains names”. As an example, if you are planning to launch next cool hot deal site http://x1deals.com ; you should also reserve http://x1deal.com ; There can be a big loss due to typo-traffic (traffic generated by typing mistakes) and junkies are hunting for such opportunities.

Hope this helps in saving your next “million dollar idea” :-)

Cheers,
Sudhaker

Google Sites makes Google Apps platform more complete

Monday, March 10th, 2008

I am using “Google Apps” for a long time to host email for my domains. It is not very complex to setup and works great (powered by gmail - wow)! I don’t have to worry about my mails being delivered to spam-folder or being rejected because my shared host IP was misused by other folks. “Google Apps” has a friendly limit of 500 emails per day, which is pretty decent for a normal usage.

The initial web builder was pretty basic and barely enough for “Hello world” or “Under construction”.

Things has become even better with “Google Sites” release, I’m playing with this new google-toy and will update this article very soon with my findings.

Cheers,

Gmail IMAP with SquirrelMail

Tuesday, February 26th, 2008

Friends,

I am listing steps required for setting up SquirrelMail to work with Gmail IMAP. This is especially useful when you like SquirrelMail or don’t have access to regular http://mail.google.com :-) You can even use it to brand your custom domain hosted at Google Apps and seamlessly integrate it your portal (if you can afford, consider buying Google’s Premium Edition which comes with API access at $50/user/year).

Steps:

Create a place holder for SquirrelMail and unpack the latest distribution

mkdir -p /home/squirrel/data/attachments
cd /home/squirrel/
chown -R apache.apache data
tar zxvf ~/downloads/squirrelmail-1.4.13.tar.gz

Configure the installation (do nothing simply save and quit).

cd squirrelmail-1.4.13
./configure

Append following lines into /home/squirrel/squirrelmail-1.4.13/config/config_local.php

$domain = ‘gmail.com’;
// IMAP settings
$imapServerAddress = ‘imap.gmail.com’;
$imapPort = 993;
$use_imap_tls = true;
$imap_auth_mech = ‘login’;
// SMTP settings
$smtpServerAddress = ’smtp.gmail.com’;
$smtpPort = 465;
$use_smtp_tls = true;
$smtp_auth_mech = ‘login’;
// Special folder setting
$trash_folder = ‘[Gmail]/Trash’;
$sent_folder = ‘[Gmail]/Sent Mail’;
$draft_folder = ‘[Gmail]/Drafts’;
// Attachment
$data_dir = ‘/home/squirrel/data/’;
$attachment_dir = ‘/home/squirrel/data/attachments/’;
// Optional -
$provider_name = ‘Gmail alternative by Sudhaker’;
$provider_uri = ‘http://sudhaker.com/’;

Create an alias in apache /etc/httpd/conf.d/squirrel.conf

Alias /sq “/home/squirrel/squirrelmail-1.4.13″
<Directory “/home/squirrel/squirrelmail-1.4.13″>
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>

Verify the setup by browsing to ${site_url}/sq/

User Id: example@gmail.com (or user@example.com)
Password: email_password

Please make appropriate changes for cPanel based hosting (shared hosting).

Please follow following step if SELinux is enabled.

[root@centos ~]# setsebool httpd_can_network_connect true

Please drop a comment if you find it useful.

Cheers,
Sudhaker