Instantly share code, notes, and snippets.

What would you like to do?
Ubuntu 14.04 PHP7 (Install from Source)
#!/usr/bin/env bash
sudo -i;
apt-get update;
apt-get install --yes \
git \
bison \
autoconf \
libltdl-dev \
libbz2-dev \
libxml2-dev \
libxslt1-dev \
libpspell-dev \
libenchant-dev \
libmcrypt-dev \
libpng-dev \
libjpeg8-dev \
libfreetype6-dev \
libmysqlclient-dev \
mkdir --parents /usr/local/php7;
mkdir --parents /etc/php7/conf.d;
mkdir --parents /etc/php7/cli/conf.d;
mkdir --parents /etc/php7/fpm/conf.d;
mkdir --parents --mode=777 /var/log/php7;
git clone /usr/local/src/php7 --branch=php-7.0.0RC2 --depth=1;
cd /usr/local/src/php7;
./buildconf --force;
php_configure_args=" \
--prefix=/usr/local/php7 \
--with-bz2 \
--with-zlib \
--enable-zip \
--with-mcrypt \
--with-openssl \
--with-curl \
--enable-ftp \
--with-mysqli \
--enable-sockets \
--enable-pcntl \
--with-pspell \
--with-enchant \
--with-gettext \
--with-gd \
--enable-exif \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-xsl \
--enable-bcmath \
--enable-mbstring \
--enable-calendar \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
./configure $php_configure_args \
--with-config-file-path=/etc/php7/cli \
make && make install && make clean;
./configure $php_configure_args \
--disable-cli --enable-fpm \
--with-fpm-user=www-data \
--with-fpm-group=www-data \
--with-config-file-path=/etc/php7/fpm \
make && make install && make clean;
ln --symbolic /usr/local/php7/bin/php /usr/bin/php;
ln --symbolic /usr/local/php7/sbin/php-fpm /usr/sbin/php-fpm;
echo '' > /etc/php/conf.d/opcache.ini;
ln --symbolic /etc/php/conf.d/opcache.ini /etc/php/cli/conf.d/opcache.ini;
ln --symbolic /etc/php/conf.d/opcache.ini /etc/php/fpm/conf.d/opcache.ini;

This comment has been minimized.

Geekbell commented Dec 5, 2015

This worked better than others that I've tried. The only issues I've had is libssl-dev had to be installed. php -v gives me the correct version but the php files are not compiled when viewing a web page. I get raw text.
Also the symbolic links didn't work. the php path is php7 or am I misunderstanding something?


This comment has been minimized.

enoch85 commented Dec 7, 2015

@jaswsinc Shouldn't you update this script as it's not RC2 anymore, PHP7 Stable is released.


This comment has been minimized.

kamilsj commented Dec 12, 2015

Thank you for posting 👍


This comment has been minimized.

emiglobetrotting commented Jan 22, 2016

please may provide a support for pthreads with this installation


This comment has been minimized.

serkin commented Apr 4, 2016

lines 86-88 should it be /etc/php7/ instead of /etc/php/?


This comment has been minimized.

gp187 commented Sep 1, 2016

Now that it's stable you can get it from repo

add-apt-repository ppa:ondrej/php
apt-get update
apt-get install -y php-pear php7.0-fpm php7.0-curl php7.0-gd php7.0-mcrypt php7.0-memcache php7.0-sqlite3 php7.0-xmlrpc php7.0-mbstring php7.0-imagick php7.0-apcu

Or somewhat sexier apt-get

apt-get install -y php7.0-{fpm,curl,gd,mcrypt,memcache,sqlite3,xmlrpc,mbstring,json,imagick,apcu,cli}

This doesn't include mysql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment