HOWTO
# PHP 7.4.30
# ==========
# 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.
#
# Prerequisites:
#
Apache, Lighttpd, or another compatible web server
# -
LiteSpeed web server
#
Bison (PHP 5.x not OK with Bison 3.x, PHP 7.x is OK with it)
#
re2c
#
sendmail
#
pkg-config
#
PCRE2 or
PCRE
#
libxml2 (enabled by default if it's installed, required for --with-libxml and --enable-dom, both defaults)
#
Expat (--with-expat)
#
Valgrind
#
OpenSSL (for --with-openssl and --with-imap-ssl)
#
Kerberos
#
SQLite
#
zlib >= 1.2.0.4 (for --with-zlib)
#
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-external-gd to use the "real" one) and:
#
libwebp (for GD's --with-webp flag)
#
libjpeg (for GD's --with-jpeg flag)
#
libpng (required)
# Xpm from
XFree86 or
X.org (for GD's --with-xpm flag)
#
freetype 2.x (for GD's --with-freetype 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)
#
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)
#
libzip (for --with-libzip)
#
Onigurama (required for regular expression functions with multibyte support)
# Note: As of 7.2.x, mcrypt has been moved to PECL
#
libmcrypt >= 2.5.6
# If you are doing so, read this:
#
Migrating from PHP 5.6.x to PHP 7.0.x
#
Migrating from PHP 7.0.x to PHP 7.1.x
#
Migrating from PHP 7.1.x to PHP 7.2.x
#
Migrating from PHP 7.2.x to PHP 7.3.x
#
Migrating from PHP 7.3.x to PHP 7.4.x
#
PHP 7 ChangeLog - Version 7.4.30
# If you have trouble with the download URL below, a list of download mirrors
# is available here:
#
http://www.php.net/get/php-7.4.30.tar.xz/from/a/mirror
# Web site mirrors are here:
#
http://php.net/mirrors.php
#
http://us1.php.net/mirrors.php
#
http://us2.php.net/mirrors.php
#
http://us3.php.net/mirrors.php
# Get it
cd
test -f installed/apache2/php-7.4.30.tar.xz &&
mv installed/apache2/php-7.4.30.tar.xz .
test ! -f php-7.4.30.tar.xz &&
wget http://us1.php.net/distributions/php-7.4.30.tar.xz
# Verify tarball w/
sha256sum:
echo "ea72a34f32c67e79ac2da7dfe96177f3c451c3eefae5810ba13312ed398ba70d php-7.4.30.tar.xz" | sha256sum -c
# Verify tarball w/
gpg:
# [ See here for ID, fingerprint: http://us1.php.net/downloads.php#gpg-7.4 ]
( gpg --list-keys F53EA312 > /dev/null 2>&1 || gpg --recv-keys F53EA312 ) &&
wget -nc http://us1.php.net/distributions/php-7.4.30.tar.xz.asc &&
gpg --verify php-7.4.30.tar.xz.asc && rm php-7.4.30.tar.xz.asc
# 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.4.30.tar.xz
cd php-7.4.30
test $UID = 0 && chown -R root:root .
# If you're building PHP for use with
Horde's
IMP, you probably want these:
# (Note: I've done this before with mcrypt, which is now a PECL ext)
#
# --with-gettext --with-imap --with-imap-ssl --enable-mbstring
# --with-gd --with-jpeg --with-png
#
# (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
#
# 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://us1.php.net/manual/en/
# Rather than build the MySQL/MariaDB support the older
# --with-mysqli=/usr/local/mysql/bin/mysql_config way, we
# use mysqlnd below. This avoids some building issues between MariaDB
# 10.2, 10.3 and PHP like these:
# https://bugs.php.net/bug.php?id=75612
# https://jira.mariadb.org/browse/MDEV-14555
# In 7.4.x, many of the --with-xxxx-dir=/usr type flags are now just
# --with-xxxx and pkg-config will handle the path
# Configure the build
LIBDIR=lib
test $(uname -m) = 'x86_64' && LIBDIR=lib64
./configure --with-libdir=${LIBDIR} --with-apxs2=/usr/local/apache2/bin/apxs --libdir=/usr/local/lib64 --disable-cgi --with-openssl --with-ldap --with-zlib --with-mysql-sock=/tmp/mysql.sock --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-curl --enable-sockets --with-bz2 --with-zip --enable-dba --with-db4 --enable-exif --with-gmp --with-mhash --with-gettext --with-imap --with-imap-ssl --enable-intl --enable-mbstring --enable-gd --with-jpeg --with-freetype --with-tidy --enable-calendar --disable-ipv6
unset LIBDIR
# Build it
make
# Test the build, may take a while
make test
# Become root to install it
su
# Remove the Slackware package unless you are running an Apache
# with that PHP now until you fire up the one installed here
# (under /usr/local/)
test /sbin/removepkg && /sbin/removepkg php
# 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:
## (or use --mandir above to put them in /usr/local/man instead)
# 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 a profile script for Apache, 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.54 (Unix) OpenSSL/1.1.1o PHP/7.4.30
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.4.30.tar.xz installed/apache2/
# If you ever want to uninstall PHP, this should do it:
cd
su
# Before you do this, comment out the line that loads the PHP module
# in Apache's configuration, and restart it (if you want it to run
# without PHP)
rm -f /usr/local/apache2/modules/libphp7.so
( cd /usr/local/bin
rm -f phar phar.phar php php-config phpdbg phpize )
test -d /usr/local/include/php && rm -r /usr/local/include/php
test -d /usr/local/lib64/build && rm -r /usr/local/lib64/build
test -d /usr/local/lib64/extensions && rm -r /usr/local/lib64/extensions
test -d /usr/local/lib64/php && rm -r /usr/local/lib64/php
test -d /usr/local/php && rm -r /usr/local/php
exit
find ~/src -maxdepth 1 -type d -name "php-*" -exec rm -r {} \;
rm -f ~/installed/php-*.tar.*