Skip to content

Instantly share code, notes, and snippets.

@derrekbertrand
Last active February 16, 2017 06:57
Show Gist options
  • Save derrekbertrand/b064f4379dd82a83ab995a5cc03fbf89 to your computer and use it in GitHub Desktop.
Save derrekbertrand/b064f4379dd82a83ab995a5cc03fbf89 to your computer and use it in GitHub Desktop.

Install build packages from repos. You will probably need EPEL.

 ~ # yum install git gcc gcc-c++ libxml2-devel pkgconfig openssl-devel bzip2-devel curl-devel libpng-devel libjpeg-devel libXpm-devel freetype-devel gmp-devel libmcrypt-devel mariadb-devel aspell-devel recode-devel autoconf bison re2c libicu-devel postgresql-devel

For Ubuntu this looks something like:

~ # apt install autoconf bison libpq-dev libxml2-dev apache2-dev systemtap-sdt-dev openssl pkg-config libssl-dev libcurl4-openssl-dev libbz2-dev libgdbm-dev libjpeg62 libjpeg62-dev libpng12-0 libpng12-dev libfreetype6-dev libicu-dev libiodbc2-dev libxslt1-dev

Make a place to put PHP's things.

 ~ # mkdir -p /usr/local/php/7.0
 ~ # mkdir -p /etc/php/7.0/conf.d

Clone from source. Checkout a specific release; look on php.net for what the latest release number is.

 ~ $ git clone https://github.com/php/php-src.git php70
 ~ $ cd php70
 ~/php70 $ git checkout PHP-7.0.X

Configure your build.

 ~/php70 $ ./buildconf --force
 ~/php70 $ ./configure --host=x86_64 \
    --prefix=/usr/local/php/7.0 \
    --disable-phpdbg \
    --disable-phpdbg-webhelper \
    --enable-bcmath \
    --enable-filter \
    --enable-fpm \
    --enable-ftp \
    --enable-intl \
    --enable-mbregex \
    --enable-mbstring \
    --enable-mysqlnd \
    --enable-opcache \
    --enable-shmop \
    --enable-simplexml \
    --enable-soap \
    --enable-sockets \
    --enable-sysvmsg \
    --enable-sysvsem \
    --enable-sysvshm \
    --enable-xmlreader \
    --enable-xmlwriter \
    --enable-zip \
    --with-bz2 \
    --with-config-file-path=/etc/php/7.0 \
    --with-config-file-scan-dir=/etc/php/7.0/conf.d \
    --with-curl \
    --with-freetype-dir \
    --with-gd \
    --with-jpeg-dir \
    --with-mysql-sock=/var/lib/mysql/mysql.sock \
    --with-pdo-mysql=mysqlnd \
    --with-openssl \
    --with-pdo-pgsql \
    --with-pdo-sqlite \
    --with-png-dir \
    --with-pgsql=/var/lib/pgsql/data \
    --with-sqlite3 \
    --with-xmlrpc \
    --with-zlib

Build the damn thing. If you have more CPUs, look into -j. Should take about 5 minutes to run make.

 ~/php70 $ make -j2
 ~/php70 # make install

Link the command line binaries. The second one sets this as the default PHP build, so you might not want to run that line depending on your config.

 ~/php70 # ln -s /usr/local/php/7.0/bin/php /usr/local/bin/php7.0
 ~/php70 # ln -s /usr/local/bin/php7.0 /usr/local/bin/php

Copy the default configs to varying directories.

~/php70 # cp -v ./php.ini-production /usr/local/php/7.0/lib/php.ini
~/php70 # mkdir /etc/php/7.0/php-fpm.d/
~/php70 # cp -v ./sapi/fpm/www.conf /etc/php/7.0/php-fpm.d/www.conf
~/php70 # cp -v ./sapi/fpm/php-fpm.conf /etc/php/7.0/php-fpm.conf
~ $ fpm -s dir -t rpm -v 7.0.15 --prefix / -m [email protected] -n php-common-dialinno -e --description "PHP is a popur general-purpose scripting language that is especially suited to web development." --vendor https://secure.php.net --license "PHP License" --url https://secure.php.net -C /home/derrek/projects/php7.0/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment