installphp.sh 1.3 KB

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