Installing & configuring Lighttpd with PHP on FreeBSD

Recently, I had to install Lighttpd on a FreeBSD server. Now generally I install Apache as a web server, but this time because of the gains that Lighttpd has over Apache, I decided to give it a go. The following instructions have been primarily taken from http://trac.lighttpd.net/trac/wiki/TutorialInstallation, some changes primarily being for the path to more suit FreeBSD defaults.

Install lighttpd from ports (Update the ports tree before this)

cd /usr/ports/www/lighttpd
make install clean

Make sure you have enabled FastCGI support in PHP.

Enable Lighttpd in rc.conf and edit it’s configuration:

echo lighttpd_enable="YES" >> /etc/rc.conf
cd /usr/local/etc/
cp lighttpd.conf.sample lighttpd.conf

Create some directories and files:

mkdir /usr/local/www/lighttpd
mkdir /usr/local/www/lighttpd/log
mkdir /usr/local/www/lighttpd/data

touch /usr/local/www/lighttpd/log/lighttpd.error.log
touch /usr/local/www/lighttpd/log/lighttpd.access.log

Make your new directories and files accessible by the user and group “www” that Lighttpd operates as:

chown -R www:www /usr/local/www/lighttpd

Edit lighttpd.conf

vi /usr/local/etc/lighttpd.conf

Change the values for directories and files as follows:

server.document-root = "/usr/local/www/lighttpd/data" 
server.errorlog = "/usr/local/www/lighttpd/log/lighttpd.error.log" 
accesslog.filename = "/usr/local/www/lighttpd/log/lighttpd.access.log"

Save and exit from the editor.

Test to make sure Lighttpd starts up properly:

/usr/local/etc/rc.d/lighttpd start

If you need to, you may shutdown lighttpd this way:

 /usr/local/etc/rc.d/lighttpd stop

And then restart it with this:

/usr/local/etc/rc.d/lighttpd restart

If you get an error that says “permission denied”, check to make sure that the files and directories mentioned exist AND that user www has permission to operate on them. Also be sure that lighttpd.conf has been corrected from the non-working default version. If you get no errors, put an HTML file in /usr/local/www/lighttpd/data and try to load it up in your browser. If everything works, now enable PHP.

Edit lighttpd.conf once again

# vi /usr/local/etc/lighttpd.conf
  • In section “server.modules” uncomment the line “mod_fastcgi”
  • Uncomment the entire section “fastcgi.server”
  • Add the following lines under “socket” in the “fastcgi.server” section:
		"bin-path" => "/usr/local/bin/php-cgi",
		"broken-scriptfilename" => "enable"

Now make some more files and directories:

mkdir /var/run/lighttpd
touch /var/run/lighttpd/php-fastcgi.socket

Make your new directories and files accessible by the user and group “www” that Lighttpd operates as:

chown -R www:www /var/run/lighttpd

China Visit during March-April

I visited China during the period of March-April this year. Had lots of business work to do, mainly dealing with hardware suppliers of GPS based vehicle tracking systems, but could squeeze out time on Sunday for a trip to shenzhen beach. Few pics, including the friend who literally acted as my interpreter:Beach Creature

Dubai trip

I have been on a small business trip to Dubai, UAE. Really amazed by the amount of construction activities going on in the entire place. All around you can see large buildings, malls and shops. One has to be inside one of these malls to see their expanse. Just went to Mall of the Emirates, and while I am no shopping addict, but the it’s one big mall. It has its own artificial ice skiing place.

Adding a few images of my trip, hopefully will have more time to click a few more pictures now that official business has been completed and I have two more days to roam around.
Now this was taken from the hotel I was staying in for the first two days:
front_building.jpg dubai_skyline3.jpg dubai_nightime3.jpg

Ten rules for startups

This is the one the best pages I have seen for anyone running a small IT/web company:
http://evhead.com/2005/11/ten-rules-for-web-startups.asp

And one of the best quotes:

#9: Be Agile
You know that old saw about a plane flying from California to Hawaii being off course 99% of the time—but constantly correcting? The same is true of successful startups—except they may start out heading toward Alaska. Many dot-com bubble companies that died could have eventually been successful had they been able to adjust and change their plans instead of running as fast as they could until they burned out, based on their initial assumptions. Pyra was started to build a project-management app, not Blogger. Flickr’s company was building a game. Ebay was going to sell auction software. Initial assumptions are almost always wrong. That’s why the waterfall approach to building software is obsolete in favor agile techniques. The same philosophy should be applied to building a company.