I know I can run a php script as CGI even if php has been installed as Apache module, if I put it in the cgi-bin folder, add #!/usr/bin/php (if php is installed at that location) as the first line and chmod it to 755.
But is there a way how to execute php scripts as cgi outside of the cgi-bin directory? Also, if I do install it in the cgi-bin folder, will such script have access to files outside of the cgi-bin folder (in the public_html root folder and subdirectories)?
Thanks!
Tomas
How to run PHP script in "cgi mode"?
Moderator: General Moderators
Re: How to run PHP script in "cgi mode"?
The last few versions of PHP that I have compiled as Apache modules have disabled the compiling of the CGI executable unless I actively specify with CGI at configure time, so you may not automatically have CGI support. The CLI executable is compilied by default so that may be what you have.tomfra wrote:I know I can run a php script as CGI even if php has been installed as Apache module, if I put it in the cgi-bin folder, add #!/usr/bin/php (if php is installed at that location) as the first line and chmod it to 755.
That would be down to the configuration of your web server.tomfra wrote:But is there a way how to execute php scripts as cgi outside of the cgi-bin directory?
That depends on your setup, your webserver can be configured to run your CGI apps/scripts under your username or it may be configured to run under the 'nobody' user (or some such similar user) in either case access restrictions will be decided upon by you filesystem permissions.tomfra wrote:Also, if I do install it in the cgi-bin folder, will such script have access to files outside of the cgi-bin folder (in the public_html root folder and subdirectories)?
As this post does not directly concern PHP code as such, it would have been better suited in the 'Webserver' section.