For installing old software in a new Ubuntu Version, the old repositories have to be included.
Just replacing new by old packages
Be aware that old packages might replace new packages with this first way, but apt will warn you if this is the case and you still have the option to interrupt the downgrade:
- Open the file /etc/apt/sources.list
- Open the page https://repogen.simplylinux.ch/ and create a repository-list with your needs.
- Copy the repository-list in the file /etc/apt/sources.list ADDITIONALLY to the existing content. You can mark the old repositories with Ubuntu Version in a comment like ## Trusty 14.04 ##, then save the file.
- in the Terminal (Bash, Sh, ...) run
apt update
apt search php5
If you search something else than php5, just replace it by your own requirement.
Search the package(s) you want to install and run
apt-get install php5-cgi
Here you can enter also another package instead if php5-cgi, you shouldn't install what you never need.
Installing different PHP versions side by side
For php exist different possibilities, the list is not complete, some examples:
For other software than php you've to find different solutions for parallel installation.