You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PHP合并CSS遇异常:同配置两虚拟主机结果不同,报loadproxy_fcgi错误

Troubleshooting the loadproxy_fcgi:error on Your Apache/PHP-FPM Setup

Hey, let's dig into why your two seemingly identical virtual hosts are behaving differently and throwing that loadproxy_fcgi:error on your new Debian server. Given your setup (Apache 2.4 Event MPM + PHP 7.2 FPM) and the fact your CSS-merging PHP script worked for years, here are the most likely fixes to try:

1. Update Your Apache 2.4 Directory Permissions Syntax

Your current <Directory> block uses Apache 2.2-era rules (Order Deny,Allow + Allow from all). While Apache 2.4 supports these for backwards compatibility, they can cause weird permission glitches when paired with Event MPM and PHP-FPM. Swap it for the 2.4 standard syntax:

<Directory /var/www/balkenhantel>
    Require all granted
    AllowOverride All
    Options -Indexes
</Directory>

Double-check that both virtual hosts have this updated config—even a tiny oversight here could throw things off.

2. Verify PHP-FPM Pool & Apache Proxy Configs

Since you're using Event MPM, you must run PHP via FPM (not mod_php). Make sure both vhosts are correctly pointing to the same FPM pool, and that Apache has the right modules loaded:

  • First, enable the required Apache modules if you haven't already:
    a2enmod proxy_fcgi setenvif
    
  • Then, add this PHP handler block to both vhosts (adjust the sock path if your FPM uses a different location):
    <FilesMatch \.php$>
        SetHandler "proxy:unix:/run/php/php7.2-fpm.sock|fcgi://localhost/"
    </FilesMatch>
    

If you set up separate FPM pools for each vhost, confirm the sock file permissions let the Apache user (www-data) access it—this is a super common cause of FPM connection failures.

3. Check File/Directory Permission Differences

Even if your vhost configs look identical, the actual file permissions in each site's DocumentRoot might not match:

  • Run this to check ownership and permissions:
    ls -l /var/www/
    

Ensure both balkenhantel and your other site directory are owned by www-data:www-data, or at least give www-data read access to all CSS files and the merging script.

  • Also, check if either site has an .htaccess or php.ini setting that restricts open_basedir—this could block the script from reading CSS files outside a specific directory.

4. Fix PHP 7.2 Compatibility Issues in Your CSS Merging Script

Your script worked for years, but PHP 7.2 deprecated/removed some older functions and tightened up defaults:

  • Memory limits: If you're merging a lot of CSS files, PHP 7.2's default memory limit might be too low. Add this at the top of your script to bump it:
    ini_set('memory_limit', '64M');
    
  • Timeouts: If the merging process takes longer than expected, Apache or FPM might kill the request. Check your FPM pool config for request_terminate_timeout and Apache's ProxyTimeout setting, and increase them if needed.
  • File operations: Double-check that your script uses modern file functions (e.g., file_get_contents instead of outdated stream wrappers) and handles errors properly—PHP 7.2 is stricter about uncaught warnings.

5. Dig Into the Actual Error Logs

The loadproxy_fcgi:error is just a generic message—you need to look at the detailed logs to find the root cause:

  • Apache error logs: Check /var/log/apache2/error.log or the vhost-specific log files (if you set them up).
  • PHP-FPM logs: Look at /var/log/php7.2-fpm.log or the log file for your specific FPM pool.
    These logs will tell you exactly if it's a permission denied error, a script crash, or an FPM connection issue.

内容的提问来源于stack exchange,提问作者MrGlasspoole

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:39:13