Nginx 0.6.33

Aus Bennys Wiki
Wechseln zu: Navigation, Suche

Nginx 0.6.33 als Debian Packet bauen[Bearbeiten]

Da in Debian leider nur die alte Version 0.4.13 mit dabei ist und die aktuell als stabil deklarierte Version 0.6.33 ist habe ich mich entschieden das Packet neu zu bauen. Zudem kam noch dazu das in der Debian Version das Packet ohne realip_module, http_ssl_module sowie dem mail support (imap und pop3 reverse proxy) und den entsprechendem ssl module

Als erstes den Sourcecode unter
http://sysoev.ru/nginx/nginx-0.6.33.tar.gz
herunterladen und an einer geeigneten Stelle z.B. /usr/src auspacken.

Danach folgenden Patch anwenden, welcher lediglich eine veränderte Version des Debian Patches http://ftp.de.debian.org/debian/pool/main/n/nginx/nginx_0.4.13-2.diff.gz ist. Einzige Änderungen sind:

  • Auf im 0.6.33 Tarball mitgeschickte nginx.conf angepasst
  • Oben beschriebene configure Parameter in der controll Datei angepasst

nginx_0.6.33-1.diff

--- nginx-0.6.33.orig/conf/nginx.conf
+++ nginx-0.6.33/conf/nginx.conf
@@ -1,13 +1,9 @@
 
-#user  nobody;
+user  www-data;
 worker_processes  1;
 
-#error_log  logs/error.log;
-#error_log  logs/error.log  notice;
-#error_log  logs/error.log  info;
-
-#pid        logs/nginx.pid;
-
+error_log  /var/log/nginx/error.log;
+pid        /var/run/nginx.pid;
 
 events {
     worker_connections  1024;
@@ -15,14 +11,14 @@
 
 
 http {
-    include       mime.types;
+    include       /etc/nginx/mime.types;
     default_type  application/octet-stream;
 
     #log_format  main  '$remote_addr - $remote_user [$time_local] $request '
     #                  '"$status" $body_bytes_sent "$http_referer" '
     #                  '"$http_user_agent" "$http_x_forwarded_for"';
 
-    #access_log  logs/access.log  main;
+    access_log  /var/log/nginx/access.log  main;
 
     sendfile        on;
     #tcp_nopush     on;
@@ -30,7 +26,7 @@
     #keepalive_timeout  0;
     keepalive_timeout  65;
 
-    #gzip  on;
+    gzip  on;
 
     server {
         listen       80;
@@ -38,10 +34,10 @@
 
         #charset koi8-r;
 
-        #access_log  logs/host.access.log  main;
+        access_log  /var/log/nginx/logs/host.access.log  main;
 
         location / {
-            root   html;
+            root   /var/www/nginx-default;
             index  index.html index.htm;
         }
 
@@ -51,7 +47,7 @@
         #
         error_page   500 502 503 504  /50x.html;
         location = /50x.html {
-            root   html;
+            root   /var/www/nginx-default;
         }
 
         # proxy the PHP scripts to Apache listening on 127.0.0.1:80--- nginx-0.6.33.orig/debian/nginx.1
--- nginx-0.6.33.orig/debain/nginx.1
+++ nginx-0.6.33/debian/nginx.1
@@ -0,0 +1,47 @@
+.TH "nginx" "1" "" "" ""
+.SH "NAME"
+nginx \- small, but very powerful and efficient web server
+.br 
+
+.br 
+.SH "SYNOPSIS"
+\fBnginx\fR [options] <configuration file>
+.br 
+
+.br 
+.SH "DESCRIPTION"
+\fBnginx\fR is a server that can be used as standalone HTTP server and as 
+a reverse proxy server before some Apache or another big server to reduce 
+load to backend servers by many concurrent HTTP\-sessions.
+.br 
+
+.br 
+.SH "OPTIONS"
+A summary of options is included below:
+.br 
+
+.br 
+\fB\-c\fR <configuration file>
+Specifies a particular configuration file for nginx to load.
+.br 
+\fB\-v\fR
+Show version of program.
+.br 
+\fB\-t\fR
+Tests nginx configuration
+.br 
+.br 
+
+.br 
+You can find further information about this webserver in http://nginx.net/docs_en.txt.
+.br 
+
+.br 
+.SH "AUTHORS"
+\fBnginx\fR was written by Igor Sysoev.
+.br 
+
+.br 
+This manual page was written by Jose Parrella <joseparrella@cantv.net>,
+for the Debian project (but may be used by others).
+
--- nginx-0.6.33.orig/debian/nginx.logrotate
+++ nginx-0.6.33/debian/nginx.logrotate
@@ -0,0 +1,13 @@
+/var/log/nginx/*.log {
+	daily
+	missingok
+	rotate 52
+	compress
+	delaycompress
+	notifempty
+	create 640 root adm
+	sharedscripts
+	postrotate
+		[ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
+	endscript
+}
--- nginx-0.6.33.orig/debian/postrm
+++ nginx-0.6.33/debian/postrm
@@ -0,0 +1,38 @@
+#!/bin/sh
+# postrm script for nginx
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+       purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+
+
+        ;;
+
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 1
+
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
--- nginx-0.6.33.orig/debian/compat
+++ nginx-0.6.33/debian/compat
@@ -0,0 +1 @@
+5
--- nginx-0.6.33.orig/debian/copyright
+++ nginx-0.6.33/debian/copyright
@@ -0,0 +1,30 @@
+This package was debianized by Jose Parrella <joseparrella@cantv.net> on
+Tue,  5 Sep 2006 11:33:34 -0400.
+
+It was downloaded from http://nginx.net/
+
+Upstream Author: Igor Sysoev <igor@sysoev.ru>
+
+Copyright (C) 2002-2006 Igor Sysoev <igor@sysoev.ru>
+
+License:
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted under the terms of the BSD License.
+
+    THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
+
+On Debian systems, the complete text of the BSD License can be 
+found in `/usr/share/common-licenses/BSD'.
+
+The Debian packaging is (C) 2006, Jose Parrella <joseparrella@cantv.net> and
+is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
--- nginx-0.6.33.orig/debian/nginx.install
+++ nginx-0.6.33/debian/nginx.install
@@ -0,0 +1,3 @@
+objs/nginx	usr/sbin
+html/*		var/www/nginx-default
+conf/*		etc/nginx
--- nginx-0.6.33.orig/debian/watch
+++ nginx-0.6.33/debian/watch
@@ -0,0 +1,11 @@
+# Example watch control file for uscan
+# Rename this file to "watch" and then you can run the "uscan" command
+# to check for upstream updates and more.
+# See uscan(1) for format
+
+# Compulsory line, this is a version 3 file
+version=3
+
+# Uncomment to examine a Webpage 
+# <Webpage URL> <string match>
+http://sysoev.ru/nginx/ nginx-(.*)\.tar\.gz
--- nginx-0.6.33.orig/debian/dirs
+++ nginx-0.6.33/debian/dirs
@@ -0,0 +1,5 @@
+usr/sbin
+etc/nginx
+var/log/nginx
+var/lib/nginx
+var/www/nginx-default
--- nginx-0.6.33.orig/debian/preinst
+++ nginx-0.6.33/debian/preinst
@@ -0,0 +1,38 @@
+#!/bin/sh
+# preinst script for nginx
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <new-preinst> `install'
+#        * <new-preinst> `install' <old-version>
+#        * <new-preinst> `upgrade' <old-version>
+#        * <old-preinst> `abort-upgrade' <new-version>
+#
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    install|upgrade)
+    ;;
+
+    abort-upgrade)
+    ;;
+
+    *)
+        echo "preinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
--- nginx-0.6.33.orig/debian/README.Debian
+++ nginx-0.6.33/debian/README.Debian
@@ -0,0 +1,9 @@
+nginx for Debian
+----------------
+
+The package didn't handle paths correctly, so the configure line has grown
+up a bit. I've also tweaked a bit the main configuration file. If you would
+like to supply patches and write or translate documentation from russian, it
+will be greatly appreciated.
+
+ -- Jose Parrella <joseparrella@cantv.net>, Tue,  5 Sep 2006 11:33:34 -0400
--- nginx-0.6.33.orig/debian/prerm
+++ nginx-0.6.33/debian/prerm
@@ -0,0 +1,39 @@
+#!/bin/sh
+# prerm script for nginx
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <prerm> `remove'
+#        * <old-prerm> `upgrade' <new-version>
+#        * <new-prerm> `failed-upgrade' <old-version>
+#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
+#        * <deconfigured's-prerm> `deconfigure' `in-favour'
+#          <package-being-installed> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    remove|remove-in-favour|deconfigure|deconfigure-in-favour)
+        invoke-rc.d nginx stop
+        ;;
+    upgrade|failed-upgrade)
+        ;;
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
--- nginx-0.6.33.orig/debian/control
+++ nginx-0.6.33/debian/control
@@ -0,0 +1,17 @@
+Source: nginx
+Section: web
+Priority: optional
+Maintainer: Jose Parrella <joseparrella@cantv.net>
+Build-Depends: debhelper (>= 5), autotools-dev, libpcre3-dev, zlib1g-dev
+Standards-Version: 3.7.2
+
+Package: nginx
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: small, but very powerful and efficient web server
+ Nginx (engine x) is a web server created by Igor Sysoev and kindly provided
+ to the open-source community. This server can be used as standalone HTTP
+ server and as a reverse proxy server before some Apache or another big 
+ server to reduce load to backend servers by many concurrent HTTP-sessions.
+ .
+ Homepage: http://nginx.net/
--- nginx-0.6.33.orig/debian/rules
+++ nginx-0.6.33/debian/rules
@@ -0,0 +1,89 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+	CFLAGS += -O0
+else
+	CFLAGS += -O2
+endif
+
+config.status:
+	dh_testdir
+
+ifneq "$(wildcard /usr/share/misc/config.sub)" ""
+		cp -f /usr/share/misc/config.sub config.sub
+endif
+ifneq "$(wildcard /usr/share/misc/config.guess)" ""
+		cp -f /usr/share/misc/config.guess config.guess
+endif
+	./configure --conf-path=/etc/nginx/nginx.conf \
+	--error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid \
+	--lock-path=/var/lock/nginx.lock   --http-log-path=/var/log/nginx/access.log \
+	--http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy \
+	--http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module \
+	--with-http_realip_module --with-http_ssl_module --with-mail --with-mail_ssl_module
+
+build: config.status
+	$(MAKE) build
+
+build-stamp:
+	dh_testdir
+#	$(MAKE)
+	touch $@
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp 
+	-$(MAKE) clean
+
+ifneq "$(wildcard /usr/share/misc/config.sub)" ""
+		rm -f config.sub
+endif
+ifneq "$(wildcard /usr/share/misc/config.guess)" ""
+		rm -f config.guess
+endif
+	dh_clean 
+
+install:
+	dh_testdir
+	dh_testroot
+	dh_clean -k 
+	dh_installdirs
+	dh_install
+
+# Build architecture-independent files here.
+binary-indep:
+
+# Build architecture-dependent files here.
+binary-arch: install
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs CHANGES
+	dh_installdocs
+	dh_installinit
+	dh_installman debian/nginx.1
+	dh_link
+	dh_strip
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+
+.PHONY: build clean binary-indep binary-arch binary install 
--- nginx-0.6.33.orig/debian/changelog
+++ nginx-0.6.33/debian/changelog
@@ -0,0 +1,39 @@
+nginx (0.6.33-2) unstable; urgency=low
+
+  * Fixed default installation paths for www/ files, avoiding the
+    default installation of index.html in /var/www (Closes: #400103)
+  * Alexey Besciokov <proforg@maloletka.ru> provided new postinst and prerm
+    scripts with the ability to reload the master binary (Closes: #398009)
+
+ -- Jose Parrella <joseparrella@cantv.net>  Fri, 24 Nov 2006 07:12:46 -0400
+
+nginx (0.6.33-1) unstable; urgency=low
+
+  * New upstream version
+  * Fixed default configuration file which made nginx to fail at
+    installation and purge.
+
+ -- Jose Parrella <joseparrella@cantv.net>  Thu, 16 Nov 2006 22:44:33 -0400
+
+nginx (0.4.12-1) unstable; urgency=low
+
+  * New upstream version (Closes: #397969)
+  * nginx will now compile with debugging and status support
+    (Closes: #397967)
+  * Added configuration reload support in the init.d script
+    (Closes: #397980)
+  * Added logrotate script (Closes: #397978)
+  * Added debian/upstream.pl as a brief helper for new
+    upstream version packaging.
+  * Thanks to Alexey Besciokov <proforg@maloletka.ru> for
+    suggestions, bug reports and patches.
+
+ -- Jose Parrella <joseparrella@cantv.net>  Sun, 12 Nov 2006 18:31:24 -0400
+
+nginx (0.4.2-1) unstable; urgency=low
+
+  * Initial release (Closes: #386151)
+  * Tweaked the configuration file and the path handling for Debian.
+
+ -- Jose Parrella <joseparrella@cantv.net>  Thu, 14 Sep 2006 11:40:20 -0400
+
--- nginx-0.6.33.orig/debian/docs
+++ nginx-0.6.33/debian/docs
@@ -0,0 +1 @@
+README
--- nginx-0.6.33.orig/debian/postinst
+++ nginx-0.6.33/debian/postinst
@@ -0,0 +1,62 @@
+#!/bin/sh
+# postinst script for nginx
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+#
+
+case "$1" in
+    configure)
+
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+if [ -x "/etc/init.d/nginx" ]; then
+	if [ -f /var/run/nginx.pid ]; then
+		/bin/kill -USR2 `cat /var/run/nginx.pid`
+		while [ ! -f /var/run/nginx.pid.oldbin ]
+		do
+			cnt=`expr $cnt + 1`
+			if [ $cnt -gt 10 ]
+			then
+				echo "Nginx 'soft' update failed, doing restart";
+				/bin/kill -9 `cat /var/run/nginx.pid`
+				invoke-rc.d nginx start
+				exit 0
+			fi
+			sleep 1
+		done
+		/bin/kill -QUIT `cat /var/run/nginx.pid.oldbin`
+#	else
+#		invoke-rc.d nginx start
+	fi
+fi
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
--- nginx-0.6.33.orig/debian/init.d
+++ nginx-0.6.33/debian/init.d
@@ -0,0 +1,62 @@
+#! /bin/sh
+
+### BEGIN INIT INFO
+# Provides:          nginx
+# Required-Start:    $all
+# Required-Stop:     $all
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: starts the nginx web server
+# Description:       starts nginx using start-stop-daemon
+### END INIT INFO
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/sbin/nginx
+NAME=nginx
+DESC=nginx
+
+test -x $DAEMON || exit 0
+
+# Include nginx defaults if available
+if [ -f /etc/default/nginx ] ; then
+	. /etc/default/nginx
+fi
+
+set -e
+
+case "$1" in
+  start)
+	echo -n "Starting $DESC: "
+	start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
+		--exec $DAEMON -- $DAEMON_OPTS
+	echo "$NAME."
+	;;
+  stop)
+	echo -n "Stopping $DESC: "
+	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
+		--exec $DAEMON
+	echo "$NAME."
+	;;
+  restart|force-reload)
+	echo -n "Restarting $DESC: "
+	start-stop-daemon --stop --quiet --pidfile \
+		/var/run/$NAME.pid --exec $DAEMON
+	sleep 1
+	start-stop-daemon --start --quiet --pidfile \
+		/var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
+	echo "$NAME."
+	;;
+  reload)
+      echo -n "Reloading $DESC configuration: "
+      start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
+          --exec $DAEMON
+      echo "$NAME."
+      ;;
+  *)
+	N=/etc/init.d/$NAME
+	echo "Usage: $N {start|stop|restart|force-reload}" >&2
+	exit 1
+	;;
+esac
+
+exit 0
--- nginx-0.6.33.orig/debian/upstream.pl
+++ nginx-0.6.33/debian/upstream.pl
@@ -0,0 +1,48 @@
+#!/usr/bin/perl
+
+# upstream.pl
+# creates a new upstream version of a Debian package
+#
+# Usage: perl upstream.pl <VERSION>
+# Please note that if you specify a version number that is the same of this debianized source tree, your
+# old orig.tar.gz will get overwritten!
+
+use strict;
+use warnings;
+
+my $newversion = $ARGV[0];
+
+my $pwd = `pwd`;
+my $basepwd = `basename $pwd`;
+
+# If you don't want to specify a version number, it will
+# increment by 0.1
+my $increment = 0.1;
+
+# Let's get the package name
+# and the version number
+my ($package, $version) = ($1, $2) if $basepwd =~ /([\w\d\_]+)-([\d\.]+)/;
+die "Seems like you're not standing in a Debianized source tree.\n" unless (defined ($package) && defined($version));
+
+# Let's create a new orig
+# working directory
+$newversion = $version + $increment unless (defined($newversion) && $newversion ne '');
+my $neworig = "${package}_" . $newversion;
+print "Creating new orig files for the new upstream version: $neworig\n";
+system ("mkdir $neworig.orig");
+
+# Let's copy all the upstream
+# files in there
+my @files = split("\n", `ls`);
+foreach my $file (@files) {
+	system("cp -R $file $neworig.orig/") unless ($file =~ /^debian$/ || $file =~ /^$neworig.orig$/);
+}
+
+# Now we'll compress the new
+# file and delete the temporary
+# directory
+system("tar czf ../$neworig.orig.tar.gz $neworig.orig/");
+system("rm -rf $neworig.orig/");
+
+print "Created a new orig file in ../$neworig.orig.tar.gz\n";
+print "Done! Now you should debian/rules binary again so the .diff.gz is recreated!\n";
Der Patch kann mit
patch -p0 <nginx_0.6.33-1.diff
angewandt werden.

Als nächstes muss für pre- und postinstall Skripte, sowie für die rules das executable Bit für einige Dateien gesetzt werden

cd nginx-0.6.33
chmod +x debian/{post*,pre*,rules}
Jetzt im Verzeichnis nginx-0.6.33 den Befehl absetzen
fakeroot dpkg-buildpackage
um das Debian Packet bauen zu lassen. Falls noch einige Abhängigkeiten unaufgelöst sind, einfach die Packete mit apt-get oder apitude nachinstallieren.