Index: nginx-common.postrm
===================================================================
--- nginx-common.postrm	(revision 0)
+++ nginx-common.postrm	(revision 0)
@@ -0,0 +1,28 @@
+#!/bin/sh
+set -e
+
+# systemd: reload the daemon
+if [ -x /bin/systemctl ]; then
+  /bin/systemctl daemon-reload >/dev/null 2>&1 || true
+fi
+
+case "$1" in
+  upgrade)
+    # systemd: start the new version of nginx
+    if [ -x /bin/systemctl ]; then
+      /bin/systemctl restart nginx.service
+    fi
+    ;;
+
+  purge|remove|failed-upgrade|abort-install|abort-upgrade|disappear)
+    ;;
+
+  *)
+    echo "postrm called with unknown argument \`$1'" >&2
+    exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
Index: rules
===================================================================
--- rules	(revision 19876)
+++ rules	(working copy)
@@ -211,6 +211,8 @@
 	dh_installexamples -i
 	dh_installinit -r --no-start -i --init-script=nginx
 	cp debian/logrotate debian/nginx-common/etc/logrotate.d/nginx
+	mkdir -p debian/nginx-common/lib/systemd/system
+	cp debian/nginx-common.service debian/nginx-common/lib/systemd/system/nginx.service
 	dh_link -i
 	dh_compress -i
 	dh_fixperms -i
Index: nginx-common.postinst
===================================================================
--- nginx-common.postinst	(revision 19876)
+++ nginx-common.postinst	(working copy)
@@ -10,6 +10,11 @@
       chown www-data:adm $logdir
       chmod 0750 $logdir
     fi
+    # For systemd, enable the nginx unit, but don't start it (just like the
+    # init script).
+    if [ -x /bin/systemctl ]; then
+      /bin/systemctl enable nginx.service >/dev/null 2>&1 || true
+    fi
     ;;
 
   abort-upgrade|abort-remove|abort-deconfigure)
Index: nginx-common.prerm
===================================================================
--- nginx-common.prerm	(revision 0)
+++ nginx-common.prerm	(revision 0)
@@ -0,0 +1,24 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+  remove|upgrade|deconfigure)
+    # systemd: On uninstall (not upgrade), disable and stop the unit
+    if [ -x /bin/systemctl ]; then
+      /bin/systemctl --no-reload disable nginx.service >/dev/null 2>&1 || true
+      /bin/systemctl stop nginx.service >/dev/null 2>&1 || true
+    fi
+    ;;
+
+  failed-upgrade)
+    ;;
+
+  *)
+    echo "prerm called with unknown argument \`$1'" >&2
+    exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
Index: nginx-common.service
===================================================================
--- nginx-common.service	(revision 0)
+++ nginx-common.service	(revision 0)
@@ -0,0 +1,14 @@
+[Unit]
+Description=A high performance web server and a reverse proxy server
+After=network.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/nginx.pid
+ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;'
+ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;'
+ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload
+ExecStop=/usr/sbin/nginx -s quit
+
+[Install]
+WantedBy=multi-user.target
