Merge "Rewrite pref cleanup script"
[lhc/web/wiklou.git] / maintenance / dev / installphp.sh
1 #!/bin/bash
2
3 if [ "x$BASH_SOURCE" == "x" ]; then echo '$BASH_SOURCE not set'; exit 1; fi
4 DEV=$(cd -P "$(dirname "${BASH_SOURCE[0]}" )" && pwd)
5
6 set -e # DO NOT USE PIPES unless this is rewritten
7
8 . "$DEV/includes/php.sh"
9
10 if [ "x$PHP" != "x" -a -x "$PHP" ]; then
11 echo "PHP is already installed"
12 exit 0
13 fi
14
15 VER=5.6.32
16 TAR="php-$VER.tar.gz"
17 PHPURL="https://secure.php.net/get/$TAR/from/this/mirror"
18
19 cd "$DEV"
20
21 echo "Preparing to download and install a local copy of PHP $VER, note that this can take some time to do."
22 echo "If you wish to avoid re-doing this for future dev installations of MediaWiki we suggest installing php in ~/.mediawiki/php"
23 echo -n "Install PHP in ~/.mediawiki/php [y/N]: "
24 read INSTALLINHOME
25
26 case "$INSTALLINHOME" in
27 [Yy] | [Yy][Ee][Ss] )
28 PREFIX="$HOME/.mediawiki/php"
29 ;;
30 *)
31 PREFIX="$DEV/php/"
32 ;;
33 esac
34
35 # Some debian-like systems bundle wget but not curl, some other systems
36 # like os x bundle curl but not wget... use whatever is available
37 echo -n "Downloading PHP $VER"
38 if command -v wget &>/dev/null; then
39 echo " - using wget"
40 wget -O "$TAR" "$PHPURL"
41 elif command -v curl &>/dev/null; then
42 echo " - using curl"
43 curl "$PHPURL" -L -o "$TAR"
44 else
45 echo " - aborting"
46 echo "Could not find curl or wget." >&2;
47 exit 1;
48 fi
49
50 echo "Extracting php $VER"
51 tar -xzf "$TAR"
52
53 cd "php-$VER/"
54
55 echo "Configuring and installing php $VER in $PREFIX"
56 ./configure --prefix="$PREFIX"
57 make
58 make install