# PHP 7.2.34
# ==========
# As of 2022-11-03, PHP 7.2.x has reached End of Life status
# 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
# Bison (PHP 5.x not OK with Bison 3.x, PHP 7.x is OK with it)
# re2c
# sendmail
# pkg-config
# PCRE (it uses the bundled one by default)
# libxml2 (enabled by default if it's installed, required for --enable-libxml and --enable-dom, both defaults)
# Expat
# Valgrind
# 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)
# 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)
# Note: As of 7.2.x, mcrypt has been moved to PECL
# libmcrypt >= 2.5.6
# Get it
cd
test -f installed/apache2/php-7.2.34.tar.xz &&
mv installed/apache2/php-7.2.34.tar.xz .
test ! -f php-7.2.34.tar.xz &&
wget http://us1.php.net/distributions/php-7.2.34.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.2.34.tar.xz
cd php-7.2.34
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-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://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
# 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 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.43 (Unix) OpenSSL/1.1.1g PHP/7.2.34
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.2.34.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.*