Install the packages php7 and php7-apache. Open /etc/httpd/conf/httpd.conf and make sure you are specifically using the php7 module, it should look like this:

LoadModule php7_module modules/
AddHandler php7-script php7
Include conf/extra/php7_module.conf

You shouldn’t need to do anything else besides restart apache: sudo systemctl restart httpd.

If you need other php extensions install the php 7 version, for example: sudo pacman -S php7-imagick.

The official arch repos currently only contain php 7 and php 8, but if you need to use any other version, you can install it from the AUR. For example paru -S php56 / yay -S php56. The same steps will apply.

Each version of php has it’s own configuration directory. Using php7 as an example: /etc/php7.