summaryrefslogtreecommitdiff
path: root/www/wiki/maintenance/dev/installphp.sh
blob: 1e3d410f148ca0064c75167af155d74b9e627a39 (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
#!/bin/bash

if [ "x$BASH_SOURCE" == "x" ]; then echo '$BASH_SOURCE not set'; exit 1; fi
DEV=$(cd -P "$(dirname "${BASH_SOURCE[0]}" )" && pwd)

set -e # DO NOT USE PIPES unless this is rewritten

. "$DEV/includes/php.sh"

if [ "x$PHP" != "x" -a -x "$PHP" ]; then
	echo "PHP is already installed"
	exit 0
fi

VER=5.6.32
TAR="php-$VER.tar.gz"
PHPURL="https://secure.php.net/get/$TAR/from/this/mirror"

cd "$DEV"

echo "Preparing to download and install a local copy of PHP $VER, note that this can take some time to do."
echo "If you wish to avoid re-doing this for future dev installations of MediaWiki we suggest installing php in ~/.mediawiki/php"
echo -n "Install PHP in ~/.mediawiki/php [y/N]: "
read INSTALLINHOME

case "$INSTALLINHOME" in
	[Yy] | [Yy][Ee][Ss] )
		PREFIX="$HOME/.mediawiki/php"
		;;
	*)
		PREFIX="$DEV/php/"
		;;
esac

# Some debian-like systems bundle wget but not curl, some other systems
# like os x bundle curl but not wget... use whatever is available
echo -n "Downloading PHP $VER"
if command -v wget &>/dev/null; then
	echo " - using wget"
	wget -O "$TAR" "$PHPURL"
elif command -v curl &>/dev/null; then
	echo " - using curl"
	curl "$PHPURL" -L -o "$TAR"
else
	echo " - aborting"
	echo "Could not find curl or wget." >&2;
	exit 1;
fi

echo "Extracting php $VER"
tar -xzf "$TAR"

cd "php-$VER/"

echo "Configuring and installing php $VER in $PREFIX"
./configure --prefix="$PREFIX"
make
make install