/www/imfreedom: 37d695209494: Add a sandbox script for running a...

Mark Doliner mark at kingant.net
Thu Apr 18 02:08:26 EDT 2013


Changeset: 37d695209494ecd4e8e1dca70281f72869b41258
Author:	 Mark Doliner <mark at kingant.net>
Date:	 2013-04-17 20:39 -0700
Branch:	 default
URL: https://hg.pidgin.im/www/imfreedom/rev/37d695209494

Description:

Add a sandbox script for running a local nginx web server for testing
changes.  Instructions for using this are at the top of sandbox/run.
The script currently expects to connect to a php fastcgi process
at unix socket /var/run/php5-fpm.sock.

Things that would be nice:
- Better instructions in the run file
- If we started php ourselves so that we were less dependent
  on the host system's environment

diffstat:

 .hgignore          |   4 ++++
 sandbox/nginx.conf |  38 ++++++++++++++++++++++++++++++++++++++
 sandbox/run        |  27 +++++++++++++++++++++++++++
 3 files changed, 69 insertions(+), 0 deletions(-)

diffs (84 lines):

diff --git a/.hgignore b/.hgignore
new file mode 100644
--- /dev/null
+++ b/.hgignore
@@ -0,0 +1,4 @@
+sandbox/access.log
+sandbox/error.log
+sandbox/nginx_docroot.conf
+sandbox/pid
diff --git a/sandbox/nginx.conf b/sandbox/nginx.conf
new file mode 100644
--- /dev/null
+++ b/sandbox/nginx.conf
@@ -0,0 +1,38 @@
+daemon off;
+error_log error.log;
+pid pid;
+
+events {
+	worker_connections 100;
+}
+
+http {
+	include /etc/nginx/mime.types;
+	default_type application/octet-stream;
+
+	access_log access.log;
+
+	client_body_temp_path /tmp;
+	proxy_temp_path /tmp;
+	fastcgi_temp_path /tmp;
+
+	server {
+		listen 8080;
+
+		# I couldn't find a way to use a relative document root here and
+		# have it work with php.  Instead, the "run" script writes the
+		# absolute doc root to a conf file and we include it here.  If you
+		# can find a way to make the doc root relative, please get rid of
+		# this, because it's a little ugly.  --Mark Doliner, 2012-04-28
+		include nginx_docroot.conf;
+
+		# Enable php
+		index index.php index.html;
+		location ~ \.php$ {
+			# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini?
+			include /etc/nginx/fastcgi_params;
+			fastcgi_intercept_errors on;
+			fastcgi_pass unix:/var/run/php5-fpm.sock;
+		}
+	}
+}
diff --git a/sandbox/run b/sandbox/run
new file mode 100755
--- /dev/null
+++ b/sandbox/run
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+#
+# This script runs a local web server sandbox that serves the Pidgin web
+# site, so you can test your changes before committing them.
+#
+# The current version of this script uses nginx.  pidgin.im is actually
+# served using lighttpd... but that shouldn't matter.
+#
+
+# Directions for using this on Ubuntu:
+# Note: These directions aren't very good.  Feel free to correct/improve.
+#   apt-get install nginx-light php5-common php5-fpm
+#   TODO: disable nginx from starting at boot
+#      /sbin/chkconfig nginx off?
+#      insserv --remove nginx
+#   /etc/init.d/nginx stop
+#   /etc/init.d/php5-fpm start?
+#   TODO: Configure php5-fpm to start at boot?
+
+MYDIR="$( cd "$( dirname "$0" )" && pwd )"
+
+# Write the absolute path of the document root to a file.  See the note
+# about this file in nginx.conf for more information.
+echo "root "`readlink -f $MYDIR/../`";" > $MYDIR/nginx_docroot.conf
+
+/usr/sbin/nginx -c $MYDIR/nginx.conf -p $MYDIR/



More information about the Commits mailing list