25 year old developer and startup guy living in SF
Follow @Stammy
After hearing about the joys of Lighttpd, a lightweight alternative to the Apache web server, for a long time I opened a Connector account with Joyent/TextDrive. I planned on using this account as a development sandbox where I can tinker with Lighttpd without the possibility of bringing down this blog, which experienced brief downtime last week when I upgraded to PHP5 my clumsy self.
However, I quickly found working with TextDrive complex due to their scattered documentation and use of Webmin. In this post, I'll be walking you through getting Lighttpd and PHP5 running on a TextDrive/Joyent Connector account.
dns1.textdrive.com
dns2.textdrive.com
dns3.textdrive.com
dns4.textdrive.com
ssh username@yourdomain.com
cd ~
mkdir var/
mkdir var/log
mkdir var/run
mkdir etc/rc.d
mkdir etc/lighttpd
mkdir etc/lighttpd/vhosts.d
### Lighttpd Configuration File
#-- Lighttpd modules
server.modules = ( "mod_rewrite",
"mod_redirect",
"mod_access",
"mod_cgi",
"mod_fastcgi",
"mod_compress",
"mod_accesslog" )
#-- CGI configuration
cgi.assign = ( ".pl" => "/usr/local/bin/perl",
".cgi" => "/usr/local/bin/perl" )
#-- Mimetypes
include_shell "cat /usr/local/etc/lighttpd_mimetypes.conf"
#-- Default domain
server.username = "USERNAME"
server.port = PORTNUMBER
server.groupname = server.username
var.base = "/users/home/" + server.username
server.document-root = base + "/web/public/"
server.pid-file = base + "/var/run/lighttpd.pid"
server.tag = "Lighttpd | TextDriven"
server.indexfiles = ( "index.php", "index.html",
"index.htm", "default.htm" )
url.access-deny = ( "~", ".inc", ".ht" )
#-- Logging
accesslog.filename = base + "/var/log/lighttpd.access.log"
server.errorlog = base + "/var/log/lighttpd.error.log"
#-- VHOSTS
include "vhosts.d/APPNAME.conf"### Rails Application Configuration File
HTTP["host"] =~ "(www\.)?yourdomain\.com" {
server.document-root = base + "/web/public/"
server.error-handler-404 = "/dispatch.fcgi"
fastcgi.server = (
".fcgi" => ( "localhost" => ( "socket" => base + "/var/run/APPNAME-0.socket" ) )
### PHP
,".php" =>
( "localhost" =>
(
"socket" => base + "/var/run/php-fastcgi.socket",
"bin-path" => "/usr/local/www/cgi-bin/php5-fcgi",
"bin-environment" =>
( "PHP_FCGI_CHILDREN" => "1", "PHP_FCGI_MAX_REQUESTS" => "2500" ),
"bin-copy-environment" =>
( "PATH", "SHELL", "USER" ),
"max-procs" => 1,
"idle-timeout" => 20
)
)
)
}#!/bin/sh
# This is for Starting/Stopping/Restarting Lighttpd. You won't need
# to edit anything.
HOME=/users/home/`whoami`
LIGHTTPD_CONF=HOME/etc/lighttpd/lighttpd.conf
PIDFILE=HOME/var/run/lighttpd.pid
export SHELL=/bin/sh
case "1" in
start)
# Starts the lighttpd deamon
echo "Starting Lighttpd"
PATH=PATH:/usr/local/bin /usr/local/sbin/lighttpd -f LIGHTTPD_CONF
;;
stop)
# stops the daemon bt cat'ing the pidfile
echo "Stopping Lighttpd"
kill `/bin/cat PIDFILE`
;;
restart)
## Stop the service regardless of whether it was
## running or not, start it again.
echo "Restarting Lighttpd"
0 stop
0 start
;;
reload)
# reloads the config file by sending HUP
echo "Reloading config"
kill -HUP `/bin/cat PIDFILE`
;;
*)
echo "Usage: lighttpdctrl (start|stop|restart|reload)"
exit 1
;;
esacIn order for lighttpd to work, you must use a proxy with the port number you were given.

/users/home/username/etc/rc.d/lighttpd.sh start
<?php
phpinfo();
?>

/users/home/username/etc/rc.d/lighttpd.sh start
/users/home/username/etc/rc.d/lighttpd.sh restart
/users/home/username/etc/rc.d/lighttpd.sh stop
For your convenience, here are the 3 files from this post: Lighttpd_files.zip.
I'm not responsible if your server goes boom and the CPU lets out magic smoke. I only wrote this as a guide for others to follow after my own bad experience trying to set it all up. I wrote it after I did it myself so I might have put a step or two in the wrong place. Try it and get back to me.
Subscribe via RSS or email.
AppSumo. Deals on tools for startups. Check em out.