PHP5-FPM – FastCGI Process Manager, Rewrite Loop

Home Forums BulletProof Security Pro PHP5-FPM – FastCGI Process Manager, Rewrite Loop

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1159
    mikkie
    Member

    Ok, i am going to save some people a lot of frustration who decided to switch to (imo) the far superior PHP5-FPM + FastCGI solution. Problem #1:
    After you turn on fancy permalinks in WordPress the site throws a 503 internal server error. If you check the error log you will find:
    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.  And actually, turning on debug loglevel wont help you much, other then make you realize that the error is a rewrite problem.

    To fix this, in your .htaccess the WordPress code is:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    You have to manually change this and add your FastCGI alias as below (you have to substitute your alias with whatever you have set, in my case it is php5-fcgi but it could be anything)
    Alias example from vhost config:

    Action php5-fcgi /php5-fcgi
    Alias /php5-fcgi /home/yoursite/www/public_html/fastcgi/php5-fcgi
    FastCgiExternalServer /home/yoursite/www/public_html/fastcgi/php5-fcgi -host 127.0.0.1:9001 -pass-header Authorization
    Change to:
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/php5-fcgi/*
    RewriteRule . /index.php [L]

    Voila! working again. The same rewrite rules are also the same for Drupal which will break when clean url’s are enabled. Now, wether you enabled fancy permalinks or not, installing and activating BPS pro/Free will render your site inaccessible again and throwing a 503. The solution to this is very simple.
    Load up your .htaccess file, everytime you see:

     RewriteRule . /index.php [L]
    You have to manually enter a condition just before it:
    RewriteCond %{REQUEST_URI} !^/php5-fcgi/*

    Again, you have to substitute “php5-fcgi” with the alias you have set in your vhost.This solves 2 problems. #1 Fancy permalinks in WP with php5-fpm and #2 Rewrite issues causing internal redirects/loops with BPS.

    #1161
    AITpro Admin
    Keymaster

    NOTE:  This only applies if you have Virtual or Dedicated hosting.  This does not apply if you have Shared hosting.

    Thanks for adding this hot Virtual Hosting tip!

    Also since you have Virtual Hosting you will also need to change this in your Server Config – FcgidMaxRequestLen 33554432 (or other similar and relevant size settings) or else you will experience intermittent 500 Internal Server Errors on your website.  Please see this post for why >>> http://www.ait-pro.com/aitpro-blog/4349/misc-projects/wordpress-tips-tricks-fixes/php5-3-x-php5-4-x-user-ini-file-does-not-work-known-php5-3-x-user-ini-fastcgi-wordpress-zend-issue/

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.