Suppose you have PHP version like php7.0 and php8.0. To set php version in you apache virtualhost open apache conf file like default-ssl.conf and update as following example.
# For PHP 7.0
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName hr.example.com
ServerAlias hr.example.com
ServerAdmin admin@example.com
DocumentRoot /home/hr/public_html
ServerPath /public_html/
<IfModule mod_fastcgi.c>
AddHandler php70-fcgi .php
Action php70-fcgi /php70-fcgi
Alias /php70-fcgi /usr/lib/cgi-bin/php70-fcgi -socket /var/run/php/php7.0-fpm.sock -pass-header Authorization
</IfModule>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/wildcard/example.com.crt
SSLCertificateKeyFile /etc/ssl/wildcard/example.com.key
SSLCertificateChainFile /etc/ssl/wildcard/example.com.ca-bundle
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
RewriteEngine on
RewriteRule "^(/public_html/.*)" "/home/iiucweb$1"
</VirtualHost>
</IfModule>
# For PHP 8.0
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName beta.example.com
ServerAlias beta.example.com
ServerAdmin admin@example.vcom
DocumentRoot /home/beta/public_html/public
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php/php8.0-fpm.sock|fcgi://localhost/"
</FilesMatch>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/wildcard/example.com.crt
SSLCertificateKeyFile /etc/ssl/wildcard/example.com.key
SSLCertificateChainFile /etc/ssl/wildcard/example.com.ca-bundle
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>