Apache 2.4 Error: FCGI: attempt to connect to Unix domain socket /run/php/php7.0-fpm.sock (*) failed
When upgrading a production environment from PHP 5.x to PHP 7, it is common for the web server's frontend services to function flawlessly while the administrative backend or direct IP access fails immediately. This specific scenario, where customer sites run perfectly on FastCGI Process Manager (FPM) but the Froxlor management interface returns an HTTP 503 error, points directly to a mismatch in how Apache attempts to handshake with the PHP process manager.
The Apache error log provides a definitive clue: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php7.0-fpm.sock (*) failed. The asterisk indicates that Apache is looking for a socket at that specific path, but the file does not exist or is inaccessible. This disconnect typically occurs because the PHP-FPM service was restarted after the upgrade without properly registering its new process manager in the system's supervision hierarchy, or the FPM pool configuration for the administrative user has not been updated to match the new PHP version.
Diagnosing the Socket Mismatch
The core issue is that Apache expects a socket at /run/php/php7.0-fpm.sock, yet the PHP-FPM daemon may have initialized with a different socket path or failed to start entirely. In Debian 8 environments running Apache 2.4, the default configuration usually points to /var/run/php/php7.0/fpm.sock or /run/php/php7.0-fpm.sock. The failure often stems from how the PHP-FPM service was installed or restarted relative to the system's init system.
To resolve this, you must first verify if the socket exists at any location on the filesystem. Use the following command to list sockets created by PHP-FPM:
ls -la /run/php/ /var/run/php/ /etc/php/7.0/fpm/pool.d/
If the socket file is missing entirely, it suggests that the php7.0-fpm service is not running or is misconfigured. Check the status of the FPM service:
systemctl status php7.0-fpm
# Or on older Debian systems:
service php7.0-fpm status
If the service reports an error, review its own logs (often located at /var/log/php7.0-fpm.log or within syslog) to identify why the daemon failed to spawn worker processes. Common causes include missing shared objects or permission errors on the pool configuration files.
Aligning Apache and PHP-FPM Configuration
Once the socket path is confirmed, you must ensure Apache's VirtualHost configuration matches the reality of the filesystem. In your Apache virtual host configuration (typically found in /etc/apache2/sites-available/), locate the ProxyPassMatch directive that handles .php requests. It likely looks like this:
<FilesMatch "\.php$">
SetHandler "proxy:fcgi://unix:/run/php/php7.0-fpm.sock"
</FilesMatch>
If your system actually uses /var/run/php/ as the socket directory, you must update the SetHandler directive to reflect that path. Do not guess the path; derive it from the actual output of the ls command above. Mismatched paths are a frequent source of "No such file or directory" errors during FPM upgrades.
Additionally, verify that the user running Apache (usually www-data) has read and execute permissions on the socket file. PHP-FPM typically creates the socket with restrictive permissions (e.g., 0770), allowing only specific users to access it. If the group ownership does not include www-data, Apache cannot connect, resulting in a silent failure or an error depending on the configuration.
ls -l /run/php/php7.0-fpm.sock
# Example output: srwxrwx--- 1 www-data www-data ...
If permissions are too tight, you may need to adjust the group ownership of the socket file or the entire PHP-FPM pool directory to ensure www-data is included in the access list.
Handling Administrative Interfaces vs. Public Sites
The fact that customer sites work while the Froxlor backend fails is a classic symptom of differing execution contexts. Customer sites might be configured with a pool specifically for your web server user, or they might be served by a separate PHP version (e.g., via php-fpm packages for specific versions) that happens to have the socket registered correctly. However, the Froxlor backend likely runs as a distinct application using a specific pool configuration (often named froxlor.conf).
If you upgraded PHP globally but did not update the pool configuration files in /etc/php/7.0/fpm/pool.d/ for the Froxlor user, the daemon might have started with default settings or failed to start the specific pool required for the admin interface. Ensure that the pool file corresponding to the Froxlor application is correctly defined and enabled:
ls -l /etc/php/7.0/fpm/pool.d/ | grep froxlor
If the file exists but is not active, enable it via the PHP-FPM configuration manager or by creating a symlink in /etc/php/7.0/fpm/conf.d/.
Once the socket path is corrected in Apache's SetHandler directive and the permissions are aligned, restart both services to apply changes:
systemctl restart php7.0-fpm apache2
After restarting, verify that the socket appears in the directory and that Apache logs no longer report connection failures. If the error persists, carefully inspect the PHP-FPM stderr output for fatal errors during startup that might prevent the pool from initializing even if the service reports "active".