Lighttpd

From GeilThings

Jump to: navigation, search
Lighttpd
General
Version 1.4.32
Stable 1.4.32
Function Web Server
Port 49707
Files
Config File /etc/lighttpd/lighttpd.conf
Log File /var/log/lighttpd/*
Scripts
Version Script lighttpd -version
Start service lighttpd start
Stop service lighttpd stop

Contents

General

Installing Lighttpd

APPNAME=lighttpd
 
RAWNEWVERSION=`curl -d "action=ask&query=[[Lighttpd]]|%3FStable&format=json" http://www.geilthings.com/api.php`
# Get Version as Substring. 
# Using grep to sed to extract STRING between first occurrence of MATCH1 and next occurrence of MATCH2: 
# http://stackoverflow.com/questions/4392106/sed-extract-string-between-first-occurrence-of-match1-and-next-occurrence-of-m 
NEWVERSION=`echo "$RAWNEWVERSION" | grep -Po '^.*?\K(?<=Stable\":\[\").*?(?=\")'`
# Test.
echo $NEWVERSION
 
MAINNEWVERSION=${NEWVERSION:0:3}
echo $MAINNEWVERSION
 
cd /opt
# Get the file
wget http://download.lighttpd.net/lighttpd/releases-${MAINNEWVERSION}.x/lighttpd-${NEWVERSION}.tar.gz
tar -zxvf lighttpd-${NEWVERSION}.tar.gz
cd lighttpd-${NEWVERSION}
./configure
# Disabled Plugins: mod_cml, mod_magnet, mod_mysql_vhost
# Disabled Features: auth-ldap, network-openssl, stat-cache-fam, storage-gdbm, 
# Disabled Features: storage-memcache, webdav-locks, webdav-properties
make
make install
 
ln -s /opt/lighttpd-${NEWVERSION} /opt/lighttpd

Configuring Lighttpd

# Create lighttpd.conf.
mkdir -p /etc/lighttpd
# Check for an available port.
netstat -an | grep <port_number>
# If the result of the command "netstat -an | grep <port_number>" is empty, that would be an indication that port_number is probably available.
# The range of 49151 < port_number < 65536 is particularly suited for this since only dynamic or private ports are usually assigned in this range, see 
# http://en.wikipedia.org/wiki/Registered_port
mkdir -p /var/log/lighttpd
 
# Either create user and group "www" (Rackspace), or use existing ones.
 
# Copy Rackspace's script to /etc/init.d/lighttpd
touch /etc/init.d/lighttpd
chmod a+rx /etc/init.d/lighttpd
 
# To avoid "(log.c.118) opening errorlog '/var/log/lighttpd/lighttpd.error.log' failed: Permission denied":
chown -R apache. /var/log/lighttpd/
 
service lighttpd start
 
# Test.
curl -v http://127.0.0.1:49707/index.html

Upgrade Lighttpd

APPNAME=lighttpd
DATE=`date +%Y-%m-%d` 
 
RAWOLDVERSION=`lighttpd -version`
OLDVERSION=`echo "$RAWOLDVERSION" | grep -Po '^.*?\K(?<=/).*?(?= )'`
echo ${OLDVERSION}
 
RAWNEWVERSION=`curl -d "action=ask&query=[[Lighttpd]]|%3FStable&format=json" http://www.geilthings.com/api.php`
# Get Version as Substring. 
# Using grep to sed to extract STRING between first occurrence of MATCH1 and next occurrence of MATCH2: 
# http://stackoverflow.com/questions/4392106/sed-extract-string-between-first-occurrence-of-match1-and-next-occurrence-of-m 
NEWVERSION=`echo "$RAWNEWVERSION" | grep -Po '^.*?\K(?<=Stable\":\[\").*?(?=\")'`
# Test.
echo $NEWVERSION
 
MAINNEWVERSION=${NEWVERSION:0:3}
echo $MAINNEWVERSION
 
if [[ ${OLDVERSION} != ${NEWVERSION} ]]; then
  echo ${APPNAME}: installed: ${OLDVERSION}, actual: ${NEWVERSION}
  echo "You could update ${APPNAME} to ${NEWVERSION}"
  echo "Would you like to install ${APPNAME} ${NEWVERSION} y/n?"
  read item
  if [[ "$item" == "y" || "$item" == "Y" ]]; then
    echo "Installing ${APPNAME} ${NEWVERSION}. Follow instructions."
  else
    echo "Exit"
  fi
else
  echo "You don't need to update ${APPNAME}; it is uptodate (${NEWVERSION})"
fi
 
BACKUPDIR=/home/backup/${APPNAME}/${APPNAME}_${OLDVERSION}_${DATE}
if [ ! -d "${BACKUPDIR}" ]
then
    mkdir -m 755 -p ${BACKUPDIR}
fi
cp -rp /etc/lighttpd/* $BACKUPDIR
 
cd /opt
# Get the file
wget http://download.lighttpd.net/lighttpd/releases-${MAINNEWVERSION}.x/lighttpd-${NEWVERSION}.tar.gz
tar -zxvf lighttpd-${NEWVERSION}.tar.gz
cd lighttpd-${NEWVERSION}
 
vi NEWS
:q
 
vi README
:q
 
vi INSTALL
:q
 
# Stop the server before updating.
service lighttpd stop
 
cd /opt/lighttpd-${NEWVERSION}
./configure
make
make install
 
# Check that the config file from the new version
# (under ./doc/config/lighttpd.conf) is similar to the file /etc/lighttpd/lighttpd.conf
# ...
 
rm -f /opt/lighttpd
ln -s /opt/lighttpd-${NEWVERSION} /opt/lighttpd
 
service lighttpd start
 
ps aux | grep lighttpd
lighttpd -v
 
# Check applications ...

Versions

Software name Version number Version date
Lighttpd 1.4.32 22 November 2012

Comments

blog comments powered by Disqus