Created
December 1, 2012 16:49
-
-
Save benphelps/4183197 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
open MIMETYPES, "/etc/mime.types" or exit; | |
print "mimetype.assign = (\n"; | |
my %extensions; | |
while(<MIMETYPES>) { | |
chomp; | |
s/\#.*//; | |
next if /^\w*$/; | |
if(/^([a-z0-9\/+-.]+)\s+((?:[a-z0-9.+-]+[ ]?)+)$/) { | |
foreach(split / /, $2) { | |
# mime.types can have same extension for different | |
# mime types | |
next if $extensions{$_}; | |
$extensions{$_} = 1; | |
print "\".$_\" => \"$1\",\n"; | |
} | |
} | |
} | |
print ")\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server.modules += ( "mod_fastcgi" ) | |
fastcgi.server += ( ".php" => | |
( "localhost" => ( | |
"socket" => "/var/run/php5-fpm.sock", | |
)) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -wl | |
use strict; | |
use File::Glob ':glob'; | |
my $confdir = shift || "/etc/lighttpd/"; | |
my $enabled = "conf-enabled/*.conf"; | |
chdir($confdir); | |
my @files = bsd_glob($enabled); | |
for my $file (@files) | |
{ | |
print "include \"$file\""; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
# | |
# Copyright (c) 2006 Krzysztof Krzyzaniak | |
# | |
# Contains changes from: | |
# - Tobias Gruetzmacher <[email protected]> | |
# | |
# You may distribute under the terms of either the GNU General Public | |
# License[1] or the Artistic License[2]. | |
# | |
# [1] http://www.gnu.org/licenses/gpl.html | |
# [2] http://www.perl.com/pub/a/language/misc/Artistic.html | |
# | |
use strict; | |
use Term::ReadLine; | |
use File::Basename; | |
use File::Glob ':glob'; | |
use File::stat; | |
#--- some initializations | |
my $confdir = "/etc/lighttpd/"; | |
my %available = (); | |
my %enabled = (); | |
my @todo = (); | |
my %moduledeps = (); | |
my $enabling = 1; | |
#--- first check if we enabling or disabling | |
if ($0 =~ /disable-mod$/) { | |
#--- disabling mode | |
$enabling = 0; | |
} | |
#--- list of available modules | |
my @files = bsd_glob($confdir.'conf-available/*.conf'); | |
print "Available modules: "; | |
foreach my $file (@files) { | |
if (basename($file) =~ /^\d+\-([\w\-\.]+)\.conf$/) { | |
$available{$1} = $file; | |
print qq{$1 }; | |
} | |
} | |
print "\n"; | |
#--- list of already enabled modules | |
@files = bsd_glob($confdir.'conf-enabled/*.conf'); | |
print "Already enabled modules: "; | |
foreach my $file (@files) { | |
if (basename($file) =~ /^\d+\-([\w\-\.]+)\.conf$/) { | |
$enabled{$1} = $file; | |
print qq{$1 }; | |
} | |
} | |
print "\n"; | |
unless (defined($ARGV[0])) { | |
my $prompt = $enabling ? 'Enable module: ' : 'Disable module: '; | |
my $term = new Term::ReadLine $prompt; | |
my $OUT = $term->OUT || \*STDOUT; | |
my $var = lc($term->readline($prompt)); | |
@todo = split(/ /, $var); | |
} | |
else { | |
@todo = @ARGV; | |
} | |
#--- activate (link) or deactivate (remove) module | |
foreach my $do (@todo) { | |
if ($enabling) { | |
next unless defined($available{$do}); | |
my $target = sprintf("%s/conf-enabled/%s", $confdir,basename($available{$do})); | |
print qq{Enabling $do: }; | |
my $st = stat($target); | |
unless ( -f $target ) { | |
if (symlink("../conf-available/" . basename($available{$do}), $target)) { | |
print "ok\n"; | |
} | |
else { | |
print "failure: $!\n"; | |
} | |
} | |
else { | |
print "already enabled\n"; | |
} | |
#--- check dependencies | |
for my $module (@{$moduledeps{$do}}) | |
{ | |
unless ( -f $target && -l $target ) | |
{ | |
print qq{Module $do depends on module $module which is not activated.\n}; | |
} | |
} | |
} | |
else { | |
if (defined($enabled{$do})) { | |
print qq{Disabling $do\n}; | |
my $target = sprintf("%s/conf-enabled/%s", $confdir,basename($enabled{$do})); | |
unlink($target); | |
} else { | |
print qq{Already disabled $do\n}; | |
} | |
} | |
} | |
print "Run /etc/init.d/lighttpd force-reload to enable changes\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!/usr/bin/perl -w | |
# | |
# Copyright (c) 2006 Krzysztof Krzyzaniak | |
# | |
# Contains changes from: | |
# - Tobias Gruetzmacher <[email protected]> | |
# | |
# You may distribute under the terms of either the GNU General Public | |
# License[1] or the Artistic License[2]. | |
# | |
# [1] http://www.gnu.org/licenses/gpl.html | |
# [2] http://www.perl.com/pub/a/language/misc/Artistic.html | |
# | |
use strict; | |
use Term::ReadLine; | |
use File::Basename; | |
use File::Glob ':glob'; | |
use File::stat; | |
#--- some initializations | |
my $confdir = "/etc/lighttpd/"; | |
my %available = (); | |
my %enabled = (); | |
my @todo = (); | |
my %moduledeps = (); | |
my $enabling = 1; | |
#--- first check if we enabling or disabling | |
if ($0 =~ /disable-mod$/) { | |
#--- disabling mode | |
$enabling = 0; | |
} | |
#--- list of available modules | |
my @files = bsd_glob($confdir.'conf-available/*.conf'); | |
print "Available modules: "; | |
foreach my $file (@files) { | |
if (basename($file) =~ /^\d+\-([\w\-\.]+)\.conf$/) { | |
$available{$1} = $file; | |
print qq{$1 }; | |
} | |
} | |
print "\n"; | |
#--- list of already enabled modules | |
@files = bsd_glob($confdir.'conf-enabled/*.conf'); | |
print "Already enabled modules: "; | |
foreach my $file (@files) { | |
if (basename($file) =~ /^\d+\-([\w\-\.]+)\.conf$/) { | |
$enabled{$1} = $file; | |
print qq{$1 }; | |
} | |
} | |
print "\n"; | |
unless (defined($ARGV[0])) { | |
my $prompt = $enabling ? 'Enable module: ' : 'Disable module: '; | |
my $term = new Term::ReadLine $prompt; | |
my $OUT = $term->OUT || \*STDOUT; | |
my $var = lc($term->readline($prompt)); | |
@todo = split(/ /, $var); | |
} | |
else { | |
@todo = @ARGV; | |
} | |
#--- activate (link) or deactivate (remove) module | |
foreach my $do (@todo) { | |
if ($enabling) { | |
next unless defined($available{$do}); | |
my $target = sprintf("%s/conf-enabled/%s", $confdir,basename($available{$do})); | |
print qq{Enabling $do: }; | |
my $st = stat($target); | |
unless ( -f $target ) { | |
if (symlink("../conf-available/" . basename($available{$do}), $target)) { | |
print "ok\n"; | |
} | |
else { | |
print "failure: $!\n"; | |
} | |
} | |
else { | |
print "already enabled\n"; | |
} | |
#--- check dependencies | |
for my $module (@{$moduledeps{$do}}) | |
{ | |
unless ( -f $target && -l $target ) | |
{ | |
print qq{Module $do depends on module $module which is not activated.\n}; | |
} | |
} | |
} | |
else { | |
if (defined($enabled{$do})) { | |
print qq{Disabling $do\n}; | |
my $target = sprintf("%s/conf-enabled/%s", $confdir,basename($enabled{$do})); | |
unlink($target); | |
} else { | |
print qq{Already disabled $do\n}; | |
} | |
} | |
} | |
print "Run /etc/init.d/lighttpd force-reload to enable changes\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server.modules = ( | |
"mod_access", | |
"mod_alias", | |
"mod_compress", | |
"mod_redirect", | |
"mod_rewrite" | |
) | |
server.document-root = "/var/www" | |
server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) | |
server.errorlog = "/var/log/lighttpd/error.log" | |
server.pid-file = "/var/run/lighttpd.pid" | |
server.username = "www-data" | |
server.groupname = "www-data" | |
index-file.names = ( "index.php", "index.html", "index.htm" ) | |
url.access-deny = ( "~", ".inc" ) | |
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) | |
dir-listing.encoding = "utf-8" | |
server.dir-listing = "enable" | |
compress.cache-dir = "/var/cache/lighttpd/compress/" | |
compress.filetype = ( "application/x-javascript", "text/css", "text/html", "text/plain" ) | |
include_shell "/usr/share/lighttpd/use-ipv6.pl" | |
include_shell "/usr/share/lighttpd/create-mime.assign.pl" | |
include_shell "/usr/share/lighttpd/include-conf-enabled.pl" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: lighted | |
# Required-Start: $syslog $remote_fs $network | |
# Required-Stop: $syslog $remote_fs $network | |
# Should-Start: fam | |
# Should-Stop: fam | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start the lighted web server. | |
### END INIT INFO | |
PATH=/sbin:/bin:/usr/sbin:/usr/bin | |
DAEMON=/usr/sbin/lighttpd | |
NAME=lighttpd | |
DESC="web server" | |
PIDFILE=/var/run/$NAME.pid | |
SCRIPTNAME=/etc/init.d/$NAME | |
DAEMON_OPTS="-f /etc/lighttpd/lighttpd.conf" | |
test -x $DAEMON || exit 0 | |
set -e | |
check_syntax() | |
{ | |
$DAEMON -t $DAEMON_OPTS > /dev/null || exit $? | |
} | |
if [ "$1" != status ]; then | |
# be sure there is a /var/run/lighttpd, even with tmpfs | |
mkdir --mode 750 --parents /var/run/lighttpd | |
chown www-data:www-data /var/run/lighttpd | |
fi | |
. /lib/lsb/init-functions | |
case "$1" in | |
start) | |
check_syntax | |
log_daemon_msg "Starting $DESC" $NAME | |
if ! start-stop-daemon --start --oknodo --quiet \ | |
--pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS | |
then | |
log_end_msg 1 | |
else | |
log_end_msg 0 | |
fi | |
;; | |
stop) | |
log_daemon_msg "Stopping $DESC" $NAME | |
if start-stop-daemon --stop --retry 30 --oknodo --quiet \ | |
--pidfile $PIDFILE --exec $DAEMON | |
then | |
rm -f $PIDFILE | |
log_end_msg 0 | |
else | |
log_end_msg 1 | |
fi | |
;; | |
reload|force-reload) | |
check_syntax | |
log_daemon_msg "Reloading $DESC configuration" $NAME | |
if start-stop-daemon --stop --signal INT --quiet \ | |
--pidfile $PIDFILE --exec $DAEMON | |
then | |
rm $PIDFILE | |
if start-stop-daemon --start --quiet \ | |
--pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS ; then | |
log_end_msg 0 | |
else | |
log_end_msg 1 | |
fi | |
else | |
log_end_msg 1 | |
fi | |
;; | |
reopen-logs) | |
log_daemon_msg "Reopening $DESC logs" $NAME | |
if start-stop-daemon --stop --signal HUP --oknodo --quiet \ | |
--pidfile $PIDFILE --exec $DAEMON | |
then | |
log_end_msg 0 | |
else | |
log_end_msg 1 | |
fi | |
;; | |
restart) | |
check_syntax | |
$0 stop | |
$0 start | |
;; | |
status) | |
status_of_proc -p "$PIDFILE" "$DAEMON" lighttpd && exit 0 || exit $? | |
;; | |
*) | |
echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server.modules += ( "mod_mysql_vhost" ) | |
mysql-vhost.db = "lighttpd" | |
mysql-vhost.user = "lighttpd" | |
mysql-vhost.sock = "/var/run/mysqld/mysqld.sock" | |
mysql-vhost.sql = "SELECT docroot FROM hosts WHERE hostname = '?';" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server.modules += ( "mod_setenv" ) | |
server.modules += ( "mod_cgi" ) | |
$HTTP["url"] =~ ".php$" { | |
setenv.add-environment = ( | |
"SUPHP_HANDLER" => "x-httpd-suphp" | |
) | |
} | |
cgi.assign = ( | |
".php" => "/usr/lib/suphp/suphp" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/perl -w | |
use Socket; | |
my $sock; | |
if (socket($sock, AF_INET6, SOCK_STREAM, 0)) { | |
print qq/\$SERVER["socket"] == "[::]:80" { }\n/; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment