# PHP 8.3.3 (Current Stable 2024-02-15)
# =========
# 8.3.x will be actively supported until 2025-11-23 and security support
# for 1 year beyond that
#
# As this is written, PHP 8.3.x is the latest
# 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 (includes a bundled copy)
# libxml2 (enabled by default if it's installed, required for --with-libxml and --enable-dom, both defaults)
# Expat (--with-expat)
# Valgrind
# OpenSSL >= 1.0.2 (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)
# Aspell >= 0.50.0 (for --with-pspell)
# 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
# Get the tarball
cd
test -f installed/apache2/php-8.3.3.tar.xz &&
mv installed/apache2/php-8.3.3.tar.xz .
test ! -f php-8.3.3.tar.xz &&
wget https://www.php.net/distributions/php-8.3.3.tar.xz
# Extract the source
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-8.3.3.tar.xz
cd php-8.3.3
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-jpeg --with-gd
#
# (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.md, and if upgrading ./UPGRADING
# The online PHP manual is:
# https://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
# As of 7.4.x, many of the --with-xxxx-dir=/usr type flags are now just
# --with-xxxx and pkg-config will handle the path
# If you have glibc's iconv (/usr) and also have libiconv installed under
# /usr/local, use --with-iconv=/usr/local
# Be prepared to have to install things such as these after upgrading
# to a new release such as going from 8.2.x to 8.3.x, especially
# when the old ones are located in a different path (see the
# extensions path below):
# Imagick
# xapian-bindings
# Remove the Slackware package unless you are running an Apache
# HTTP with that PHP now until you fire up the one installed here
# (under /usr/local/)
test /sbin/removepkg && /sbin/removepkg php
# Probably not necessary, but you may want to clear out old files out
# of the typical PHP installation directories shown below if upgrading
# and you're sure they're not needed any more
# 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 configtest, then stop, then start.
## 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).
##
## NOTE: Make sure you only have one PHP module loading, if you have a
## php7_module line and a php_module line (ver 8), you will probably get a
## segfault and httpd will not start.
# LoadModule php_module modules/libphp.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.* (Unix) OpenSSL/*.*.* PHP/8.3.3
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
mkdir -p -m 0700 installed/apache2
rm -f installed/apache2/php-*.tar.*
mv php-8.3.3.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)
( cd /usr/local/apache2/modules
rm -f libphp7.so libphp.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.*