network/lighttpd2: Added (light, fast, and secure webserver).

Signed-off-by: Matteo Bernardini <ponce@slackbuilds.org>
This commit is contained in:
Matteo Bernardini 2012-09-08 11:40:57 +02:00 committed by Robby Workman
parent c5774c9ed1
commit 1efbfb7da2
11 changed files with 526 additions and 0 deletions

15
network/lighttpd2/README Normal file
View file

@ -0,0 +1,15 @@
lighttpd2 is a fast, secure, and flexible webserver. It is optimized
for high-performance environments, and provides an extensive feature
set, including FastCGI, CGI, Auth, output compression, and URL
rewriting support.
By default, this package uses the "lighttpd" user and group to run
lighttpd as a unpriviliged process. The script will exit if these
do not exist on this machine. We recommend using the following
UID and GID as they do not conflict with any stock Slackware users
and groups, nor with any added by other SlackBuilds.org scripts.
User: lighttpd UID: 208 GID: 208
Group: lighttpd GID: 208
Be sure to see README.SLACKWARE (in this directory, and also installed
with the package documentation) for configuration and setup information.

View file

@ -0,0 +1,34 @@
README.SLACKWARE For lighttpd2
lighttpd2 can be started and stopped through the initialization script that
is provided:
/etc/rc.d/rc.lighttpd2 start
/etc/rc.d/rc.lighttpd2 stop
If you would like to start lighttpd automatically when the system
is booted, add the following lines to /etc/rc.d/rc.local:
if [ -x /etc/rc.d/rc.lighttpd2 ]; then
/etc/rc.d/rc.lighttpd2 start
fi
Conversely, add the following lines to /etc/rc.d/rc.local_shutdown
to stop lighttpd on system shutdown.
if [ -x /etc/rc.d/rc.lighttpd2 ]; then
/etc/rc.d/rc.lighttpd2 stop
fi
* PHP users:
Slackware's default php package is meant to work with httpd(apache).
It works fine with lighttpd assumed the addition of the user lighttpd
run as to the "apache" group.
gpasswd -a lighttpd apache
Otherwise, php won't be able to use $_SESSION.
This slackbuild already setup php in /etc/lighttpd2/lighttpd.conf
and build a fastcgi server, spawn-fcgi. This is used as a daemon
with its own init script, /etc/rc.d/rc.spawn-fcgi (that can be
started at boot in the same way of rc.lighttpd2).

View file

@ -0,0 +1,11 @@
instance {
user "lighttpd";
group "lighttpd";
max-open-files 16384;
copy-env ( "PATH" );
# env ( "G_SLICE=always-malloc", "G_DEBUG=gc-friendly" );
# wrapper ("/usr/bin/valgrind", "--leak-check=full", "--show-reachable=yes", "--leak-resolution=high" );
}

View file

@ -0,0 +1,57 @@
setup {
module_load ( "mod_fastcgi", "mod_status", "mod_access", "mod_accesslog" );
# mod_access,
# mod_auth,
# mod_balance,
# mod_cache_disk_etag,
# mod_debug,
# mod_deflate,
# mod_dirlist,
# mod_expire,
# mod_flv,
# mod_fortune,
# mod_limit,
# mod_lua,
# mod_memcached,
# mod_openssl,
# mod_progress,
# mod_proxy,
# mod_redirect,
# mod_rewrite,
# mod_scgi,
# mod_userdir,
# mod_vhost,
listen "0.0.0.0:80";
listen "[::]:80";
log ["debug" => "", "*" => "/var/log/lighttpd2/error.log"];
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" );
}
# named action block
php = {
if phys.path =$ ".php" {
if physical.is_file {
fastcgi "unix:/var/run/lighttpd2/www-default-php.sock";
}
}
};
if req.path == "/status" { status.info; }
include "/etc/lighttpd2/mimetypes.conf";
docroot "/var/www/htdocs-lighttpd";
index ( "index.php", "index.html", "default.html" );
# alias "/phpmyadmin" => "/var/www/htdocs/phpmyadmin";
php;

View file

