# PHP 7.0.33
# ==========
# As of 2019-01-10, PHP 7.0.x has reached End of Life status
# Prerequisites:
# Apache, Lighttpd, or another compatible web server
# bison (PHP 5.x not OK with Bison 3.x, PHP 7.x is OK with it)
# re2c
# sendmail
# pkg-config
# There are many optional prerequisites. To build them into your copy
# of PHP, make sure the program/library/whatever is installed, then add the
# appropriate configure flag below. The configure line below has just a few
# that I commonly use. For the full list, see the output of
# './configure --help | less'. Each extension you build in will add to the
# list of functions that you can use with PHP, but it also makes PHP larger.
# If you don't plan on writing PHP-based web pages (or using someone else's)
# that use the curl functions, for example, don't build in
# curl support.
#
# libxml2 (enabled by default if it's installed, required for --enable-libxml and --enable-dom, both defaults)
# OpenSSL (for --with-openssl and --with-imap-ssl)
# Kerberos
# SQLite
# zlib >= 1.2.0.4 (for --with-zlib and --with-zlib-dir)
# bzip2 (for --with-bz2)
# curl (for --with-curl)
# db3 (for --with-db3)
# db4 (for --with-db4)
# Enchant (for --with-enchant)
# libexif (for --with-exif)
# GD (PHP includes it's own copy now, or you can use
# --with-gd=/wherever/it/is to use the "real" one) and:
# libwebp (for GD's --with-webp-dir flag)
# libjpeg (for GD's --with-jpeg-dir flag)
# libpng (for GD's --with-png-dir flag)
# Xpm from XFree86 or X.org (for GD's --with-xpm-dir flag)
# freetype 2.x (for GD's --with-freetype-dir flag)
# gettext
# GMP (for --with-gmp)
# mhash (for --with-mhash)
# iconv or libiconv
# uw-imap (for --with-imap and --with-imap-ssl)
# OpenLDAP (for --with-ldap)
# and Cyrus SASL (for --with-ldap-sasl)
# MySQL (for --with-mysql* flags)
# PCRE (it uses the bundled one by default)
# PostgreSQL (for --with-pgsql)
# mm (for --with-mm; mm is not thread safe, will fail to build with Apache 2.x AFAIK)
# HTML Tidy (for --with-tidy)
# readline (for --with-readline)
# ucd-snmp or net-snmp (for --with-snmp and --enable-ucd-snmp-hack)
# libmcrypt >= 2.5.6 (for --with-mcrypt)
# Get it
cd
test -f installed/apache2/php-7.0.33.tar.xz &&
mv installed/apache2/php-7.0.33.tar.xz .
test ! -f php-7.0.33.tar.xz &&
wget http://us1.php.net/distributions/php-7.0.33.tar.xz
# Extract it
test ! -d src/apache2 && mkdir -p -m 0700 src/apache2
cd src/apache2
find -maxdepth 1 -type d -name "php-*" -exec rm -r {} \;
tar xJvf ~/php-7.0.33.tar.xz
cd php-7.0.33
test $UID = 0 && chown -R root:root .
# If you're building PHP for use with Horde's IMP, you probably want these:
#
# --with-gettext --with-imap --with-imap-ssl --enable-mbstring --with-mcrypt
# --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr
#
# (and you'll want --with-mysqli, --with-ldap, or something else to store
# your preferences in)
# If you are going to be using Roundcube Webmail, you'll need Intl (optional)
# and PDO MySQL (or SQLite)
# If you are 64-bit (uname -m = 'x86_64') and libraries are in /lib64,
# /usr/lib64, /usr/local/ssl/lib64, etc. use --with-libdir=lib64
# If not, leave that off as shown below
#
# If you do that, but have anything like /usr/local/mysql/lib and not
# lib64, you will need to create a symlink from lib to lib64 so PHP can
# find it
# Read through ./NEWS, ./README.UNIX-BUILD-SYSTEM, ./INSTALL, and if
# upgrading, ./UPGRADING
# The online PHP manual is:
# http://php.net/manual/en/
# The CPPFLAGS part below is required due to some MariaDB header files
# moving from /usr/local/mysqli/include/mysql to the server sub-directory below
# that
# If you get my_list.h: No such file or directory
# open ext/mysqli/php_mysqli_structs.h in a text editor and change the two
# include lines for my_list.h and the one for m_string.h and change them to
# server/my_list.h and server/m_string.h
# Then run 'make' again
# Test the build, may take a while
make test
# Become root to install it
su
# Install it
make install
# Some typical PHP installation directories:
# /usr/local/bin/ (phar phar.phar php php-config phpize)
# /usr/local/include/php/
# /usr/local/lib64/extensions/
# /usr/local/lib64/build/
# /usr/local/lib64/php/
# /usr/local/php/man/man1/ (the bin programs + .1)
## Update your MANPATH so you can run:
# man phar
# man phar.phar
# man php-config
# man php
# man phpize
echo "#!/bin/sh" > /etc/profile.d/php.sh
echo "export MANPATH=\$MANPATH:/usr/local/php/man" >> /etc/profile.d/php.sh
chmod 755 /etc/profile.d/php.sh
. /etc/profile.d/php.sh
# This will install a php.ini
# If you already had one, it will be renamed php.ini.old
# Compare differences between them with 'diff -u php.ini.old php.ini | less'
LIBDIR=lib
test $(uname -m) = 'x86_64' && LIBDIR=lib64
test -f /usr/local/${LIBDIR}/php.ini &&
( cp -a /usr/local/${LIBDIR}/php.ini /usr/local/${LIBDIR}/php.ini.old
test -d ~/backup/apache2 &&
cp -a /usr/local/${LIBDIR}/php.ini \
~/backup/apache2/php.ini-$(date +%Y%m%d))
cp php.ini-production /usr/local/${LIBDIR}/php.ini
unset LIBDIR
# If you have /usr/local/lib64 and files were installed under
# /usr/local/lib64/php, add that to include_path in php.ini
# If you've been through this howto before and you only upgraded PHP, you
# should just have to restart apache. Rather than 'apachectl restart', I'd
# suggest stopping it then starting instead.
## Make sure these are all set in your /usr/local/apache2/conf/httpd.conf
## or use an include file for the PHP settings. They're commented out
## here, but they shouldn't be in httpd.conf The LoadModule line should
## already be in there, but the others won't be (if this is a new
## installation of apache).
# LoadModule php5_module modules/libphp5.so
#
## These two would typically go in the <IfModule mime_module> section
# AddType application/x-httpd-php .php .php3 .php4
# AddType application/x-httpd-php-source .phps
#
# DirectoryIndex index.php index.php4 index.php3 index.html
# If you don't have one, you may need to use the full path to apachectl
test -f /etc/profile.d/apache2.sh && . /etc/profile.d/apache2.sh
# Make sure all is well with your configuration:
apachectl configtest
# Now restart apache with PHP enabled:
apachectl stop
apachectl start
# Make sure the server is running everything it should be, either look at
# /usr/local/apache2/logs/error_log or run this command and look for a line
# like this:
# Server: Apache/2.4.37 (Unix) OpenSSL/1.1.0j PHP/7.0.33
lynx -dump -width=110 -head http://localhost/ | egrep "^Server:"
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .
# Become yourself again
exit
# Save the source for later
cd
test ! -d installed/apache2 && mkdir -p -m 0700 installed/apache2
rm -f installed/apache2/php-*.tar.*
mv php-7.0.33.tar.xz installed/apache2/