Recently I have upgraded my mail server from 22.04.5 LTS to 24.04.1 LTS, I have made sure every prompt regarding to configuration changes have answer keep previous configuration (N), but after OS upgrade and rebooted I have greeted with 502 bad gateway at the Roundcube login page…
The solution is actually quite simple due to the Ubuntu version upgrade also upgraded the php to the latest version and the configuration it carried forward is incorrect. Follow below to get the Roundcube page running again.
1. Firstly check for installed php version:
ls -l /etc/init.d/php*fpm
As you can see I have 2 versions is installed, and 8.3 is running.
service php*fpm status
2. We need to bring the configuration from the old 8.1 to the 8.3 version. Just overwrite it will do, but I prefer the safer way by renaming the current 8.3 config to some other file name as backup. I am using WinSCP as file manager, feel free to use whichever file manager of your choice or use cli commands.
Copy the file www.conf from /etc/php/8.1(old version)/fpm/pool.d
to the latest php folder, in my case, which is /etc/php/8.3(new version)/fpm/pool.d
The contents should be similar to this:
3. After copying the file to the new directory, restart php and nginx service. (Replace 8.3 to the new version installed)
service php8.3-fpm restart
service nginx restart
4. Refresh the page and the Roundcube login is now working again.
Source: https://forum.iredmail.org/topic17897-solved-after-roundcube-update-502-bad-gateway-error.html