It depends on which Linux distribution. you're using.
You can try: yum update php
Or: sudo apt-get install php5-cgi php5-cli
I highly recommend that you test your code on 5.4 before updating any server in real time, as there are likely to be some breaks (as usual with most PHP updates).
source share