I want to ask, I have a plan to migrate the VirtualMin Server to a new server that uses the latest operating system (Ubuntu 24.04) because there is a need for the latest PHP version.
Upgrading the OS is pretty much always the best way to get newer versions of any and all packages. There are options for getting newer PHP for supported OS versions (but 18.04 is no longer supported, so you can’t get maintained PHP packages for it from any of the common sources), but if upgrading the OS is an option, it’s the best one.