php-build.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/bash
  2. VERSION=$1
  3. RESET=$2
  4. POSTFIX=
  5. EXTRA_FLAGS=
  6. if [ -z "$VERSION" ]; then
  7. echo "Usage: php-build.sh {VERSION}"
  8. echo ""
  9. echo "e.g. php-build.sh 5.2.11"
  10. exit;
  11. fi
  12. if [ -z "$RESET" ]; then
  13. RESET=0
  14. fi
  15. SRC_DIR=/home/vagrant/src
  16. PHP_DIR=${SRC_DIR}/php-${VERSION}
  17. if [ ! -d "$SRC_DIR" ]; then
  18. mkdir ${SRC_DIR}
  19. fi
  20. cd $SRC_DIR
  21. # If we don't have the src file downloaded, then we're going to need it.
  22. if [ ! -f "php-${VERSION}.tar.gz" ]; then
  23. RESET=1
  24. fi;
  25. # Retrieve source code
  26. if [ $RESET -eq 1 ] ; then
  27. echo "Downloading php-${VERSION}.tar.gz"
  28. RESPONSE=$(curl --write-out %{http_code} --silent --head --output /dev/null http://museum.php.net/php5/php-${VERSION}.tar.gz)
  29. echo $RESPONSE
  30. if [ $RESPONSE -eq 404 ]; then
  31. wget -O php-${VERSION}.tar.gz http://uk3.php.net/get/php-${VERSION}.tar.gz/from/this/mirror
  32. else
  33. wget http://museum.php.net/php5/php-${VERSION}.tar.gz
  34. fi
  35. if [ ! -f php-${VERSION}.tar.gz ];
  36. then
  37. echo "Could not find php-${VERSION}.tar.gz"
  38. exit;
  39. fi
  40. rm -rf ${PHP_DIR}
  41. tar -zxf php-${VERSION}.tar.gz
  42. fi
  43. cd $PHP_DIR
  44. echo "Configuring ${VERSION}${POSTFIX} in $PHP_DIR"
  45. # Configure
  46. OPTIONS="--with-gd --with-jpeg-dir=/usr --with-xpm-dir=/usr --with-freetype-dir=/usr \
  47. --with-mysql=/usr --enable-bcmath --with-gmp --with-readline \
  48. --with-openssl --with-curl --without-esmtp \
  49. --with-mysqli --enable-pcntl \
  50. --enable-memory-limit --with-mcrypt --with-t1lib \
  51. --enable-debug --with-iconv --enable-wddx --with-pdo-pgsql \
  52. --enable-spl --enable-pdo --with-pdo-mysql --with-pdo-sqlite \
  53. --with-ctype --with-bz2 --enable-mbstring --with-mime-magic \
  54. --with-xmlrpc --with-zlib --disable-zend-memory-manager --with-esmtp \
  55. --with-xsl --enable-exif --enable-soap --enable-ftp"
  56. ./configure --prefix=/usr/local/php/${VERSION}${POSTFIX} ${EXTRA_FLAGS} ${OPTIONS}
  57. # Build and install
  58. echo "Building ${VERSION}${POSTFIX} in $PHP_DIR"
  59. make -j 5
  60. echo "Installing ${VERSION}${POSTFIX} in $PHP_DIR"
  61. sudo make install
  62. echo "Linking PHPUnit library"
  63. sudo ln -s /usr/share/php/PHPUnit /usr/local/php/${VERSION}${POSTFIX}/lib/php/PHPUnit
  64. echo ""
  65. echo "PHP version ${VERSION} is now installed. Type: pe ${VERSION}"
  66. echo ""