merge latest master into Wikidata branch
[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 TAR=php5.4-latest.tar.gz
16 PHPURL="http://snaps.php.net/$TAR"
17
18 cd "$DEV"
19
20 echo "Preparing to download and install a local copy of PHP 5.4, note that this can take some time to do."
21 echo "If you wish to avoid re-doing this for uture dev installations of MediaWiki we suggest installing php in ~/.mediawiki/php"
22 echo -n "Install PHP in ~/.mediawiki/php [y/N]: "
23 read INSTALLINHOME
24
25 case "$INSTALLINHOME" in
26 [Yy] | [Yy][Ee][Ss] )
27 PREFIX="$HOME/.mediawiki/php"
28 ;;
29 *)
30 PREFIX="$DEV/php/"
31 ;;
32 esac
33
34 # Some debain-like systems bundle wget but not curl, some other systems
35 # like os x bundle curl but not wget... use whatever is available
36 echo -n "Downloading PHP 5.4"
37 if command -v wget &>/dev/null; then
38 echo "- using wget"
39 wget "$PHPURL"
40 elif command -v curl &>/dev/null; then
41 echo "- using curl"
42 curl -O "$PHPURL"
43 else
44 echo "- aborting"
45 echo "Could not find curl or wget." >&2;
46 exit 1;
47 fi
48
49 echo "Extracting php 5.4"
50 tar -xzf "$TAR"
51
52 cd php5.4-*/
53
54 echo "Configuring and installing php 5.4 in $PREFIX"
55 ./configure --prefix="$PREFIX"
56 make
57 make install