Your questions is "too-broad".It is not same on each operating system,and also different implementation.For example,if you compile php from source,they you can simply re-compile with version which you need.If you using auto packaging system like yum on cent os,then you can do following:
YUM Downgrade Packages on Fedora, CentOS, Red Hat (RHEL)