JavaEar 专注于收集分享传播有价值的技术资料

Apache on windows and php-fpm


php 7.1
Apache 2.4 + mod_proxy_fcgi
Windows 10

I'm trying to set up php-fpm + apache on windows, using mod_proxy_fcgi but keep getting errors. Can anyone help me with configuring apache.

I got php-fpm runnig, and verified that it actually works using nginx, so php should not be a problem.


PHP-fpm is running on port 9123.

Here is my vhost config:

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "${SRVROOT}/htdocs"
    <Directory "${SRVROOT}/htdocs">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        <FilesMatch "\.php$">
            SetHandler proxy:fcgi://127.0.0.1:9123
        </FilesMatch>
    </Directory>    
</VirtualHost>

Here is the error:

Proxy Error

Your browser sent a request that this server could not understand. The proxy server could not handle the request GET /index.php/.

Reason: URI cannot be parsed: fcgi://127.0.0.1:9123C:/Apache24/htdocs/index.php*

Does anyone know how to fix it ?

3个回答

    最佳答案
  1. I was dealing with the same issue and I found the root cause: most likely we were both following the this wiki.apache.org guide. There are a couple of typos in said guide. What causes the problem for us is that there is a missing slash after SetHandler. This is the config that worked for me:

    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
    
    <FilesMatch "\.php$">
        <If "-f %{REQUEST_FILENAME}">
            SetHandler "proxy:fcgi://localhost:9123/"
        </If>
    </FilesMatch>
    
  2. 参考答案2
  3. have you tried putting the:

    <FilesMatch "\.php$">
        SetHandler proxy:fcgi://127.0.0.1:9123
    </FilesMatch>
    

    outside the directory? Ie. what happens if you put that part between the docroot directive and the directory directive?

    Regards, Eric

  4. 参考答案3
  5. Hi try something like :

    <FilesMatch "^/CHANGE_ME/.*\.php(/.*)?$">
        SetHandler proxy:fcgi://127.0.0.1:9123
    </FilesMatch>