Apache 2 Fast CGI php issue

I'm trying to set php5.6.23 as fast CGI on my server for using php7 as main version

but in one of my domain, I get this error :

The requested URL / was not found on this server.

here is my vhost conf :

ScriptAlias / /usr/lib/cgi-bin
DocumentRoot "/home/ue4xxxx/www"

<Directory "/home/ue4xxxx/www">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all

        AddHandler php-cgi .php
        Action php-cgi /cgi-bin/php-cgi-5.6.23
        <FilesMatch "\.php*">
                SetHandler php-cgi
        </FilesMatch>
</Directory>

ErrorLog ${APACHE_LOG_DIR}/ue4/error.log
CustomLog ${APACHE_LOG_DIR}/ue4/access.log combined

I have the php cgi bin locate at /usr/lib/cgi-bin and I want to use the the file in the vhost root /home/ue4xxxx/www

UPDATE: After following some suggestions, the vhost conf is now:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName ue4-xxxx.tld
    ServerAlias ue4-xxxx.tld

        ScriptAlias /cgi-bin /usr/lib/cgi-bin
        DocumentRoot "/home/ue4xxxx/www"

        <Directory "/home/ue4xxxx/www">
                Options Indexes FollowSymLinks Includes ExecCGI
                AllowOverride All
                Order allow,deny
                Allow from all

                AddHandler php-cgi .php
                Action php-cgi /cgi-bin/php-cgi-5.6.23
                <FilesMatch "\.php">
                    SetHandler php-cgi
                </FilesMatch>
        </Directory>

    ErrorLog ${APACHE_LOG_DIR}/ue4/error.log
    CustomLog ${APACHE_LOG_DIR}/ue4/access.log combined
</VirtualHost>

After these changes, I get a 404 error:

The requested URL /cgi-bin/php-cgi-5.6.23/index.php was not found on this server

Solution 1:

You have an error here:

<FilesMatch "\.php*">

The "*" is not a wildcard in the sense that you used it, but means to "Repeat the previous match zero or more times."

You should review the Apache documentation for Regular Expressions, and change the FilesMatch to:

<FilesMatch "\.php">

ALSO: It looks like:

ScriptAlias / /usr/lib/cgi-bin

should probably be:

ScriptAlias /cgi-bin /usr/lib/cgi-bin

You can review the Apache documentation for the ScriptAlias Directive for more details of usage.