简体   繁体   中英

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 ?

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>

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

Hi try something like :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM