Lighttpd2

From Segfault
Jump to: navigation, search

Installation

Lighttpd2 is the next generation of our beloved lighttpd:

sudo apt-get install automake gcc libtool pkg-config ragel libpcre3-dev libglib2.0-dev \
              libev-dev zlib1g-dev libbz2-dev libssl-dev libgnutls-dev liblua50-dev

Or, for RPM based distributions:

sudo yum install automake gcc libtool pkgconfig ragel pcre-devel glib2-devel \
              libev-devel zlib-devel bzip2-devel openssl-devel gnutls-devel lua-devel

Checkout the source from git:

git clone git://git.lighttpd.net/lighttpd/lighttpd2 lighttpd2-git
cd lighttpd2-git

Building with automake seems to work:

./autogen.sh
./configure --prefix=/opt/lighttpd2 --with-libev --with-gnutls --with-openssl --with-zlib --with-bzip2
make
sudo make install

Copy sample configuration files:

# sudo mkdir -m0755 /opt/lighttpd2/etc
# sudo cp -pv contrib/*.conf /opt/lighttpd2/etc/
‘contrib/angel.conf’ -> ‘/opt/lighttpd2/etc/angel.conf’
‘contrib/lighttpd.conf’ -> ‘/opt/lighttpd2/etc/lighttpd.conf’
‘contrib/mimetypes.conf’ -> ‘/opt/lighttpd2/etc/mimetypes.conf

Configuration

angel.conf

#
# angel.conf
# http://doc.lighttpd.net/lighttpd2/core_config_angel.html
#
user    "www-data";
group   "www-data";
binary  "/opt/lighttpd2/libexec/lighttpd2/lighttpd2-worker";
config  "/opt/lighttpd2/etc/lighttpd2.conf";

# copy_env      ( "PATH" );
# copy_env      ( "PATH", "LD_LIBRARY_PATH" );
max_open_files  16384;

# env           [ "G_SLICE=always-malloc", "G_DEBUG=gc-friendly,fatal_criticals" ];
# wrapper       [ "/usr/bin/valgrind", "--leak-check=full", "--show-reachable=yes", "--leak-resolution=high" ];

# need separate statements for IPv4 and IPv6. if none are configured, allow
# TCP port 80 and 443 on all IPv4 and IPv6.
# no port means 80 and 443 are allowed:
# allow_listen "0.0.0.0/0";
# allow_listen "[::/0]";

allow_listen    "0.0.0.0/0:80";
allow_listen    "0.0.0.0/0:443";
allow_listen    "[::/0]:80";
allow_listen    "[::/0]:443";

lighttpd2.conf

#
# lighttpd2.conf
# http://doc.lighttpd.net/lighttpd2/
#
setup {
        module_load [
                "mod_accesslog",
                "mod_dirlist",
                "mod_fastcgi"
        ];
        
        listen "0.0.0.0:80";
        listen "[::]:80";

        log [
            #   "debug" => "",
            #   default => "",
                "debug" => "/var/log/lighttpd2/debug.log",
                default => "/var/log/lighttpd2/error.log",
        ];

        # accesslog           "";
        accesslog             "/var/log/lighttpd2/access.log";
        accesslog.format      "%h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"";

        static.exclude_extensions       [ ".php", ".pl", ".fcgi", "~", ".inc" ];

        module_load "mod_gnutls";
        gnutls (
                "priority" => "PFS:-3DES-CBC:-ARCFOUR-128:-VERS-SSL3.0:-SHA1:+SHA1:+RSA:%SERVER_PRECEDENCE",
                "listen" => "0.0.0.0:443",
                "listen" => "[::]:443",
                "dh-params" => "/opt/lighttpd2/etc/dhparam.pem",
                "protect-against-beast" => true,
                "pemfile" => (
                        "key"  => "/opt/lighttpd2/etc/example.key",
                        "cert" => "/opt/lighttpd2/etc/example.crt"
                )
        );
}

# http://redmine.lighttpd.net/projects/lighttpd2/wiki/Howto_PHP
php = {
        if phys.path =$ ".php" {
        #       log.write "Accessing php file - %{phys.path}";
                fastcgi "unix:/var/run/php5-fpm.sock";
        }
};

include "/opt/lighttpd2/etc/mimetypes.conf";

docroot "/var/www/html";
index   [ "index.php", "index.html" ];
dirlist;
static;
pathinfo;
php;

For some reason, PHP is still not working :-\[1]

Usage

/opt/lighttpd2/sbin/lighttpd2 -c /etc/lighttpd2/angel.conf &

This won't fork into background, hence the ampersand.

Links

References