Bugzilla – Attachment 14257 Details for
Bug 9316
Add Nginx install options with plack
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9316: Add ability to install/configure nginx
Bug-9316-Add-ability-to-installconfigure-nginx.patch (text/plain), 14.80 KB, created by
Elliott Davis
on 2012-12-24 23:50:07 UTC
(
hide
)
Description:
Bug 9316: Add ability to install/configure nginx
Filename:
MIME Type:
Creator:
Elliott Davis
Created:
2012-12-24 23:50:07 UTC
Size:
14.80 KB
patch
obsolete
>From 0608199e1f85192c204840fd811215f890c9e201 Mon Sep 17 00:00:00 2001 >From: Elliott Davis <elliott@bywatersolions.com> >Date: Mon, 24 Dec 2012 18:46:01 -0500 >Subject: [PATCH] Bug 9316: Add ability to install/configure nginx > >To Test: >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 >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 | 85 ++++++++++++++++++++++++++++++++++++++++++++++- > etc/koha-httpd.conf | 12 +++--- > etc/koha-nginx.conf | 52 +++++++++++++++++++++++++++++ > misc/bin/koha-plack.sh | 72 ++++++++++++++++++++++++++++++++++++++++ > misc/bin/koha.psgi | 44 +++++++++++++++++++++++++ > rewrite-config.PL | 6 +++ > 6 files changed, 263 insertions(+), 8 deletions(-) > create mode 100644 etc/koha-nginx.conf > create mode 100644 misc/bin/koha-plack.sh > create mode 100644 misc/bin/koha.psgi > >diff --git a/Makefile.PL b/Makefile.PL >index 6c6e186..12cdec8 100644 >--- a/Makefile.PL >+++ b/Makefile.PL >@@ -345,6 +345,26 @@ Koha from a git clone with no fuss). > Directory under which most components will go. Default > value will vary depending on INSTALL_MODE. > >+=item WEBSERVER >+ >+Type of WebServer ( Apache2 or NGINX). >+ >+=item INTRANET_DNS >+ >+Set the DNS entry for staff client >+ >+=item OPAC_DNS >+ >+Set the DNS entry for OPAC >+ >+=item INTRANET_PORT >+ >+Set the port for the staff client >+ >+=item OPAC_PORT >+ >+Set the port for the OPAC >+ > =item DB_TYPE > > Type of DBMS (e.g., mysql or Pg). >@@ -405,6 +425,11 @@ System group that will own Koha's files. > > # default configuration options > my %config_defaults = ( >+ 'WEBSERVER' => 'apache2', >+ 'INTRANET_DNS' => 'localhost', >+ 'OPAC_DNS' => 'localhost', >+ 'INTRANET_PORT' => '8080', >+ 'OPAC_PORT' => '80', > 'DB_TYPE' => 'mysql', > 'DB_HOST' => 'localhost', > 'DB_NAME' => 'koha', >@@ -464,6 +489,7 @@ else { > my %valid_config_values = ( > 'INSTALL_MODE' => { 'standard' => 1, 'single' => 1, 'dev' => 1 }, > 'DB_TYPE' => { 'mysql' => 1, 'Pg' => 1 }, >+ 'WEBSERVER' => { 'apache2' => 1, 'nginx' => 1 }, > 'INSTALL_ZEBRA' => { 'yes' => 1, 'no' => 1 }, > 'INSTALL_SRU' => { 'yes' => 1, 'no' => 1 }, > 'AUTH_INDEX_MODE' => { 'grs1' => 1, 'dom' => 1 }, >@@ -496,15 +522,27 @@ get_file_map($target_map, $dirtree, $file_map, $config{'INSTALL_ZEBRA'} eq "yes" > my $pl_files = { > 'rewrite-config.PL' => [ > 'blib/KOHA_CONF_DIR/koha-conf.xml', >- 'blib/KOHA_CONF_DIR/koha-httpd.conf', >+ 'blib/KOHA_CONF_DIR/koha-nginx.conf', > 'blib/ZEBRA_CONF_DIR/etc/default.idx', >- 'blib/MISC_DIR/koha-install-log' >+ 'blib/MISC_DIR/koha-install-log', > ], > 'fix-perl-path.PL' => [ # this script ensures the correct shebang line for the platform installed on... > 'blib' > ], > }; > >+if ($config{'WEBSERVER'} eq "apache2"){ >+ push @{ $pl_files->{'rewrite-config.PL'} }, ( >+ 'blib/KOHA_CONF_DIR/koha-httpd.conf', >+ ); >+} >+else { >+ push @{ $pl_files->{'rewrite-config.PL'} }, ( >+ 'blib/SCRIPT_DIR/koha.psgi', >+ 'blib/SCRIPT_DIR/koha-plack.sh', >+ ); >+} >+ > if ($config{'INSTALL_ZEBRA'} eq "yes") { > push @{ $pl_files->{'rewrite-config.PL'} }, ( > 'blib/ZEBRA_CONF_DIR/etc/passwd', >@@ -559,6 +597,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_RUN_DIR => ['var', 'run', 'plack'], > ); > > WriteMakefile( >@@ -865,6 +904,45 @@ Group); > } > > $msg = q( >+Please specify which WebServer you will use >+to serve data in Koha. The choices are Apache2 and >+NGINX; please note that at the moment >+NGINX support is highly experimental. >+ >+WebServer to use); >+ $msg .= _add_valid_values_disp('WEBSERVER', $valid_values); >+ $config{'WEBSERVER'} = _get_value('WEBSERVER', $msg, $defaults->{'WEBSERVER'}, $valid_values, $install_log_values); >+ >+ $msg = q( >+Please specify which WebServer you will use >+to serve data in Koha. The choices are Apache2 and >+NGINX; please note that at the moment >+NGINX support is highly experimental. >+ >+Intranet DNS Settings); >+ $config{'INTRANET_DNS'} = _get_value('INTRANET_DNS', $msg, $defaults->{'INTRANET_DNS'}, $valid_values, $install_log_values); >+ >+ $msg = q( >+Please specify if you would like a DNS >+entry for the Koha Staff Client. >+ >+OPAC DNS Settings); >+ $config{'OPAC_DNS'} = _get_value('OPAC_DNS', $msg, $defaults->{'OPAC_DNS'}, $valid_values, $install_log_values); >+ >+ $msg = q( >+Please specify the port you would >+like the Koha Staff Client to use. >+ >+Intranet Port Settings); >+ $config{'INTRANET_PORT'} = _get_value('INTRANET_PORT', $msg, $defaults->{'INTRANET_PORT'}, $valid_values, $install_log_values); >+ $msg = q( >+Please specify if you would like a DNS >+entry for the Koha Staff Client. >+ >+OPAC Port Settings); >+ $config{'OPAC_PORT'} = _get_value('OPAC_PORt', $msg, $defaults->{'OPAC_PORT'}, $valid_values, $install_log_values); >+ >+ $msg = q( > Please specify which database engine you will use > to store data in Koha. The choices are MySQL and > PostgreSQL; please note that at the moment >@@ -1237,6 +1315,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_RUN_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'run', 'plack'); > } elsif ($mode eq 'dev') { > my $curdir = File::Spec->rel2abs(File::Spec->curdir()); > $dirmap{'INTRANET_CGI_DIR'} = File::Spec->catdir($curdir); >@@ -1267,6 +1346,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_RUN_DIR'} = File::Spec->catdir(@basedir, $package, 'var', 'run', 'plack'); > } else { > # mode is standard, i.e., 'fhs' > $dirmap{'INTRANET_CGI_DIR'} = File::Spec->catdir(@basedir, $package, 'intranet', 'cgi-bin'); >@@ -1289,6 +1369,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_RUN_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'run', $package, 'plack'); > } > > _get_env_overrides(\%dirmap); >diff --git a/etc/koha-httpd.conf b/etc/koha-httpd.conf >index dc82d08..f0edb61 100644 >--- a/etc/koha-httpd.conf >+++ b/etc/koha-httpd.conf >@@ -3,11 +3,11 @@ > #NameVirtualHost * > > ## OPAC >-<VirtualHost __WEBSERVER_IP__:__WEBSERVER_PORT__> >+<VirtualHost __OPAC_DNS__:__OPAC_PORT__> > ServerAdmin __WEBMASTER_EMAIL__ > DocumentRoot __OPAC_WWW_DIR__ >- ServerName __WEBSERVER_HOST__ >-# ServerAlias opac.mydomain.com >+ ServerName __OPAC_DNS__:__OPAC_PORT__ >+# ServerAlias __OPAC_DNS__ > ScriptAlias /cgi-bin/koha/ "__OPAC_CGI_DIR__/opac/" > ScriptAlias /index.html "__OPAC_CGI_DIR__/opac/opac-main.pl" > ScriptAlias /opac-search.pl "__OPAC_CGI_DIR__/opac/opac-search.pl" >@@ -97,11 +97,11 @@ > </VirtualHost> > > ## Intranet >-<VirtualHost __WEBSERVER_IP__:__WEBSERVER_PORT_LIBRARIAN__> >+<VirtualHost __INTRANET_DNS__:__INTRANET_PORT__> > ServerAdmin __WEBMASTER_EMAIL__ > DocumentRoot __INTRANET_WWW_DIR__ >- ServerName __WEBSERVER_HOST__:__WEBSERVER_PORT_LIBRARIAN__ >-# ServerAlias intranet.mydomain.com >+ ServerName __INTRANET_DNS__:__INTRANET_PORT__ >+# ServerAlias __INTRANET_DNS__ > ScriptAlias /cgi-bin/koha/ "__INTRANET_CGI_DIR__/" > ScriptAlias /index.html "__INTRANET_CGI_DIR__/mainpage.pl" > ScriptAlias /search "__INTRANET_CGI_DIR__/search.pl" >diff --git a/etc/koha-nginx.conf b/etc/koha-nginx.conf >new file mode 100644 >index 0000000..8397266 >--- /dev/null >+++ b/etc/koha-nginx.conf >@@ -0,0 +1,52 @@ >+upstream backendurl { >+ server unix:__PLACK_RUN_DIR__/plack.sock; >+} >+ >+server { >+ listen __OPAC_PORT__; >+ server_name __INTRANET_DNS__; >+ access_log __LOG_DIR__/nginx-opac-access.log; >+ root __OPAC_WWW_DIR__; >+ >+ rewrite ^/$ /cgi-bin/koha/opac-main.pl; >+ rewrite ^/cgi-bin/koha/(.*)$ /cgi-bin/koha/opac/$1; >+ >+ location / { >+ try_files $uri @plack; >+ } >+ location /opac-tmpl/ { >+ root __OPAC_TMPL_DIR__; >+ } >+ >+ location @plack { >+ proxy_set_header Host $http_host; >+ proxy_set_header X-Forwarded-Host $host; >+ proxy_set_header X-Real-IP $remote_addr; >+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; >+ proxy_pass http://backendurl; >+ } >+} >+ >+server { >+ listen __INTRANET_PORT__; >+ server_name __INTRANET_DNS__; >+ access_log __LOG_DIR__/nginx-intranet-access.log; >+ root __INTRANET_WWW_DIR__; >+ >+ rewrite ^/$ /cgi-bin/koha/mainpage.pl; >+ >+ location / { >+ try_files $uri @plack; >+ } >+ location /intranet-tmpl/ { >+ root __INTRANET_TMPL_DIR__; >+ } >+ >+ location @plack { >+ proxy_set_header Host $http_host; >+ proxy_set_header X-Forwarded-Host $host; >+ proxy_set_header X-Real-IP $remote_addr; >+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; >+ proxy_pass http://backendurl; >+ } >+} >\ No newline at end of file >diff --git a/misc/bin/koha-plack.sh b/misc/bin/koha-plack.sh >new file mode 100644 >index 0000000..867047a >--- /dev/null >+++ b/misc/bin/koha-plack.sh >@@ -0,0 +1,72 @@ >+#!/bin/sh -e >+ >+# 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 >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along with >+# 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 >+# 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 >+### END INIT INFO >+ >+export KOHA_CONF=__KOHA_CONF_DIR__/koha-conf.xml >+#export OPACDIR=__OPAC_WWW_DIR__ >+#export INTRANETDIR=__OPAC_WWW_DIR__ >+export LOGDIR=__LOG_DIR__ >+USER=__KOHA_USER__ >+USER=__KOHA_GROUP__ >+RUNDIR=__PLACK_RUN_DIR__ >+PIDFILE=$RUNDIR/plack.pid >+ >+# Use one of these lines to choose between TCP port and UNIX socket listeners >+SOCKET=$RUNDIR/plack.sock >+#PORT=5000 >+ >+case "$1" in >+ start) >+ echo "Starting Koha Plack Daemon" >+ >+ # create run and lock directories if needed; >+ # /var/run and /var/lock are completely cleared at boot >+ # on some platforms >+ if [[ ! -d $RUNDIR ]]; then >+ umask 022 >+ mkdir -p $RUNDIR >+ 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" >+ fi >+ starman $opt __SCRIPT_DIR__/koha.psgi >+ >+ if [ $SOCKET ]; then >+ chown $USER:$GROUP $SOCKET >+ fi >+ ;; >+ stop) >+ start-stop-daemon --stop --pidfile $PIDFILE >+ ;; >+ *) >+ echo "Usage: koha-plack {start|stop}" >+ exit 1 >+ ;; >+esac >\ No newline at end of file >diff --git a/misc/bin/koha.psgi b/misc/bin/koha.psgi >new file mode 100644 >index 0000000..ea160d9 >--- /dev/null >+++ b/misc/bin/koha.psgi >@@ -0,0 +1,44 @@ >+#!/usr/bin/perl >+ >+BEGIN { >+ $ENV{'KOHA_CONF'} = '__KOHA_CONF_DIR__/koha-conf.xml'; >+ $ENV{'PERL5LIB'} = '__PERL_MODULE_DIR__'; >+} >+ >+use lib("__PERL_MODULE_DIR__"); >+use lib("__PERL_MODULE_DIR__/installer"); >+use Plack::Builder; >+use Plack::App::CGIBin; >+use Plack::App::Directory; >+use Plack::Middleware::Debug; >+use Plack::App::URLMap; >+use C4::Context; >+use C4::Languages; >+use C4::Members; >+use C4::Dates; >+use C4::Boolean; >+use C4::Letters; >+use C4::Koha; >+use C4::XSLT; >+use C4::Branch; >+use C4::Category; >+ >+C4::Context->disable_syspref_cache(); >+ >+my $intra=Plack::App::CGIBin->new(root => "__INTRANET_CGI_DIR__" ); >+ >+my $opac = Plack::App::CGIBin->new(root => "__OPAC_CGI_DIR__"); >+ >+builder { >+ enable 'Debug', panels => [ >+ qw(Environment Response Timer Memory), >+ [ 'DBITrace', level => 1 ], >+ ]; >+ >+ enable "Plack::Middleware::Static"; >+ >+ enable 'StackTrace'; >+ >+ mount '/cgi-bin/koha/' => $intra; >+ mount '/cgi-bin/koha/opac' => $opac; >+}; >diff --git a/rewrite-config.PL b/rewrite-config.PL >index 02715ab..58490f7 100644 >--- a/rewrite-config.PL >+++ b/rewrite-config.PL >@@ -82,6 +82,11 @@ $prefix = $ENV{'INSTALL_BASE'} || "/usr"; > %configuration = ( > "__KOHA_INSTALLED_VERSION__" => "no_version_found", > "__LOG_DIR__" => "/var/log", >+ "__WEBSERVER__" => "apache2", >+ "__INTRANET_DNS__" => "localhost", >+ "__OPAC_DNS__" => "localhost", >+ "__OPAC_PORT__" => "80", >+ "__INTRANET_PORT__" => "8080", > "__DB_TYPE__" => "mysql", > "__DB_NAME__" => "koha", > "__DB_HOST__" => $myhost, >@@ -119,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_RUN_DIR__' => "$prefix/var/run/plack", > '__ZEBRA_MARC_FORMAT__' => 'marc21', > '__ZEBRA_LANGUAGE__' => 'en', > '__ZEBRA_TOKENIZER_STMT__' => 'charmap word-phrase-utf.chr', >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9316
:
14257
|
14322
|
14369
|
14370
|
14371
|
14375
|
14376
|
14378
|
14379
|
14381
|
14383
|
14385
|
14789
|
15151
|
15859
|
21818
|
21819
|
22767