2

I'm trying to change my Open Journal Systems installation to run under php-fpm instead of php-cgi, but when I make the change all my rewrites, specified in .htaccess, break -- the redirects simply don't work ('File not found'), and the logged error is something like AH10131: FastCGI: server "/home/username/www/index.php" stderr: Primary script unknown, referer: https://mydomain/some/path.

The system is running PHP 7.3.27, and Apache.

The .htaccess file looks like this:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.)(.*) [NC]
RewriteRule (.*) https://%2%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]

</IfModule>

Can anyone tell me how to convert this to be php-fpm-friendly? Or what is that I'm missing?

The hosting package is quite limited, so I can't change e.g. php.ini directly, although if that is ultimately what's necessary then it's something I would consider.

melat0nin
  • 860
  • 1
  • 16
  • 37
  • 2
    How the rewriting itself is handled, should not have anything to do with the way PHP is embedded in the web server. – CBroe Mar 17 '21 at 15:01
  • 1
    `index.php/$1` – for PHP to be able to read what gets passed after the slash here, the PATH_INFO must be correctly populated. Whether that happens, depends first of all on the Apache directive [`AcceptPathInfo`](https://httpd.apache.org/docs/2.4/mod/core.html#acceptpathinfo), so make sure that is (still) active. – CBroe Mar 17 '21 at 15:04
  • 1
    PHP also has some settings that influence the path info behavior when run in CGI mode, check those as well. https://www.php.net/manual/en/ini.core.php#ini.cgi.discard-path (`discard_path` and `fix_pathinfo`) – CBroe Mar 17 '21 at 15:06
  • `AcceptPathInfo` would appear to be active; a quick `print_r($_SERVER["PATH_INFO"]);` in a file `test.php/some/path` gives output `/some/path` – melat0nin Mar 17 '21 at 15:42
  • 1
    I added the logged error message to the OP, in case it illuminates anything: `AH10131: FastCGI: server "/home/username/www/index.php" stderr: Primary script unknown, referer: https://mydomain/some/path` – melat0nin Mar 17 '21 at 16:25
  • It appears that often might hint at a permission issue, https://stackoverflow.com/q/35261922/1427878, https://serverfault.com/q/517190 - those are nginx-focused questions, but the permission issue parts should be independent from the web server. – CBroe Mar 18 '21 at 07:11

0 Answers0