Skip to content

Instantly share code, notes, and snippets.

@georgejipa
Created December 4, 2015 11:39
Show Gist options
  • Save georgejipa/91f5ddc40c5d53cb6cc6 to your computer and use it in GitHub Desktop.
Save georgejipa/91f5ddc40c5d53cb6cc6 to your computer and use it in GitHub Desktop.
PHP 7.0.0 (release) on Debian 8
#!/bin/bash
set -e
PHP_VERSION=7.0.0
# Dependencies
apt-get update
apt-get install -y \
bison \
g++ \
autoconf \
libxml2-dev \
libbz2-dev \
libcurl4-openssl-dev \
libltdl-dev \
libpng12-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
libxpm-dev \
libimlib2-dev \
libicu-dev \
libreadline6-dev \
libmcrypt-dev \
libxslt1-dev
rm -rf /etc/php7
rm -rf /usr/local/php-${PHP_VERSION}
mkdir -p /etc/php7/conf.d
mkdir -p /etc/php7/{cli,fpm}/conf.d
mkdir /usr/local/php-${PHP_VERSION}
# Download
rm -rf php-src
git clone http://github.com/php/php-src.git
cd php-src
git checkout -b php-${PHP_VERSION} php-${PHP_VERSION}
./buildconf --force
# Tested and works with LibreSSL 2.2.4
# Just point --with-openssl=<your_dir>/libressl-2.2.4/.openssl to your installation
CONFIGURE_STRING="--prefix=/usr/local/php-${PHP_VERSION} \
--enable-bcmath \
--with-bz2 \
--with-zlib \
--enable-zip \
--enable-calendar \
--enable-exif \
--enable-ftp \
--with-gettext \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-xpm-dir \
--enable-mbstring \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--enable-intl \
--enable-soap \
--with-readline \
--with-curl \
--with-mcrypt \
--with-xsl \
--disable-cgi"
# Build FPM
./configure \
$CONFIGURE_STRING \
--with-config-file-path=/etc/php7/fpm \
--with-config-file-scan-dir=/etc/php7/fpm/conf.d \
--disable-cli \
--enable-fpm \
--with-fpm-user=www-data \
--with-fpm-group=www-data
make -j2
make install
# Install FPM config files
cp php.ini-production /etc/php7/fpm/php.ini
sed -i 's/;date.timezone =.*/date.timezone = Europe\/Brussels/' /etc/php7/fpm/php.ini
cp sapi/fpm/php-fpm.conf.in /etc/php7/fpm/php-fpm.conf
sed -i 's#^include=.*/#include=/etc/php7/fpm/pool.d/#' /etc/php7/fpm/php-fpm.conf
mkdir /etc/php7/fpm/pool.d/
cp /usr/local/php-${PHP_VERSION}/etc/php-fpm.d/www.conf.default /etc/php7/fpm/pool.d/www.conf
sed -i 's/listen = 127.0.0.1:9000/listen = 127.0.0.1:9070/g' /etc/php7/fpm/pool.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm
chmod +x /etc/init.d/php7-fpm
sed -i 's/Provides: php-fpm/Provides: php7-fpm/' /etc/init.d/php7-fpm
sed -i 's#^php_fpm_CONF=.*#php_fpm_CONF=/etc/php7/fpm/php-fpm.conf#' /etc/init.d/php7-fpm
sed -i 's#^php_fpm_PID=.*#php_fpm_PID=/var/run/php7-fpm.pid#' /etc/init.d/php7-fpm
update-rc.d php7-fpm defaults
# Cleanup between SAPI builds
make distclean
./buildconf --force
# Build CLI
./configure \
$CONFIGURE_STRING \
--enable-pcntl \
--with-config-file-path=/etc/php7/cli \
--with-config-file-scan-dir=/etc/php7/cli/conf.d
make -j2
make install
# Install CLI config files
cp php.ini-production /etc/php7/cli/php.ini
sed -i 's/;date.timezone =.*/date.timezone = Europe\/Brussels/' /etc/php7/cli/php.ini
# Build extensions
cd ..
PATH=/usr/local/php-${PHP_VERSION}/bin:/usr/local/php-${PHP_VERSION}/sbin/$PATH
# opcache
echo "zend_extension=opcache.so" > /etc/php7/conf.d/opcache.ini
ln -s /etc/php7/conf.d/opcache.ini /etc/php7/cli/conf.d/opcache.ini
ln -s /etc/php7/conf.d/opcache.ini /etc/php7/fpm/conf.d/opcache.ini
# Ready
echo "Don't forget to run 'make test'."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment