Admin Documentation

Updating PHP & Composer

While we try to ensure a fairly steady & stable path for BookStack updates, requirements do change as software develops & moves on. In particular, the minimum required version of PHP will increase about once per year. Every so often we also may require a new minimum version of Composer to be used for BookStack. This page details the common steps required to update both of these.


Updating PHP

Currently the minimum version of PHP required by BookStack is PHP 8.2. You’ll need to update PHP if using a version lower than 8.2. You can usually check your installed PHP version by running php -v but in some cases your web-server could be running a different PHP version than what the command line reflects.

Updating to PHP 8.5 on Ubuntu based systems using Apache

The commands below provide an example of how PHP can be updated to PHP 8.5 on most Debian & Ubuntu based systems that are running PHP via Apache using mod-php.

Warnings:

  • In most cases, especially if installed using our scripts and updating from a recent BookStack version, you won’t need to update PHP using the below as you’ll already be using PHP 8.3 or greater.
  • This will attempt to broadly remove all other PHP related packages installed on the system.
  • If you run other applications on this machine, PHP applications in particular, then those may also be affected by these changes.
  • You may be prompted to press enter on the third command. That’s expected and it should be safe to press enter.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
sudo apt update
sudo apt install -y software-properties-common lsb-release ca-certificates curl
sudo add-apt-repository --remove ppa:ondrej/php
sudo curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt update
sudo apt remove -y 'php8.*' 'libapache2-mod-php*'
sudo apt install -y php8.5 php8.5-curl php8.5-mbstring php8.5-ldap php8.5-xml php8.5-zip php8.5-gd php8.5-mysql libapache2-mod-php8.5
sudo a2dismod php8.0 php8.1 php8.2 php8.3 php8.4
sudo a2enmod php8.5
sudo systemctl restart apache2

You may also need to update composer to be compatible with php8.5.


Updating Composer

You can check your current composer version by running composer -V. You can often update composer by running sudo composer self-update (Or you may be prompted to run sudo composer self-update --2). Typically it’s fine, and best practice, to be using the latest version of composer rather than a specific version near our minimum requirements.

If you’re using a system-supplied composer package you may need to first uninstall that (eg. sudo apt remove composer) then follow the composer download documentation to get the latest version. Take notice of the sudo mv composer.phar /usr/local/bin/composer command shown in the documentation to install composer globally for easier usage.