CakePHP and php-fpm

Kiekeboe100

Verified User
Joined
Apr 19, 2008
Messages
146
Location
Belgium
Hi,

I'm having issues with CakePHP installs on my server. I have a client whose website has been built by the CakePHP framework.
On my old server (suPHP) everything works perfectly.
But on the new server (with php-fpm 5.3 and 5.5) I get an "Internal Server Error" on the webpage.

Code:
[Sat Jan 04 13:25:06.858739 2014] [core:error] [pid 23944:tid 139815462860544] [client 2a02:578:f2a:100:b5a4:c8d5:1e93:87a2:53710] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

http://book.cakephp.org/2.0/en/installation/url-rewriting.html

CAn this be a conflict between the CakePHP rewrite rules and the php-fpm rewrites?

regards,
Stijn
 
Hi,

Thanks. Didn't see that entry.
This got me looking a bit further.

In the httpd template, both
Code:
|*if HAVE_PHP1_FPM="1"|
        <IfModule mod_fastcgi.c>
                <FilesMatch "\.php$">
                        SetHandler php|PHP1_RELEASE|-fcgi
                </FilesMatch>
                FastCgiExternalServer |REALDOCROOT|/php|PHP1_RELEASE|-fpm -idle-timeout 300 -socket /usr/local/php|PHP1_RELEASE|/sockets/|USER|.sock -pass-header Authorization -user |USER| -group |GROUP|
                Alias /php|PHP1_RELEASE|-bin |REALDOCROOT|/php|PHP1_RELEASE|-fpm
        </IfModule>
|*endif|
and
Code:
|*if HAVE_PHP1_FPM="1"|
                <IfModule mod_rewrite.c>
                        RewriteEngine on
                        RewriteOptions InheritBefore
                        RewriteBase /
                        RewriteCond %{REQUEST_URI} ^/php|PHP1_RELEASE|-bin(.*)
                        RewriteRule . - [L]
                </IfModule>
|*endif|
are used.

My guess is that the FilesMatch uses the new method (mod_proxy_fcgid)
While the rewrite uses mod_fastcgi.

I removed the whole mod_rewrite section from this particular client, and everything seems to work now.

regards,
Stijn

edit:
In the user's httpd.conf I also found
Code:
<Directory "/home/user/public_html">
                RewriteCond %{REQUEST_URI} ^/~user(/(.*\.php))?$
                RewriteCond %{REQUEST_FILENAME} -f
                RewriteRule ^/?(.*(/.*)?\.php(/.*)?)$ fcgi://socket=\%2fusr\%2flocal\%2fphp55\%2fsockets\%2fuser.sock/home/user/public_html/%2 [P,E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
                RewriteCond %{REQUEST_URI} ^/~user(/(.*\.php))?$
                RewriteCond %{REQUEST_FILENAME} -f
                RewriteRule ^/?(.*(/.*)?\.php53(/.*)?)$ fcgi://socket=\%2fusr\%2flocal\%2fphp53\%2fsockets\%2fuser.sock/home/user/public_html/%2 [P,E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</Directory>

I commented this, restarted apache, and everything is still working. Probably this is also from the old mod_fastcgi?
 
Last edited:
Your first 2 blocks are for php-fpm via mod_fastcgi
The last one is unused and is for when apache introduces a version of its module which works properly with PHP-FPM.

You probably had a conflict between the standard rewrite rule and the one in the CakePHP app.
Arieh's link is still valid today as the move to mod_proxy_fcgid hasn't happened for virtualhosts.
 
CakePHP installation

Hi,

I'm having issues with CakePHP installs on my server. I have a client whose website has been built by the CakePHP framework.
On my old server (suPHP) everything works perfectly.
But on the new server (with php-fpm 5.3 and 5.5) I get an "Internal Server Error" on the webpage.

Code:
[Sat Jan 04 13:25:06.858739 2014] [core:error] [pid 23944:tid 139815462860544] [client 2a02:578:f2a:100:b5a4:c8d5:1e93:87a2:53710] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

http://book.cakephp.org/2.0/en/installation/url-rewriting.html

CAn this be a conflict between the CakePHP rewrite rules and the php-fpm rewrites?

regards,
Stijn

1. Download updated Cake PHP from CakePHP Official Website[^] and unzip the file.
2. Copy the folder to Wamp server folder : C:\www\wamp\(cakefolder)
3. Here everything you will have to do in app folder. Don't alter any other folder content, if you don't have much knowledge.
4. Go to (cakefolder) -> app -> Config -> database.php.defult and rename it as database.php
5. Open (cakefoler) -> app -> Config -> core.php and change the Security.salt value and Security.cipherSeed.
6. Make sure the (cakefolder) -> tmp is writable and apache mod_rewrite is enabled.
7. Set the database.php configuration with the database details.
8. Open the browser and type : http://localhost/(cakefolder)/ and that's up.
 
Back
Top