Skip to content

Instantly share code, notes, and snippets.

@aidantwoods
Last active November 15, 2017 13:12
Show Gist options
  • Save aidantwoods/bb26af07588c7fa6c68be237a1caf22c to your computer and use it in GitHub Desktop.
Save aidantwoods/bb26af07588c7fa6c68be237a1caf22c to your computer and use it in GitHub Desktop.
Pull dependencies and configure a sane install of the latest (at time of writing) version of PHP (you'll need to update the version number if you want a newer one) on Kali (and probably other Debian too). This is mainly for my own use, I make no commitment to maintain this – but it should be a good starting point anyway
export MAJOR='7'
export MINOR='1'
export PATCH='11'
export MAJMIN=$MAJOR.$MINOR
export VERSION=$MAJMIN.$PATCH
sudo apt-get update
if ! (sudo apt-get install dirmngr); then
echo 'Could not get GPG dependency'
exit 1
fi
# check these are correct for each minor release
if ! (gpg --recv-keys 7BD5DCD0 31CBD89E); then
echo "Could not retrieve PHP's GPG signing keys"
exit 1
fi
if ! (wget https://php.net/get/php-$VERSION.tar.bz2/from/this/mirror -O php-$VERSION.tar.bz2 && wget https://php.net/get/php-$VERSION.tar.bz2.asc/from/this/mirror -O php-$VERSION.tar.bz2.asc); then
echo 'Could not download PHP'
exit 1
fi
if ! (gpg --verify php-$VERSION.tar.bz2.asc php-$VERSION.tar.bz2); then
echo 'Warning: could not verify signature of PHP'
exit 1
fi
tar xjvf php-$VERSION.tar.bz2
cd php-$VERSION/
if ! (sudo apt-get install libxml2-dev libssl-dev pkg-config zlib1g-dev libcurl4-openssl-dev libwebp-dev libjpeg-dev libpng-dev libreadline-dev libxslt-dev); then
echo 'Could not get PHP dependencies'
exit 1
fi
if ! (sudo ln -s /usr/include/x86_64-linux-gnu/curl/ /usr/include/curl); then # see https://bugs.php.net/bug.php?id=74125
echo 'Could not symlink curllib'
exit 1
fi
if ! (./configure --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc/php/$MAJMIN --with-config-file-path=/usr/local/etc/php/$MAJMIN --with-config-file-scan-dir=/usr/local/etc/php/$MAJMIN/conf.d --enable-bcmath --enable-calendar --enable-exif --enable-ftp --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --enable-zip --with-gd --with-gettext --with-iconv --with-kerberos=/usr --with-mhash --with-xmlrpc --with-readline --without-gmp --without-snmp --with-openssl --enable-fpm --with-fpm-user=_www --with-fpm-group=_www --with-curl --with-xsl=/usr --with-mysql-sock=/tmp/mysql.sock --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --disable-opcache --enable-pcntl --without-pear --disable-phpdbg --enable-zend-signals --with-zlib); then
echo 'Could not configure PHP'
exit 1
fi
echo "Configure success! Now cd php-$VERSION, make, make test, and sudo make install"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment