README.txt 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. Example that responds with the calling and system parameters
  2. ============================================================
  3. This demonstrates how to create a basic fpweb application. It responds to a
  4. request with a list of received/sent parameters, server settings and variables.
  5. Note: apart from the main project file (echo.lpr), there is not much that
  6. needs to change with using fpweb, no matter if we create CGI/FCGI applications
  7. or Apache modules. The web server config is different for each, of course.
  8. =====================
  9. 1. Compiling
  10. 1.a; with FPC
  11. 1.b; with Lazarus
  12. 2. Setup
  13. 2.a; as CGI
  14. 2.b; as Apache module
  15. 2.c; as FCGI
  16. =====================
  17. 1. Compiling:
  18. -------------
  19. We can either use FPC directly, or Lazarus to compile the CGI/FCGI/Apache
  20. module application. The main project .lpr file, as well as the Lazarus .lpi is
  21. in the cgi/fcgi/apache directories.
  22. 1.a; with FPC
  23. -------------
  24. Go to the directory (cgi/fcgi/apache) that has the .lpr file you wish to
  25. compile, and then execute the command
  26. fpc -Fu../webmodule echo.lpr
  27. The -Fu parameter shows FPC where to find the web module source code. All
  28. three web applications share the same web module code.
  29. 1.b; with Lazarus
  30. -----------------
  31. The example needs the WebLaz Package installed.
  32. If that is done, open the .lpi file from the choosen application directory
  33. (cgi/fcgi/apache), and then
  34. Run -> Build from the menu.
  35. 2. Setup:
  36. ---------
  37. 2.a; as CGI
  38. -----------
  39. http://<WebServer>/cgi-bin/<CGIExecutableName>/ should start the example if
  40. everything is set up properly.
  41. example: http://127.0.0.1:8080/cgi-bin/echo.exe/
  42. Note: You need to change the CGI application name if needed (for example, on
  43. Linux it is not echo.exe).
  44. Also, if your server is listening on port 80 instead of 8080, you can leave
  45. the :8080 part from the calling URL.
  46. 2.b; as Apache module
  47. ---------------------
  48. http://<WebServer>/<ApacheLocationName>/ should start the example if
  49. everything is set up properly.
  50. ex: http://127.0.0.1:8080/myapache/
  51. An example for the needed Apache configuration file (example: httpd.conf) snippet:
  52. LoadModule mod_echo "<path_to_mod>/echo.dll"
  53. <Location /myapache>
  54. SetHandler mod_echo
  55. Order allow,deny
  56. Allow from all
  57. </Location>
  58. Note: You need to change the module name if needed. For example on Linux,
  59. the module can be libecho.so or just simply libecho and not echo.dll .
  60. Note: If you recompile an Apache module while the module itself is loaded into
  61. the Apache server, the compilation will fail, because the file is in use
  62. (Apache modules stay in memory).
  63. So first, you always need to stop the Apache server before you recompile
  64. or before you copy over the new version of the created module.
  65. 2.c; as FCGI
  66. ------------
  67. http://<WebServer>/<ApacheScriptAliasName>/ should start the example if
  68. everything is set up properly.
  69. ex: http://127.0.0.1:8080/myfcgi/
  70. An example for the needed Apache configuration file (example: httpd.conf) snippet:
  71. LoadModule fastcgi_module "<path_to_mod>/mod_fastcgi-2.4.6-AP22.dll"
  72. <IfModule mod_fastcgi.c>
  73. <Directory "<path_to_fcgi_app>">
  74. # Options +ExecCGI <- not needed if ScriptAlias is used below
  75. Order allow,deny
  76. Allow from all
  77. </Directory>
  78. #External FCGI app, has to start manually, Apache will not do it
  79. FastCgiExternalServer "<path_to_fcgi_app>/echo.exe" -host 127.0.0.1:2015 -idle-timeout 30 -flush
  80. #optionally, to shorten the calling URL and to not display the executable file name (if used, no +ExecCGI is needed above)
  81. ScriptAlias /myfcgi "<path_to_fcgi_app>/echo.exe"
  82. </IfModule>
  83. Note: You need to change the module name if needed. For example on Linux,
  84. the module is not mod_fastcgi-2.4.6-AP22.dll but mod_fastcgi.so (needs to be
  85. compiled from sources found at http://www.fastcgi.com/dist/ ).
  86. The port (2015 in this example) must match the one set in the project main
  87. file (echo.lpr).
  88. The FCGI application must be running in order for this demo to work (external
  89. FCGI server setup). Do not forget to restart it after changes and
  90. recompilation.
  91. Also, mod_fastcgi is not the same as mod_fcgid that the Apache project is
  92. developing. The latter does not support external FCGI server apps.
  93. There are other ways than external FCGI server apps to handle the FCGI
  94. protocol and both mod_fastcgi and mod_fcgid supports that. However, external
  95. FCGI servers are the best for debugging and development, that is why the
  96. examples do it that way.