Roundcube showing php source code step by step solution

I was facing issue that Roundcube was showing php source code instead of front page. The solution is following

And steps are

Steps to Achieve This Configuration

Here’s how to configure and enable mpm_event and PHP-FPM on Apache:

Disable mpm_prefork:

sudo a2dismod mpm_prefork

Enable mpm_event:
sudo a2enmod mpm_event

Enable proxy_fcgi module (if not already enabled):
sudo a2enmod proxy_fcgi

Verify PHP-FPM is installed and running:
Ensure that PHP-FPM is running on port 9000 (as per your configuration).

Start PHP-FPM service if it’s not running:

sudo systemctl start php7.x-fpm

Replace php7.x with the actual PHP version installed on your server.

Restart Apache to apply the changes:

sudo systemctl restart apache2

Verify Apache Configuration

Use apachectl to verify if everything loads without errors:

sudo apachectl configtest

Explanation of Configuration Directive
In the hestia-event.conf file, the following configuration tells Apache to handle .php files by forwarding them to PHP-FPM at 127.0.0.1:9000:

<IfModule mpm_event_module>
    <FilesMatch \.php$>
        SetHandler "proxy:fcgi://127.0.0.1:9000"
    </FilesMatch>
</IfModule>

FilesMatch: Targets files ending with .php.
SetHandler: Defines the handler for PHP files as the proxy_fcgi module, which forwards requests to PHP-FPM running at the specified address and port.

Summary
This solution switches Apache’s MPM to one that is compatible with PHP-FPM, improving resource efficiency and performance.