diff options
author | Mark Longair <mhl@pobox.com> | 2012-09-27 21:06:10 +0100 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2012-09-27 21:07:30 +0100 |
commit | faae328530ec403eb864a96cc1b0af734dc82f19 (patch) | |
tree | 9c2b763997c1d705a8f530e1cc6def301ee438f3 /conf | |
parent | 312c3b14fd1683973baca6dcf6b4f95e888064ab (diff) |
Switch install script to use nginx
This commit also reorganizes the files in conf/
Diffstat (limited to 'conf')
-rw-r--r-- | conf/apache-vhost.conf.example | 36 | ||||
-rw-r--r-- | conf/crontab.example | 28 | ||||
-rw-r--r-- | conf/httpd.conf-example | 38 | ||||
-rw-r--r-- | conf/nginx.conf.example | 49 | ||||
-rwxr-xr-x | conf/sysvinit-catalyst-fastcgi.example | 53 |
5 files changed, 169 insertions, 35 deletions
diff --git a/conf/apache-vhost.conf.example b/conf/apache-vhost.conf.example new file mode 100644 index 000000000..de53a5b6c --- /dev/null +++ b/conf/apache-vhost.conf.example @@ -0,0 +1,36 @@ +# An example Apache virtualhost configuration file. + +# Copyright (c) 2011 UK Citizens Online Democracy. All rights reserved. +# Email: team@mysociety.org +# WWW: http://www.mysociety.org + +<VirtualHost *:80> + ServerName fixmystreet.yourservername + DocumentRoot /home/yourname/fixmystreet/web/ + + # Pull in the specific config + Include /home/yourname/fixmystreet/conf/httpd.conf + + <Directory /home/yourname/fixmystreet/web> + # You also need to enable cgi files to run as CGI scripts. For example: + # on production servers these are run under fastcgi + Options +ExecCGI + AddHandler cgi-script .cgi + AllowOverride None + </Directory> + + <Location /admin> + # + # WARNING - enable auth here on production machine + # + </Location> + + Alias /admin/ /home/yourname/fixmystreet/web-admin/ + + Alias /jslib/ /home/yourname/fixmystreet/commonlib/jslib/ + <Location /jslib> + AddOutputFilter DEFLATE js + Header append Cache-Control "no-transform" + </Location> + +</VirtualHost> diff --git a/conf/crontab.example b/conf/crontab.example new file mode 100644 index 000000000..f33e949e8 --- /dev/null +++ b/conf/crontab.example @@ -0,0 +1,28 @@ +# Timed tasks for FixMyStreet. + +# This is an example crontab that you may want to use as a basis for +# one on your own server. You should replace $FMS with the path to the +# clone of the FixMyStreet repository that you are using. You should +# also replace $LOCK_DIR with a writeable directory for the lock files. + +# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. +# Email: matthew@mysociety.org. WWW: http://www.mysociety.org/ + +PATH=/usr/local/bin:/usr/bin:/bin + +5,10,15,20,25,30,35,40,45,50,55 * * * * "$FMS/commonlib/bin/run-with-lockfile.sh" -n "$FMS/send-reports.lock" "$FMS/bin/cron-wrapper send-reports" || echo "stalled?" +0 0-8,10,11,13,14,16,17,19-23 * * * "$FMS/commonlib/bin/run-with-lockfile.sh" -n "$LOCK_DIR/send-reports.lock" "$FMS/bin/cron-wrapper send-reports" || echo "stalled?" +0 9,12,15,18 * * * "$FMS/commonlib/bin/run-with-lockfile.sh" -n "$LOCK_DIR/send-reports.lock" "$FMS/bin/cron-wrapper send-reports --verbose" || echo "stalled?" +2 * * * * "$FMS/commonlib/bin/run-with-lockfile.sh" -n "$LOCK_DIR/send-alerts.lock" "$FMS/bin/cron-wrapper send-alerts" || echo "stalled?" +0,30 * * * * "$FMS/commonlib/bin/run-with-lockfile.sh" -n "$LOCK_DIR/send-questionnaires.lock" "$FMS/bin/cron-wrapper send-questionnaires" || echo "stalled?" +5,10,15,20,25,30,35,40,45,50,55 * * * * "$FMS/commonlib/bin/run-with-lockfile.sh" -n "$LOCK_DIR/send-comments.lock" "$FMS/bin/cron-wrapper send-comments" || echo "stalled?" +5,10,15,20,25,30,35,40,45,50,55 * * * * "$FMS/commonlib/bin/run-with-lockfile.sh" -n "$LOCK_DIR/fetch-comments.lock" "$FMS/bin/cron-wrapper fetch-comments" || echo "stalled?" +0,30 * * * * "$FMS/commonlib/bin/run-with-lockfile.sh" -n "$LOCK_DIR/open311-populate-service-list.lock" "$FMS/bin/cron-wrapper open311-populate-service-list" || echo "stalled?" + +# Once an hour, update the all reports stats +13 * * * * "$FMS/bin/cron-wrapper" update-all-reports + +# Once a day on all servers +39 2 * * * "$FMS/bin/problems-filed-graph" +43 2 * * * "$FMS/bin/problem-creation-graph" +00 8 * * * "$FMS/bin/check-for-zombies" $UNIX_USER diff --git a/conf/httpd.conf-example b/conf/httpd.conf-example index 2cced0537..5d0fead38 100644 --- a/conf/httpd.conf-example +++ b/conf/httpd.conf-example @@ -1,41 +1,9 @@ # Apache configuration for FixMyStreet. # -# Add lines something like this to your /etc/apache2/sites-enabled/fixmystreet - -# replacing '/home/yourname/fixmystreet' with the path to your install +# This file should be included in an Apache <VirtualHost> section. An +# example of such a virtualhost configuration file can be found in the +# file apache-vhost.conf.example in this directory. # -# # FixMyStreet -# <VirtualHost *:80> -# ServerName fixmystreet.yourservername -# DocumentRoot /home/yourname/fixmystreet/web/ -# -# # Pull in the specific config -# Include /home/yourname/fixmystreet/conf/httpd.conf -# -# <Directory /home/yourname/fixmystreet/web> -# # You also need to enable cgi files to run as CGI scripts. For example: -# # on production servers these are run under fastcgi -# Options +ExecCGI -# AddHandler cgi-script .cgi -# AllowOverride None -# </Directory> -# -# <Location /admin> -# # -# # WARNING - enable auth here on production machine -# # -# </Location> -# -# Alias /admin/ /home/yourname/fixmystreet/web-admin/ -# -# Alias /jslib/ /home/yourname/fixmystreet/commonlib/jslib/ -# <Location /jslib> -# AddOutputFilter DEFLATE js -# Header append Cache-Control "no-transform" -# </Location> -# -# </VirtualHost> -# -# # Copyright (c) 2011 UK Citizens Online Democracy. All rights reserved. # Email: team@mysociety.org # WWW: http://www.mysociety.org diff --git a/conf/nginx.conf.example b/conf/nginx.conf.example new file mode 100644 index 000000000..253024ca6 --- /dev/null +++ b/conf/nginx.conf.example @@ -0,0 +1,49 @@ +# An example configuration for running FixMyStreet under nginx. You +# will also need to set up the FixMyStreet Catalyst FastCGI backend. +# An example sysvinit script to help with this is shown given in the file +# sysvinit-catalyst-fastcgi.example in this directory. + +# Copyright (c) 2011 UK Citizens Online Democracy. All rights reserved. +# Email: team@mysociety.org +# WWW: http://www.mysociety.org + +server { + + access_log /var/www/fixmystreet/logs/access.log; + error_log /var/www/fixmystreet/logs/error.log; + + listen 80; + root /var/www/fixmystreet/fixmystreet/web; + error_page 503 /down.html; + + # These rewrite rules are ported from the Apache configuration in + # conf/httpd.conf + + rewrite ^/rss/council/([0-9]+)$ /rss/reports/$1 permanent; + rewrite ^/report$ /reports permanent; + rewrite '^/{/rss/(.*)}$' /rss/$1 permanent; + rewrite '^/reports/{/rss/(.*)}$' /rss/$1 permanent; + rewrite ^/alerts/?$ /alert permanent; + + location /mapit { + proxy_pass http://mapit.mysociety.org/; + proxy_set_header X-Real-IP $remote_addr; + } + + location / { + if (-f $document_root/down.html) { + return 503; + } + try_files $uri @catalyst; + } + location /down.html { + internal; + } + + location @catalyst { + include /etc/nginx/fastcgi_params; + fastcgi_param PATH_INFO $fastcgi_script_name; + fastcgi_param SCRIPT_NAME ''; + fastcgi_pass 127.0.0.1:9000; + } +} diff --git a/conf/sysvinit-catalyst-fastcgi.example b/conf/sysvinit-catalyst-fastcgi.example new file mode 100755 index 000000000..d8e165a2b --- /dev/null +++ b/conf/sysvinit-catalyst-fastcgi.example @@ -0,0 +1,53 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: application-catalyst-fixmystreet +# Required-Start: $local_fs $network +# Required-Stop: $local_fs $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Starts the FastCGI app server for the "FixMyStreet" site +# Description: The FastCGI application server for the "FixMyStreet" site +### END INIT INFO + +# This example sysvinit script is based on the helpful example here: +# http://richard.wallman.org.uk/2010/02/howto-deploy-a-catalyst-application-using-fastcgi-and-nginx/ + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +SITE_HOME=/var/www/fixmystreet +NAME=fms-catalyst-fastcgi +DESC="FixMyStreet app server" +USER=fms + +echo $DAEMON +test -f $DAEMON || exit 0 + +set -e + +start_daemon() { + su -l -c "$SITE_HOME/fixmystreet/bin/cron-wrapper $SITE_HOME/fixmystreet/web/fixmystreet_app_fastcgi.cgi -d -l :9000 -n 2" $USER +} + +stop_daemon() { + pkill -f perl-fcgi -u $USER || true +} + +case "$1" in + start) + start_daemon + ;; + stop) + stop_daemon + ;; + reload|restart|force-reload) + stop_daemon + sleep 5 + start_daemon + ;; + *) + N=/etc/init.d/$NAME + echo "Usage: $N {start|stop|reload|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 |