aboutsummaryrefslogtreecommitdiffstats
path: root/travis/setup-webserver.sh
blob: a6086bb9f94ecd64847ad0c13d31db3cea49e05f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
#
# @copyright (c) 2014 phpBB Group
# @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
#
set -e
set -x

if [ "$TRAVIS_PHP_VERSION" = 'hhvm' ]
then
	# Add PPA providing dependencies for recent HHVM on Ubuntu 12.04.
	sudo add-apt-repository -y ppa:mapnik/boost
fi

sudo apt-get update
sudo apt-get install -y nginx realpath

sudo service nginx stop

DIR=$(dirname "$0")
USER=$(whoami)
PHPBB_ROOT_PATH=$(realpath "$DIR/../phpBB")
NGINX_CONF="/etc/nginx/sites-enabled/default"
APP_SOCK=$(realpath "$DIR")/php-app.sock

if [ "$TRAVIS_PHP_VERSION" = 'hhvm' ]
then
	# Upgrade to a recent stable version of HHVM
	sudo apt-get -o Dpkg::Options::="--force-confnew" install -y hhvm-nightly

	HHVM_LOG=$(realpath "$DIR")/hhvm.log

	sudo hhvm \
		--mode daemon \
		--user "$USER" \
		-vServer.Type=fastcgi \
		-vServer.FileSocket="$APP_SOCK" \
		-vLog.File="$HHVM_LOG"
else
	# php-fpm
	PHP_FPM_BIN="$HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/sbin/php-fpm"
	PHP_FPM_CONF="$DIR/php-fpm.conf"

	echo "
		[global]

		[travis]
		user = $USER
		group = $USER
		listen = $APP_SOCK
		listen.mode = 0666
		pm = static
		pm.max_children = 2

		php_admin_value[memory_limit] = 128M
	" > $PHP_FPM_CONF

	sudo $PHP_FPM_BIN \
		--fpm-config "$DIR/php-fpm.conf"
fi

# nginx
echo "
	server {
		listen	80;
		root	$PHPBB_ROOT_PATH/;
		index	index.php index.html;

		location ~ \.php {
			fastcgi_pass	unix:$APP_SOCK;
			include			fastcgi_params;
		}
	}
" | sudo tee $NGINX_CONF > /dev/null

sudo service nginx start