@ -0,0 +1,16 @@
/var/log/lighttpd2/*.log {
daily
missingok
copytruncate
rotate 7
create 0644 lighttpd lighttpd
compress
notifempty
su lighttpd lighttpd
sharedscripts
postrotate
if [ -x /etc/rc.d/rc.lighttpd2 -a -f /var/run/lighttpd.pid ]; then
/etc/rc.d/rc.lighttpd2 reload
fi
endscript
}

View file

@ -0,0 +1,75 @@
#!/bin/sh
# Copyright (c) 2007, Daniel de Kok <moc.mikciat@leinad>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
LIGHTTPD=/usr/sbin/lighttpd2
LIGHTTPD_OPTIONS="-c /etc/lighttpd2/angel.conf"
PIDOF_WORKER=$(pidof lighttpd2-worker)
PIDOF=$(pidof lighttpd2)
lighttpd_start() {
echo "Starting lighttpd2: $LIGHTTPD"
if [ $PIDOF ]; then
echo "Already running!"
return
fi
$LIGHTTPD $LIGHTTPD_OPTIONS >> /var/log/lighttpd2/lighttpd2.log 2>&1 &
sleep 2
echo $(pidof lighttpd2) > /var/run/lighttpd2/lighttpd2.pid
}
lighttpd_stop() {
echo "Stopping lighttpd2: $LIGHTTPD"
if [ $PIDOF ]; then
kill $PIDOF
rm /var/run/lighttpd2/lighttpd2.pid
else
echo "Not running!"
fi
}
lighttpd_restart() {
lighttpd_stop
PIDOF=
sleep 1
lighttpd_start
}
lighttpd_reload() {
kill -s HUP $PIDOF_WORKER
}
case "$1" in
'start')
lighttpd_start
;;
'stop')
lighttpd_stop
;;
restart)
lighttpd_restart
;;
reload)
lighttpd_reload
;;
*)
echo "usage $0 start|stop|restart"
esac

View file

@ -0,0 +1,77 @@
#!/bin/sh
# Copyright (c) 2012, ponce <matteo.bernardini@gmail.com>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
SPAWNFCGI=/usr/bin/spawn-fcgi
FCGI_PROGRAM=/usr/bin/php-cgi
FCGI_SOCKET=/var/run/lighttpd2/www-default-php.sock
PHP_FCGI_CHILDREN=4
FCGI_CHILDREN=1
CGI_USER=lighttpd
CGI_GROUP=lighttpd
SOCKET_USER=lighttpd
SOCKET_GROUP=lighttpd
PIDFILE=/var/run/lighttpd2/spawn-fcgi.pid
PHP_FCGI_MAX_REQUESTS=1000
export PHP_FCGI_MAX_REQUESTS
spawnfcgi_start() {
echo "Starting spawn-fcgi: $SPAWNFCGI"
if [ -f "$PIDFILE" ]; then
echo "Already running!"
return
fi
$SPAWNFCGI -s $FCGI_SOCKET -u $CGI_USER -U $SOCKET_USER \
-g $CGI_USER -G $SOCKET_GROUP -P $PIDFILE \
-C $PHP_FCGI_CHILDREN -F $FCGI_CHILDREN -- $FCGI_PROGRAM \
>> /dev/null 2>&1
}
spawnfcgi_stop() {
echo "Stopping spawn-fcgi: $SPAWNFCGI"
if [ -f "$PIDFILE" ]; then
rm -f $PIDFILE $FCGI_SOCKET
killall $FCGI_PROGRAM
else
echo "Not running!"
fi
}
spawnfcgi_restart() {
spawnfcgi_stop
sleep 1
spawnfcgi_start
}
case "$1" in
'start')
spawnfcgi_start
;;
'stop')
spawnfcgi_stop
;;
restart)
spawnfcgi_restart
;;
*)
echo "usage $0 start|stop|restart"
esac

View file

@ -0,0 +1,36 @@
config() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
if [ ! -r $OLD ]; then
mv $NEW $OLD
elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
rm $NEW
fi
}
preserve_perms() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
if [ -e $OLD ]; then
cp -a $OLD ${NEW}.incoming
cat $NEW > ${NEW}.incoming
mv ${NEW}.incoming $NEW
fi
config $NEW
}
config etc/lighttpd2/lighttpd.conf.new
config etc/lighttpd2/angel.conf.new
config etc/lighttpd2/mimetypes.conf.new
config etc/logrotate.d/lighttpd2.new
preserve_perms etc/rc.d/rc.lighttpd2.new
preserve_perms etc/rc.d/rc.spawn-fcgi.new
# Create dummy logfiles, but throw them away if logfiles are already here:
for i in access error ; do
if [ -e var/log/lighttpd2/${i}.log ]; then
rm -f var/log/lighttpd2/${i}.log.new
else
mv var/log/lighttpd2/${i}.log{.new,}
fi
done

View file

@ -0,0 +1,172 @@
#!/bin/sh
# Slackware build script for lighttpd2
# Copyright (c) 2007 Daniel de Kok <moc.mikciat@leinad>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# twisted for lighttpd2 by Matteo Bernardini <ponce@slackbuilds.org>
PRGNAM=lighttpd2
VERSION=${VERSION:-20120616_2634c77}
PRGNAM2=spawn-fcgi
VERSION2=${VERSION2:-r57}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i486 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
## lighttpd user & group *MUST* exist before package creation
# See http://slackbuilds.org/uid_gid.txt for current recomendations.
LIGHTTPD_USER=${LIGHTTPD_USER:-lighttpd}
LIGHTTPD_GROUP=${LIGHTTPD_GROUP:-lighttpd}
bailout() {
printf " The $LIGHTTPD_GROUP group and/or $LIGHTTPD_USER user account
does not exist. You should create it/them with the following:
groupadd -g 208 $LIGHTTPD_GROUP
useradd -u 208 -g $LIGHTTPD_GROUP -d /var/www $LIGHTTPD_USER\n"
exit 1
}
if ! grep -q ^$LIGHTTPD_GROUP: /etc/group 2>/dev/null ; then
bailout
elif ! grep -q ^$LIGHTTPD_USER: /etc/passwd 2>/dev/null ; then
bailout
fi
if [ "$ARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
set -e # Exit on most errors
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.?z*
cd $PRGNAM-$VERSION
chown -R root:root .
find . \
\( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
-exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
sh autogen.sh
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr \
--libdir=/usr/lib${LIBDIRSUFFIX}/$PRGNAM \
--sysconfdir=/etc \
--localstatedir=/var \
--mandir=/usr/man \
--with-lua \
--with-openssl \
--build=$ARCH-slackware-linux
make
make install-strip DESTDIR=$PKG
( # build also spawn-fcgi
cd ..
rm -rf $PRGNAM2-$VERSION2
tar xvf $CWD/$PRGNAM2-$VERSION2.tar.?z*
cd $PRGNAM2-$VERSION2
chown -R root:root .
find . \
\( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
-exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
sh autogen.sh
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
--prefix=/usr \
--mandir=/usr/man \
--build=$ARCH-slackware-linux
make
install -m 0755 -D src/$PRGNAM2 $PKG/usr/bin/$PRGNAM2
mkdir -p $PKG/usr/doc/$PRGNAM2-$VERSION2
install -m 0644 AUTHORS COPYING NEWS README doc/run* $PKG/usr/doc/$PRGNAM2-$VERSION2
install -m 0644 -D $PRGNAM2.1 $PKG/usr/man/man1/$PRGNAM2.1
cd -
)
mkdir -p $PKG/var/{cache,log,run}/$PRGNAM
chmod 0770 $PKG/var/{cache,log,run}/$PRGNAM
touch $PKG/var/log/$PRGNAM/{access,error}.log.new
chown -R $LIGHTTPD_USER:$LIGHTTPD_GROUP $PKG/var/{cache,run}/$PRGNAM
chown -R $LIGHTTPD_USER:root $PKG/var/log/$PRGNAM
install -D -m 0755 $CWD/conf/rc.$PRGNAM $PKG/etc/rc.d/rc.$PRGNAM.new
install -m 0755 $CWD/conf/rc.$PRGNAM2 $PKG/etc/rc.d/rc.$PRGNAM2.new
install -D -m 0644 $CWD/conf/lighttpd.conf $PKG/etc/$PRGNAM/lighttpd.conf.new
install -m 0644 $CWD/conf/angel.conf $PKG/etc/$PRGNAM/angel.conf.new
install -m 0644 doc/mimetypes.conf $PKG/etc/$PRGNAM/mimetypes.conf.new
install -D -m 0644 $CWD/conf/$PRGNAM.logrotate $PKG/etc/logrotate.d/lighttpd2.new
install -D -m 0644 doc/default.html $PKG/var/www/htdocs-lighttpd/default.html
sed -i "s|user \"lighttpd|user \"$LIGHTTPD_USER|" $PKG/etc/$PRGNAM/angel.conf.new
sed -i "s|group \"lighttpd|group \"$LIGHTTPD_GROUP|" $PKG/etc/$PRGNAM/angel.conf.new
find $PKG/usr/man -type f -exec gzip -9 {} \;
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a COPYING doc/* \
$PKG/usr/doc/$PRGNAM-$VERSION
rm -f $PKG/usr/doc/$PRGNAM-$VERSION/Makefile*
cat $CWD/README.SLACKWARE > $PKG/usr/doc/$PRGNAM-$VERSION/README.SLACKWARE
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}

View file

@ -0,0 +1,14 @@
PRGNAM="lighttpd"
VERSION="20120616_2634c77"
HOMEPAGE="http://www.lighttpd.net/"
DOWNLOAD="\
http://ponce.cc/slackware/sources/repo/lighttpd2-20120616_2634c77.tar.xz \
http://ponce.cc/slackware/sources/repo/spawn-fcgi-r57.tar.xz"
MD5SUM="\
ace76101fcd642a0fa4a0b612477af6f \
547b7d5a18aad3e5bedc27cfe45d950c"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
REQUIRES="libev lua ragel"
MAINTAINER="Matteo Bernardini"
EMAIL="ponce@slackbuilds.org"

View file

@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|' on
# the right side marks the last column you can put a character in. You must make
# exactly 11 lines for the formatting to be correct. It's also customary to
# leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
lighttpd2: lighttpd2 (Light, fast, and secure webserver)
lighttpd2:
lighttpd2: lighttpd2 is a fast, secure, and flexible webserver. It is optimized
lighttpd2: for high-performance environments, and provides an extensive feature
lighttpd2: set, including FastCGI, CGI, Auth, output compression, and URL
lighttpd2: rewriting support.
lighttpd2:
lighttpd2: Homepage: http://www.lighttpd.net/
lighttpd2:
lighttpd2:
lighttpd2: