Skip to content

Instantly share code, notes, and snippets.

@davidfuhr
Last active December 18, 2015 17:59
Show Gist options
  • Save davidfuhr/5822473 to your computer and use it in GitHub Desktop.
Save davidfuhr/5822473 to your computer and use it in GitHub Desktop.
A php install script for debian using the http://cr.yp.to/slashpackage.html directory structure. To install php 5.3.23 run "php-install.sh 5.3.23"
#!/bin/bash
PHPVERSION=$1
if [[ ! $1 =~ ^5\.[234]\.[0-9]{1,2}$ ]]; then
echo $PHPVERSION is not a valid php version.
exit
fi
INSTALL_PACKAGES=""
for PACKAGE in build-essential bzip2 gcc libbz2-dev libcurl3-openssl-dev libcurl4-openssl-dev libgd2-xpm-dev libicu-dev libmcrypt-dev libmhash-dev libmysqlclient-dev libxml2-dev libxslt1-dev libxslt1-dev make wget; do
if [ ! "`dpkg -l|grep ii|grep $PACKAGE`" ]; then
INSTALL_PACKAGES="$INSTALL_PACKAGES $PACKAGE"
fi
done
if [ "$INSTALL_PACKAGES" ]; then
sudo aptitude -Ry install $INSTALL_PACKAGES
fi
mkdir -p $HOME/src
cd $HOME/src
if [ ! -f "php-$PHPVERSION.tar.bz2" ]; then
wget --spider http://de2.php.net/get/php-$PHPVERSION.tar.bz2/from/de3.php.net/mirror
if [ "$?" -eq "0" ]; then
wget -O php-$PHPVERSION.tar.bz2 http://de2.php.net/get/php-$PHPVERSION.tar.bz2/from/de3.php.net/mirror
else
wget -O php-$PHPVERSION.tar.bz2 http://museum.php.net/php5/php-$PHPVERSION.tar.bz2
fi
fi
if [ ! -d "php-$PHPVERSION" ]; then
tar xjf php-$PHPVERSION.tar.bz2
fi
cd php-$PHPVERSION
make clean
./configure --prefix=/package/host/localhost/php-$PHPVERSION \
--with-config-file-scan-dir=/package/host/localhost/php-$PHPVERSION/etc \
--enable-bcmath \
--enable-calendar \
--enable-ctype \
--enable-exif \
--enable-ftp \
--enable-intl \
--enable-mbstring \
--enable-soap \
--enable-sockets \
--enable-wddx \
--enable-zip \
--with-curl=shared \
--with-bz2=shared \
--with-gettext=shared \
--with-gd=shared \
--with-mcrypt=shared \
--with-mhash=shared \
--with-mysql=shared \
--with-openssl=shared \
--with-pdo-mysql=shared \
--with-xmlrpc=shared \
--with-xsl=shared \
--with-zlib=shared \
&& make \
&& sudo make install
if [ $? != 0 ]; then
echo 'BUILD FAILED'
exit 1
fi
sudo cp $HOME/src/php-$PHPVERSION/php.ini-development /package/host/localhost/php-$PHPVERSION/lib/php.ini
sudo sed -i 's!;include_path = ".:!include_path = ".:/package/host/localhost/php-'$PHPVERSION'/lib/php:!g' /package/host/localhost/php-$PHPVERSION/lib/php.ini
# add timezone UTC to php.ini
sudo sed -i 's!;date.timezone =!date.timezone = "UTC"!g' /package/host/localhost/php-$PHPVERSION/lib/php.ini
# install extensions
sudo /package/host/localhost/php-$PHPVERSION/bin/pecl install apc xdebug
for EXTENSION in apc curl gd intl mysql openssl pdo_mysql zlib; do
sudo sed -i 's!;extension=php_'$EXTENSION'.dll!extension='$EXTENSION'.so!g' /package/host/localhost/php-$PHPVERSION/lib/php.ini
done
# install pear packages
sudo /package/host/localhost/php-$PHPVERSION/bin/pear -c /package/host/localhost/php-$PHPVERSION/etc/pear.conf config-set auto_discover 1
sudo /package/host/localhost/php-$PHPVERSION/bin/pear -c /package/host/localhost/php-$PHPVERSION/etc/pear.conf install pear.phpqatools.org/phpqatools
# Install Symfony CodeSniffer standard
cd /package/host/localhost/php-$PHPVERSION/lib/php/PHP/CodeSniffer/Standards
sudo git clone git://github.com/opensky/Symfony2-coding-standard.git Symfony2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment