Any difference in running folder between CGI and FCGI ? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- egsuh · 2018-11-03 06:47 Hi, I'm developing web-server applications both in CGI and FCGI just because during the development, the CGI is convenient but finally the FCGI will be used. I found there are subtle differences between them --- like transactions of database programming. In FCGI, transactions may be working but not in CGI. I found another difference ---- in Windows 7. It seems that CGI apps run at the root directory (it is called folder in Windows terminology. Anyway which is 'c:\inetpub\wwwroot\') while FCGI run at the directory the application reside (for example 'c:\inetpub\wwwroot\myapp\'). I saw the difference when I tried to read a file from within webmodule. For example, I tried to read a file     c :\inetpub\wwwroot\myapp\a.txt In FCGI , just defining thel path as 'a.txt' is fine, but in the CGI it should be '.\myapp\a.txt' or 'myapp\a.txt'. Hope anybody confirm this, and I would appreciate if you could advise on a "common" path definition  . ---------------------------------------------------------------------- Thaddy · 2018-11-03 07:03 The default path is usually /www/root/cgi or \www\root\cgi or for IIS \inetpub\wwwroot\cgi and not the actual root, but a subdirectory. For both cgi and fcgi the path is configurable in your webserver configuration. It is even recommended to not use the default paths but run them outside of the www root in a separate tree or directory. The reason being that it is a security risk on many mal-configured web servers: the content tree needs local read/write rights but sometime it has global read/write rights. In that case a hacker can - helped by the predictable path - easily manipulate or replace the cgi or fastcgi executable. This was an issue on many web server software - specifically on old versions of  IIS - and can easily be mitigated by configuring the path. Note in some scenario's it can be that your hosting provider doesn't allow that but usually they make sure that the rights are properly set. The main difference is that cgi creates a process for every request whereas FastCGI is a basically a server on its own and serves requests from a single process. You should examine the documentation for your webserver on how to configure the path. ---------------------------------------------------------------------- egsuh · 2018-11-03 07:30 Okay. Thank you very much for your kind advise. Currently I'm developing and testing at local machine, and I'll take care of the settings later. ---------------------------------------------------------------------- Leledumbo · 2018-11-04 16:54 Adding to Thaddy's answer, CGI is executed in webserver context, i.e. the webserver decides the current directory for the CGI executable, which might be (should be, I didn't find one that can't) configurable. FCGI, as it starts on its own (but Apache can also help spawing if requested, Nginx can't), executes in the way you execute it, which depends directly on the OS (policy) to decide the current directory. ---------------------------------------------------------------------- Thaddy · 2018-11-04 17:28 Quote from: Leledumbo on November 04, 2018, 05:54:08 pmAdding to Thaddy's answer, CGI is executed in webserver context, i.e. the webserver decides the current directory for the CGI executable, which might be (should be, I didn't find one that can't) configurable. FCGI, as it starts on its own (but Apache can also help spawing if requested, Nginx can't), executes in the way you execute it, which depends directly on the OS (policy) to decide the current directory. I wonder why you couldn't find it. It is in the standard documentation of Apache, Ngynx and IIS. (even Tinyweb  ). I will add links later but a google should do. edit: for starters the script alias section for apache here:https://httpd.apache.org/docs/2.4/howto/cgi.html (yes cgi's are considered "scripts", maybe that confused you.