Update PHP (Debian/Ubuntu)#
New PHP versions bring security fixes, better performance, and new features. At the same time, i-doit requires specific PHP versions -- always check the system requirements before updating to see which versions are currently supported.
This article describes switching from one PHP version to a newer one on Debian and Ubuntu -- using official package sources without third-party repositories.
Backup first
Before the PHP update, create a complete backup -- at minimum of the Apache configuration (/etc/apache2/), the PHP configuration (/etc/php/), and your i-doit installation.
Quick Guide (TL;DR)#
Using the example of switching from PHP 8.2 to PHP 8.3 with PHP-FPM:
- Create a backup
- Install new packages:
1sudo apt install libapache2-mod-fcgid php8.3-{bcmath,cli,common,curl,fpm,gd,imagick,ldap,mbstring,memcached,mysql,pgsql,soap,xml,zip} - Start and enable PHP-FPM:
1sudo systemctl enable --now php8.3-fpm - Create the i-doit PHP configuration for the new version:
1sudo nano /etc/php/8.3/mods-available/i-doit.inii-doit.ini 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
allow_url_fopen = Yes file_uploads = On max_execution_time = 300 max_file_uploads = 42 max_input_time = 60 max_input_vars = 10000 memory_limit = 256M post_max_size = 128M register_argc_argv = On short_open_tag = On upload_max_filesize = 128M display_errors = Off display_startup_errors = Off error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT log_errors = On default_charset = "UTF-8" default_socket_timeout = 60 date.timezone = Europe/Berlin session.gc_maxlifetime = 604800 session.cookie_lifetime = 0 mysqli.default_socket = /var/lib/mysql/mysql.sock1sudo phpenmod -v 8.3 i-doit - Switch the Apache VirtualHost to the new PHP version -- adjust the socket path in
/etc/apache2/sites-available/i-doit.conf:1SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost/" - Enable Apache modules and restart services:
1 2
sudo a2enmod proxy_fcgi setenvif rewrite sudo systemctl restart php8.3-fpm apache2 - Clear the i-doit cache under Administration > System Repair and Cleanup
Which PHP Version Does My Distribution Provide?#
You can only install the PHP version that your distribution offers in its official repositories. For a newer version, you would need to upgrade the distribution itself.
| Distribution | PHP Version |
|---|---|
| Debian 12 "Bookworm" | PHP 8.2 |
| Ubuntu 22.04 LTS "Jammy" | PHP 8.1 |
| Ubuntu 24.04 LTS "Noble" | PHP 8.3 |
Check which version is available:
1 | |
Preparations#
1. Update the System#
1 | |
2. Determine the Current PHP Version#
1 2 3 4 5 6 7 8 | |
3. Check the Apache Integration Method#
There are two ways Apache processes PHP files:
| Method | Description | Recommendation |
|---|---|---|
| mod_php | PHP runs directly in the Apache process. Simple but less performant. Requires mpm_prefork. | For small installations |
| PHP-FPM | PHP runs as a separate service. Apache forwards requests via a socket. Allows mpm_event. | Recommended for production |
Check which method is currently active:
1 2 3 4 5 | |
Install PHP Packages#
Install the packages for the new version. In the following example, PHP 8.2 is replaced by PHP 8.3 -- adjust the version numbers to your situation.
1 | |
If you use mod_php instead of PHP-FPM, also install:
1 | |
Migrate PHP Configuration#
Do not copy the old php.ini
Each PHP version may have changed or removed directives. Transfer your customizations manually to the new configuration.
Create the i-doit Configuration#
The cleanest approach: create a dedicated .ini file with the i-doit-specific settings:
1 | |
| i-doit.ini | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
Enable the configuration for all SAPIs (CLI and FPM):
1 | |
The complete settings can be found at System settings.
Where Are the php.ini Files Located?#
| SAPI | Path |
|---|---|
| CLI | /etc/php/8.3/cli/php.ini |
| Apache (mod_php) | /etc/php/8.3/apache2/php.ini |
| PHP-FPM | /etc/php/8.3/fpm/php.ini |
Configure Apache#
Option A: PHP-FPM (Recommended)#
1. Ensure mod_php is disabled:
1 2 | |
2. Enable Apache modules for FPM:
1 | |
3. Switch MPM to event (better performance than prefork):
1 2 | |
4. Adjust VirtualHost:
Change the socket path in /etc/apache2/sites-available/i-doit.conf:
| /etc/apache2/sites-available/i-doit.conf | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Check the socket path
The path /run/php/php8.3-fpm.sock must match the listen directive in /etc/php/8.3/fpm/pool.d/www.conf. A mismatch is the most common cause of errors.
5. Restart PHP-FPM and Apache:
1 | |
Option B: mod_php#
1. Disable old version, enable new one:
1 2 | |
2. MPM to prefork (mod_php requires this):
1 2 | |
3. Restart Apache:
1 | |
Verify the installation#
Verify PHP Version#
1 2 3 4 5 | |
Check i-doit#
- Open i-doit in the browser and verify that everything works
- Go to Administration > System Repair and Cleanup and clear the cache
- Check the system overview under Administration > System Overview -- there you can see the active PHP version
Remove the Old PHP Version#
If everything works, remove the old version:
1 2 | |
Caution
Before removing, verify that no other service on the server requires the old PHP version.
Common Problems#
HTTP 500 Internal Server Error#
- Check logs:
tail -50 /var/log/apache2/error.logandjournalctl -u php8.3-fpm - Socket mismatch: The most common error -- the path in the VirtualHost does not match the FPM configuration
- Missing modules:
php -mshows which modules are loaded. Compare with the system requirements - File permissions:
www-dataneeds read access to the PHP files - Configuration errors:
apache2ctl configtestchecks the Apache syntax
PHP Code Is Displayed as Text#
Apache is not forwarding .php files to the PHP interpreter:
- With PHP-FPM: Is the
<FilesMatch>block missing in the VirtualHost? - Is the FPM service running?
systemctl status php8.3-fpm - Are mod_php and FPM active at the same time? This causes conflicts -- disable mod_php.
Error Messages About Missing Extensions#
Check the loaded modules and compare with the required ones:
1 | |
Install missing modules:
1 | |
Changes to php.ini Have No Effect#
- Edited the wrong file? CLI, FPM, and mod_php each have their own php.ini files
- Service not restarted? After changes to the FPM configuration:
sudo systemctl restart php8.3-fpm - Custom .ini overridden? Check with
php --iniwhich files are loaded and in what order