From 4d0483f0ceeaf031ea84a18e4c4ecbdc3a0c51af Mon Sep 17 00:00:00 2001 From: Matteo Bernardini Date: Sun, 13 Jan 2013 13:20:52 -0600 Subject: network/lighttpd2: Updated for version 20121206_01abf70. Signed-off-by: Robby Workman --- network/lighttpd2/README.SLACKWARE | 39 ++++++++++----- network/lighttpd2/conf/lighttpd.conf | 58 ++++++++++++++++++---- network/lighttpd2/conf/lighttpd2.logrotate | 28 ++++++++--- network/lighttpd2/conf/php-fpm.lua | 10 ++++ network/lighttpd2/conf/rc.lighttpd2 | 8 +--- network/lighttpd2/conf/rc.spawn-fcgi | 77 ------------------------------ network/lighttpd2/doinst.sh | 11 +++-- network/lighttpd2/lighttpd2.SlackBuild | 57 +++++----------------- network/lighttpd2/lighttpd2.info | 12 ++--- network/lighttpd2/slack-desc | 12 ++--- 10 files changed, 138 insertions(+), 174 deletions(-) create mode 100644 network/lighttpd2/conf/php-fpm.lua delete mode 100644 network/lighttpd2/conf/rc.spawn-fcgi (limited to 'network/lighttpd2') diff --git a/network/lighttpd2/README.SLACKWARE b/network/lighttpd2/README.SLACKWARE index 8caea6bf40..c456dfe7c1 100644 --- a/network/lighttpd2/README.SLACKWARE +++ b/network/lighttpd2/README.SLACKWARE @@ -1,34 +1,51 @@ README.SLACKWARE For lighttpd2 -lighttpd2 can be started and stopped through the initialization script that -is provided: +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 +This slackbuild is already preconfigured (but is disabled by default) +for an use with php in /etc/lighttpd2/lighttpd.conf and uses php-fpm +already in Slackware. -Otherwise, php won't be able to use $_SESSION. +You have to make two changes to /etc/php-fpm.conf, namely + + user = lighttpd + listen = /var/run/lighttpd2/php-fpm.sock -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). +Then make /etc/rc.d/rc.php-fpm executable and start it (for an +automatic start/stop, do as for the rc.lighttpd2 script). +Enable php uncommenting the last line of /etc/lighttpd2/lighttpd.conf +(you might want to have a look at the "index" directive too). +The php.ini used will be /etc/httpd/php.ini: you can also override +options set in this file adding them at the end of /etc/php-fpm.conf +(you will find some examples there). + +Note: Slackware's default php package is meant to work with httpd +(apache), so its session folder has permissions root:apache. +It works fine with lighttpd assumed the addition of the user lighttpd +run as to the "apache" group. If you have choosen the user "lighttpd" + + gpasswd -a lighttpd apache + +Otherwise, php won't be able to use $_SESSION. diff --git a/network/lighttpd2/conf/lighttpd.conf b/network/lighttpd2/conf/lighttpd.conf index 20b47e840e..1a62342940 100644 --- a/network/lighttpd2/conf/lighttpd.conf +++ b/network/lighttpd2/conf/lighttpd.conf @@ -1,7 +1,13 @@ +# Sample /etc/lighttpd2/lighttpd.conf file +# Assembled and commented by Matteo Bernardini +# Default modules here should cover most needs: if you want to cut +# down some, consider that mod_access and mod_accesslog are mandatory. +# http://redmine.lighttpd.net/projects/lighttpd2/wiki/Modules setup { - module_load ( "mod_fastcgi", "mod_status", "mod_access", "mod_accesslog" ); + module_load ( "mod_fastcgi", "mod_status", "mod_access", "mod_accesslog", "mod_dirlist", "mod_deflate", "mod_redirect", "mod_rewrite", "mod_vhost", "mod_lua" ); # mod_access, +# mod_accesslog, # mod_auth, # mod_balance, # mod_cache_disk_etag, @@ -9,6 +15,7 @@ setup { # mod_deflate, # mod_dirlist, # mod_expire, +# mod_fastcgi, # mod_flv, # mod_fortune, # mod_limit, @@ -20,9 +27,12 @@ setup { # mod_redirect, # mod_rewrite, # mod_scgi, +# mod_status, # mod_userdir, # mod_vhost, + lua.plugin "/etc/lighttpd2/php-fpm.lua"; + listen "0.0.0.0:80"; listen "[::]:80"; @@ -33,13 +43,12 @@ setup { static.exclude_extensions ( ".php", ".pl", ".fcgi", "~", ".inc" ); } -# named action block +# http://redmine.lighttpd.net/projects/lighttpd2/wiki/Conditions + +# Run php through php-fpm: be sure to read README.SLACKWARE +# http://redmine.lighttpd.net/projects/lighttpd2/wiki/Howto_PHP php = { - if phys.path =$ ".php" { - if physical.is_file { - fastcgi "unix:/var/run/lighttpd2/www-default-php.sock"; - } - } + phpfpm { fastcgi "unix:/var/run/lighttpd2/php-fpm.sock"; }; }; if req.path == "/status" { status.info; } @@ -48,10 +57,39 @@ include "/etc/lighttpd2/mimetypes.conf"; docroot "/var/www/htdocs-lighttpd"; -index ( "index.php", "index.html", "default.html" ); +# If you install phpmyadmin from the SBo script, it should go there. +# Uncomment below, after having installed. +#alias ( "/phpmyadmin" => "/var/www/htdocs/phpmyadmin" ); + +# Directory listings are enabled by default only for an eventual +# "pub" folder in the docroot: change as needed. +# http://redmine.lighttpd.net/projects/lighttpd2/wiki/Mod_dirlist +if req.path =~ "^/pub/" { + dirlist; +} + +# Directory index files: this commented below can be useful if you +# enable php. +#index ( "index.php", "index.html" ); +index ( "index.html" ); -# alias "/phpmyadmin" => "/var/www/htdocs/phpmyadmin"; +# If you want to use urls like http://example.com/index.php/some/path +# (using your php files like directories), you need this (ex. wordpress) +#pathinfo; -php; +# Some useful rules to avoid access to sensitive files from remote. +# This example still applies to wordpress +#if req.remoteip != "127.0.0.1" { +# if req.path =~ "^/wp-includes/" { access.deny; } +#} +# Deny access to some file-extensions +# ~ is for backupfiles from vi, emacs, joe, ... +# .inc is often used for code includes which should in general not be +# part of the document-root +if phys.path =$ "~" or phys.path =$ ".inc" { + if phys.is_file { access.deny; } +} +# Uncomment this to enable php +#php; diff --git a/network/lighttpd2/conf/lighttpd2.logrotate b/network/lighttpd2/conf/lighttpd2.logrotate index 19a2f5abeb..04d448ac6b 100644 --- a/network/lighttpd2/conf/lighttpd2.logrotate +++ b/network/lighttpd2/conf/lighttpd2.logrotate @@ -1,16 +1,32 @@ -/var/log/lighttpd2/*.log { +/var/log/lighttpd2/access.log /var/log/lighttpd2/error.log { daily missingok copytruncate - rotate 7 - create 0644 lighttpd lighttpd + rotate 30 + create 0644 lighttpd root compress notifempty - su lighttpd lighttpd + su lighttpd root sharedscripts postrotate - if [ -x /etc/rc.d/rc.lighttpd2 -a -f /var/run/lighttpd.pid ]; then - /etc/rc.d/rc.lighttpd2 reload + if [ -x /etc/rc.d/rc.lighttpd2 -a -f /var/run/lighttpd2/lighttpd2.pid ]; then + /etc/rc.d/rc.lighttpd2 restart + fi + endscript +} + +/var/log/lighttpd2/lighttpd2.log { + daily + missingok + copytruncate + rotate 30 + create 0644 root root + compress + notifempty + sharedscripts + postrotate + if [ -x /etc/rc.d/rc.lighttpd2 -a -f /var/run/lighttpd2/lighttpd2.pid ]; then + /etc/rc.d/rc.lighttpd2 restart fi endscript } diff --git a/network/lighttpd2/conf/php-fpm.lua b/network/lighttpd2/conf/php-fpm.lua new file mode 100644 index 0000000000..f26bb9d796 --- /dev/null +++ b/network/lighttpd2/conf/php-fpm.lua @@ -0,0 +1,10 @@ +local function phpfpm(act) + return action.when(physical.path:suffix(".php"), + action.when(physical.is_file:is(), act), + action.when(request.path:eq("/fpm-status"), act) + ) +end + +actions = { + ["phpfpm"] = phpfpm, +} diff --git a/network/lighttpd2/conf/rc.lighttpd2 b/network/lighttpd2/conf/rc.lighttpd2 index 31ade849fe..e7a8ca286a 100644 --- a/network/lighttpd2/conf/rc.lighttpd2 +++ b/network/lighttpd2/conf/rc.lighttpd2 @@ -19,6 +19,7 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # +# Adapted for lighttpd2 by Matteo Bernardini LIGHTTPD=/usr/sbin/lighttpd2 LIGHTTPD_OPTIONS="-c /etc/lighttpd2/angel.conf" @@ -53,10 +54,6 @@ lighttpd_restart() { lighttpd_start } -lighttpd_reload() { - kill -s HUP $PIDOF_WORKER -} - case "$1" in 'start') lighttpd_start @@ -67,9 +64,6 @@ case "$1" in restart) lighttpd_restart ;; -reload) - lighttpd_reload - ;; *) echo "usage $0 start|stop|restart" esac diff --git a/network/lighttpd2/conf/rc.spawn-fcgi b/network/lighttpd2/conf/rc.spawn-fcgi deleted file mode 100644 index 146dc4f3bb..0000000000 --- a/network/lighttpd2/conf/rc.spawn-fcgi +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh -# Copyright (c) 2012, ponce -# 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 diff --git a/network/lighttpd2/doinst.sh b/network/lighttpd2/doinst.sh index 58590b923f..a2bfef2076 100644 --- a/network/lighttpd2/doinst.sh +++ b/network/lighttpd2/doinst.sh @@ -22,15 +22,16 @@ preserve_perms() { config etc/lighttpd2/lighttpd.conf.new config etc/lighttpd2/angel.conf.new config etc/lighttpd2/mimetypes.conf.new +config etc/lighttpd2/php-fpm.lua.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: +# Create dummy logfiles, but throw them away if some 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 + if [ -e var/log/lighttpd2/$i.log ]; then + rm -f var/log/lighttpd2/$i.log.new else - mv var/log/lighttpd2/${i}.log{.new,} + mv var/log/lighttpd2/$i.log.new \ + var/log/lighttpd2/$i.log fi done diff --git a/network/lighttpd2/lighttpd2.SlackBuild b/network/lighttpd2/lighttpd2.SlackBuild index 19de071ad6..1f7e9d8815 100644 --- a/network/lighttpd2/lighttpd2.SlackBuild +++ b/network/lighttpd2/lighttpd2.SlackBuild @@ -25,9 +25,7 @@ # twisted for lighttpd2 by Matteo Bernardini PRGNAM=lighttpd2 -VERSION=${VERSION:-20120616_2634c77} -PRGNAM2=spawn-fcgi -VERSION2=${VERSION2:-r57} +VERSION=${VERSION:-20121206_01abf70} BUILD=${BUILD:-1} TAG=${TAG:-_SBo} @@ -109,59 +107,30 @@ CXXFLAGS="$SLKCFLAGS" \ 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 +mkdir -p $PKG/var/cache/$PRGNAM $PKG/var/log/$PRGNAM $PKG/var/run/$PRGNAM +chmod 0770 $PKG/var/cache/$PRGNAM $PKG/var/log/$PRGNAM $PKG/var/run/$PRGNAM +( cd $PKG/var/log/$PRGNAM ; touch access.log.new error.log.new ) +chown -R $LIGHTTPD_USER:$LIGHTTPD_GROUP $PKG/var/cache/$PRGNAM $PKG/var/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 +install -m 0644 $CWD/conf/php-fpm.lua $PKG/etc/$PRGNAM/php-fpm.lua.new +install -D -m 0644 $CWD/conf/$PRGNAM.logrotate $PKG/etc/logrotate.d/$PRGNAM.new +install -D -m 0644 doc/default.html $PKG/var/www/htdocs-lighttpd/index.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 +sed -i \ + -e "s|user \"lighttpd|user \"$LIGHTTPD_USER|" \ + -e "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 +cp -a COPYING doc/* $CWD/README.SLACKWARE $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 diff --git a/network/lighttpd2/lighttpd2.info b/network/lighttpd2/lighttpd2.info index b28caab39b..7e3a0f4af6 100644 --- a/network/lighttpd2/lighttpd2.info +++ b/network/lighttpd2/lighttpd2.info @@ -1,12 +1,8 @@ -PRGNAM="lighttpd" -VERSION="20120616_2634c77" +PRGNAM="lighttpd2" +VERSION="20121206_01abf70" 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="http://ponce.cc/slackware/sources/repo/lighttpd2-20121206_01abf70.tar.xz" +MD5SUM="6dd72a57fb71817852a152207ac3b2bf" DOWNLOAD_x86_64="" MD5SUM_x86_64="" REQUIRES="libev lua ragel" diff --git a/network/lighttpd2/slack-desc b/network/lighttpd2/slack-desc index 98e96e671a..97ad74547d 100644 --- a/network/lighttpd2/slack-desc +++ b/network/lighttpd2/slack-desc @@ -1,11 +1,11 @@ # 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 ':'. +# 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 ':' except on otherwise blank lines. - |-----handy-ruler------------------------------------------------------| + |-----handy-ruler------------------------------------------------------| lighttpd2: lighttpd2 (Light, fast, and secure webserver) lighttpd2: lighttpd2: lighttpd2 is a fast, secure, and flexible webserver. It is optimized -- cgit v1.2.3