From 225f7184548aec1084bdb6521e1f16a4e578539e Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 2 Jan 2013 23:46:32 +0000 Subject: [PATCH] Bug 9316: Add ability to install/configure nginx - Minor Corrections This patch adds minor changes to koha-plack.sh upstart script and a few corrections to permissions and missing directory locations to quiet errors This patch should be applied after Elliott Davis's patch. Test as before: 1) Ensure that you have nginx installed 2) Esure that you have the following packages installed libplack-perl libcgi-emulate-psgi-perl libcgi-compile-perl starman 3) Apply patch 4) Run through the make file, you will notice 5 new configuration options. 5) Make sure you choose NGiNX as your webserver 6) You may choose whatever ports you wish and also whatever DNS entries you wish 7) After you're done configuring run make 8) Run make install (you may need sudo if you've used sudo before) 9) Start plack (you may wish to copy the script to init.d) with the script in koha-dev/bin/koha-plack.sh (requires sudo) 10) TURN OFF APACHE, and start NGiNX 11) go to your web browser and see if everything fires up as normal. --- Makefile.PL | 15 ++++++++- misc/bin/koha-plack.sh | 70 ++++++++++++++++++++++++-------------- rewrite-config.PL | 1 + skel/var/lock/koha/plack/README | 1 + skel/var/run/koha/plack/README | 1 + 5 files changed, 61 insertions(+), 27 deletions(-) mode change 100644 => 100755 misc/bin/koha-plack.sh mode change 100644 => 100755 misc/bin/koha.psgi create mode 100644 skel/var/lock/koha/plack/README create mode 100644 skel/var/run/koha/plack/README diff --git a/Makefile.PL b/Makefile.PL index 0191cc0..d7114b3 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -196,6 +196,14 @@ Directory for Zebra's data files. Directory for Zebra's UNIX-domain sockets. +=item PLACK_LOCK_DIR + +Directory for Plack's lock files. + +=item PLACK_RUN_DIR + +Directory for Plack's UNIX-domain sockets. + =item MISC_DIR Directory for for miscellaenous scripts, among other @@ -298,7 +306,8 @@ my $target_map = { './skel' => 'NONE', './skel/var/log/koha' => { target => 'LOG_DIR', trimdir => -1 }, './skel/var/spool/koha' => { target => 'BACKUP_DIR', trimdir => -1 }, - './skel/var/run/koha/plack' => { target => 'PLACK_RUN_DIR', trimdir => -1 }, + './skel/var/run/koha/plack' => { target => 'PLACK_RUN_DIR', trimdir => -1 }, + './skel/var/lock/koha/plack' => { target => 'PLACK_LOCK_DIR', trimdir => 6 }, './skel/var/run/koha/zebradb' => { target => 'ZEBRA_RUN_DIR', trimdir => -1 }, './skel/var/lock/koha/zebradb/authorities' => { target => 'ZEBRA_LOCK_DIR', trimdir => 6 }, './skel/var/lib/koha/zebradb/authorities/key' => { target => 'ZEBRA_DATA_DIR', trimdir => 6 }, @@ -598,6 +607,7 @@ my %test_suite_override_dirs = ( ZEBRA_LOCK_DIR => ['var', 'lock', 'zebradb'], ZEBRA_DATA_DIR => ['var', 'lib', 'zebradb'], ZEBRA_RUN_DIR => ['var', 'run', 'zebradb'], + PLACK_LOCK_DIR => ['var', 'lock', 'plack'], PLACK_RUN_DIR => ['var', 'run', 'plack'], ); @@ -1316,6 +1326,7 @@ sub get_target_directories { $dirmap{'BACKUP_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'spool'); $dirmap{'ZEBRA_DATA_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lib', 'zebradb'); $dirmap{'ZEBRA_RUN_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'run', 'zebradb'); + $dirmap{'PLACK_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'plack'); $dirmap{'PLACK_RUN_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'run', 'plack'); } elsif ($mode eq 'dev') { my $curdir = File::Spec->rel2abs(File::Spec->curdir()); @@ -1347,6 +1358,7 @@ sub get_target_directories { $dirmap{'BACKUP_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'spool'); $dirmap{'ZEBRA_DATA_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lib', 'zebradb'); $dirmap{'ZEBRA_RUN_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'run', 'zebradb'); + $dirmap{'PLACK_LOCK_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'lock', 'plack'); $dirmap{'PLACK_RUN_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'run', 'plack'); } else { # mode is standard, i.e., 'fhs' @@ -1370,6 +1382,7 @@ sub get_target_directories { $dirmap{'BACKUP_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'spool', $package); $dirmap{'ZEBRA_DATA_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'lib', $package, 'zebradb'); $dirmap{'ZEBRA_RUN_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'run', $package, 'zebradb'); + $dirmap{'PLACK_LOCK_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'lock', $package, 'plack'); $dirmap{'PLACK_RUN_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'run', $package, 'plack'); } diff --git a/misc/bin/koha-plack.sh b/misc/bin/koha-plack.sh old mode 100644 new mode 100755 index 954c968..16dc055 --- a/misc/bin/koha-plack.sh +++ b/misc/bin/koha-plack.sh @@ -1,7 +1,7 @@ -#!/bin/sh -e - +#!/bin/bash + # This file is part of Koha. -# +# # Koha is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation; either version 3 of the License, or (at your option) any later @@ -15,10 +15,13 @@ # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA -### BEGIN INIT INFO# Provides: koha-plack +### BEGIN INIT INFO +# Provides: koha-plack-daemon # Required-Start: $syslog $remote_fs -# Required-Stop: $syslog $remote_fs# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6# Short-Description: Plack server for Koha +# Required-Stop: $syslog $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Plack server daemon for Koha ### END INIT INFO export KOHA_CONF=__KOHA_CONF_DIR__/koha-conf.xml @@ -28,46 +31,61 @@ export LOGDIR=__LOG_DIR__ USER=__KOHA_USER__ GROUP=__KOHA_GROUP__ RUNDIR=__PLACK_RUN_DIR__ -PIDFILE=$RUNDIR/plack.pid +LOCKDIR=__PLACK_LOCK_DIR__ +PIDFILE=$LOCKDIR/plack.pid # Use one of these lines to choose between TCP port and UNIX socket listeners SOCKET=$RUNDIR/plack.sock #PORT=5000 +OTHERUSER='' +if [[ $EUID -eq 0 ]]; then + OTHERUSER="--user $USER --group $GROUP" +fi + case "$1" in start) - echo "Starting Koha Plack Daemon" + echo "Starting Plack Server" # create run and lock directories if needed; # /var/run and /var/lock are completely cleared at boot # on some platforms - if [ ! -d $RUNDIR ]; then + if [[ ! -d $RUNDIR ]]; then umask 022 mkdir -p $RUNDIR - if [ $EUID -eq 0 ]; then + if [[ $EUID -eq 0 ]]; then chown $USER:$GROUP $RUNDIR fi fi - - opt="$opt --access-log $LOGDIR/koha-access.log --error-log $LOGDIR/koha-error.log" - opt="$opt -M FindBin --max-requests 50 --workers 2 -E deployment" - if [ $SOCKET ]; then - opt="$opt --listen $SOCKET -D --pid $PIDFILE" - elif [ $PORT ]; then - opt="$opt --port $PORT -D --pid $PIDFILE" + if [[ ! -d $LOCKDIR ]]; then + umask 022 + mkdir -p $LOCKDIR + if [[ $EUID -eq 0 ]]; then + chown -R $USER:$GROUP $LOCKDIR fi - starman $opt __SCRIPT_DIR__/koha.psgi + fi - if [ $SOCKET ]; then - chown $USER:$GROUP $SOCKET - chmod 660 $SOCKET - fi - ;; + opt="$opt $OTHERUSER" + opt="$opt --access-log $LOGDIR/koha-access.log --error-log $LOGDIR/koha-error.log" + opt="$opt -M FindBin --max-requests 50 --workers 2 -E deployment" + if [ $SOCKET ]; then + opt="$opt --listen $SOCKET -D --pid $PIDFILE" + elif [ $PORT ]; then + opt="$opt --port $PORT -D --pid $PIDFILE" + fi + starman $opt __SCRIPT_DIR__/koha.psgi + + if [ $SOCKET ]; then + chown $USER:$GROUP $SOCKET + chmod 662 $SOCKET + fi + ;; stop) - start-stop-daemon --stop --pidfile $PIDFILE - ;; + echo "Stopping Plack Server" + start-stop-daemon --stop --pidfile $PIDFILE + ;; *) echo "Usage: koha-plack {start|stop}" exit 1 ;; -esac \ No newline at end of file +esac diff --git a/misc/bin/koha.psgi b/misc/bin/koha.psgi old mode 100644 new mode 100755 diff --git a/rewrite-config.PL b/rewrite-config.PL index 58490f7..774ae1b 100644 --- a/rewrite-config.PL +++ b/rewrite-config.PL @@ -124,6 +124,7 @@ $prefix = $ENV{'INSTALL_BASE'} || "/usr"; '__ZEBRA_LOCK_DIR__' => "$prefix/var/lock/zebradb", '__ZEBRA_DATA_DIR__' => "$prefix/var/lib/zebradb", '__ZEBRA_RUN_DIR__' => "$prefix/var/run/zebradb", + '__PLACK_LOCK_DIR__' => "$prefix/var/lock/plack", '__PLACK_RUN_DIR__' => "$prefix/var/run/plack", '__ZEBRA_MARC_FORMAT__' => 'marc21', '__ZEBRA_LANGUAGE__' => 'en', diff --git a/skel/var/lock/koha/plack/README b/skel/var/lock/koha/plack/README new file mode 100644 index 0000000..6c11be4 --- /dev/null +++ b/skel/var/lock/koha/plack/README @@ -0,0 +1 @@ +Plack lock dir diff --git a/skel/var/run/koha/plack/README b/skel/var/run/koha/plack/README new file mode 100644 index 0000000..fa44b0b --- /dev/null +++ b/skel/var/run/koha/plack/README @@ -0,0 +1 @@ +Plack Unix-domain sockets -- 1.7.2.5