About Restful Url with PHP CGI/FCGI

Hello,

I need help with my new installation. I can not have work restful urls with PHP CGI/FCGI mode. If I change the server api to mod_php then it works. Is it possible to use restful urls in CGI/FCGI mode? I have tried all of the methods with in forum (htaccess, cgi fixpathinfo, installing to main dir, etc.) Can anyone help me about how to done restful urls with cgi? Or is it not possible to use.

My PHP Server Api CGI/FastCGI
Apache Version 2.2.27
PHP Version 5.6

Hi @SadayNet,

The usual problem with these configurations is PATH_INFO URLs. You can test these outside of OJS if it helps to simplify the situation. Create a PHP script containing the following:

<?php print_r($_SERVER); ?>

Make sure you can access it (e.g. call it test.php and fetch it from the browser).

Then try adding something after the .php in your browser URL, e.g.: http://.../test.php/something/else/here.

If your configuration is correct, you’ll see the something/else/here show up in the PATH_INFO part of the output. If it doesn’t, or if you get a 404 error or something similar, then your Apache/PHP/CGI/FastCGI configuration isn’t working. You might find StackOverflow a good resource.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

Thank you for your help. I’ve created a test.php file with the code you sent and checked that I can access the URL. In PATH_INFO I can see /something/else/. So, my configuration works the way you say. I’m using the settings:
In .htaccess

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase /ojs/
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>

And in config.inc.php just changed the restful_url = On.

Now, when I try to access site, the error is ‘No input file specified.’

Hi @SadayNet,

I suspect the problem is in your RewriteBase as the rest is a standard RESTful rewrite ruleset for OJS. You can use a test script again to work this out without OJS potentially getting in the way.

Regards,
Alec Smecher
Public Knowledge Project Team

hi… what is .htaccess?

If I can jump in, we’ve had this problem numerous times with PKP|PS and there’s no really great solution with PHP-CGI. With PHP-FPM, all of our standard .htaccess configurations work just fine for RESTful URLs, but switching those journals to PHP-CGI results in the “no input file specified” problem.

I’ve scoured a ridiculous amount of literature, and despite a few false promises of including question marks and such to fake query strings and stuff like that, the general consensus seems to be that the reason why this happens with PHP-CGI is because there is no doc_root with the CGI handler and when you remove the index.php from the URL, the CGI handler doesn’t actually know what PHP script to run, and hence, the error.

Cheers,
Jason