compiling apache mod_hello lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- mobilevil · 2017-08-06 15:21 hello I am new to lazarus and seems I am messing with some simple setup issue instead of a real programming issue. I am using Lazarus 1.8 RC3. I played around with delphi apache module support many many years ago and now I want to make something with lazarus. I have some success with APACHE + CGI, and then I want to move to apache module. I found the httpd24 folder in C:\lazarus\fpc\3.0.2\source\packages\httpd24 but I don't know how to build it 1: seems the documentation is pretty outdated. it doesn't cover apache 2.4 but I tried it out anyway, http://wiki.lazarus.freepascal.org/FPC_and_Apache_Modules I tried to copy the content of mod_hello.pp into a new dll project and added the paths to "Other Unit Files". I duplicated the settings to "Other sources" but lazarus complains about duplication and removed it. the build failed with APR_HOOK_MIDDLE not found.   ap_hook_handler(@DefaultHandler, nil, nil, APR_HOOK_MIDDLE); then I noticed that there's a make file in the folder so I tried it as well, failed also. I have set the environment FPCDIR and added fpc to path C:\lazarus\fpc\3.0.2\bin\x86_64-win64; FPCDIR=C:\lazarus\fpc\3.0.2 C:\lazarus\fpc\3.0.2\source\packages\httpd24>make C:/lazarus/fpc/3.0.2/bin/x86_64-win64/ppcx64.exe fpmake.pp -n Fatal: Can't find unit system used by fpmake Fatal: Compilation aborted make: *** [fpmake.exe] Error 1 ---------------------------------------------------------------------- Leledumbo · 2017-08-06 16:24 Quote from: mobilevil on August 06, 2017, 05:21:07 pmC:\lazarus\fpc\3.0.2\source\packages\httpd24>make C:/lazarus/fpc/3.0.2/bin/x86_64-win64/ppcx64.exe fpmake.pp -n Fatal: Can't find unit system used by fpmake Fatal: Compilation aborted Build RTL first, call make in rtl folder. Anyway, units for apache interface should've been provided precompiled (go on check your fpc units folder). Haven't tried loading it to apache, but the sample mod_hello (long version) compiles straight on my fpc trunk. ---------------------------------------------------------------------- mobilevil · 2017-08-07 03:27 oh seems something was wrong in my mind. I didn't see the apache module project type in new project dialog, and the sample source really compiles when I paste them into a empty library project this morning in another PC. But they still have problems. I am using Lazarus 1.80 RC3 X64, and httpd-2.4.27-x64-vc14.zip from http://www.apachehaus.com/downloads/httpd-2.4.27-x64-vc14.zip for the new apache module project, I saved it and accepted the default project name mod_apache1, and noticed some compile error. Identifier not found "Application". I guess the Application object is only available in EXE project? I commented them out and it compiles fine. begin   {Application.Title:='mod_apache1';   Application.ModuleName:=ModuleName;   Application.HandlerName:=HandlerName;   Application.SetModuleRecord(DefaultModule);   Application.Initialize;} end. But apache still refuse to load the dll(renamed to .so) httpd: Syntax error on line 191 of C:/httpd-2.4.27-x64-vc14/Apache24/conf/httpd. conf: Cannot load modules/mod_apache1.so into server: The specified procedure could not be found. I am loading it like this LoadModule mod_apache1 modules/mod_apache1.so     SetHandler mod_apache1 I checked the output dll with Dll Export Viewer and see function mod_apache1 exported at address 0x000000011005c000 ordinal 1 for the sample code in http://wiki.lazarus.freepascal.org/FPC_and_Apache_Modules, it compiles fine this morning with another PC, but apache still refuse to load it with the same reason. Dll export viewer see the test_module function is exported at 0x000000011001f000 ordinal 1 I tried to change {$define Apache2_0} to Apache2_4 but it is still the same. I am loading it like this LoadModule test_module modules/mod_hello.so     SetHandler test_module ---------------------------------------------------------------------- mobilevil · 2017-08-07 03:42 checked with the echo example C:\lazarus\fpc\3.0.2\source\packages\fcl-web\examples\echo too, it doesn't compile complaining about it couldn't find the wmecho unit, but project inspector sees the wmecho.pas correctly, so I copied the files to another folder, removed wmecho.pas reference in the project and add it back again. They are now sitting in the same folder. build, and same identifier Application not found. comment out, and yes the dll is here. but apache still refuse to load it, same error, The specified procedure could not be found. i am using the config lines suggested by README of the echo project. LoadModule mod_echo modules/echo.dll     SetHandler mod_echo     Order allow,deny     Allow from all ---------------------------------------------------------------------- Leledumbo · 2017-08-07 04:35 Quote from: mobilevil on August 07, 2017, 05:27:22 amoh seems something was wrong in my mind. I didn't see the apache module project type in new project dialog There is none. Quote from: mobilevil on August 07, 2017, 05:27:22 am Identifier not found "Application". I guess the Application object is only available in EXE project? I commented them out and it compiles fine. It resides in custapache unit. Quote from: mobilevil on August 07, 2017, 05:27:22 am But apache still refuse to load the dll(renamed to .so) httpd: Syntax error on line 191 of C:/httpd-2.4.27-x64-vc14/Apache24/conf/httpd. conf: Cannot load modules/mod_apache1.so into server: The specified procedure could not be found. I am loading it like this LoadModule mod_apache1 modules/mod_apache1.so     SetHandler mod_apache1 First one is clear, syntax error in the httpd config file in apache itself. Second is out of my Apache knowledge. Quote from: mobilevil on August 07, 2017, 05:42:27 amchecked with the echo example C:\lazarus\fpc\3.0.2\source\packages\fcl- web\examples\echo too, it doesn't compile complaining about it couldn't find the wmecho unit, but project inspector sees the wmecho.pas correctly, so I copied the files to another folder, removed wmecho.pas reference in the project and add it back again. They are now sitting in the same folder. build, and same identifier Application not found. comment out, and yes the dll is here. but apache still refuse to load it, same error, The specified procedure could not be found. i am using the config lines suggested by README of the echo project. LoadModule mod_echo modules/echo.dll     SetHandler mod_echo     Order allow,deny     Allow from all Please report the compilation issue to bugtracker, the .lpi doesn't contain -Fu path to wmecho module and the .lpr is missing custapache unit in the uses clause (where the Application object resides). ---------------------------------------------------------------------- mobilevil · 2017-08-07 05:59 Hello, yes I figured out custapache too, but fpapache actually uses custapache, seems there is no need to manually uses it?(edit:ok i tested with simple project and confirmed that i have to use the unit directly to access it's variables. my pascal memory is getting thin) and for the apache conf file, it is not really syntax error. the line number is the first line I added, the LoadModule directive. Apache is trying to load the module and somehow it failed to find the entry point. while checking with the modules came with apache, I found that the address of the entry points are 32 bit?! but I the apache I am suing is a X64 build. maybe I will have to test with a 32bit build?? and for the bug report I think I will test with all other web related examples first. Thanks for your help. ---------------------------------------------------------------------- mobilevil · 2017-08-07 09:30 some progress. there are httpd13, httpd20, httpd22, and httpd24 folders in C:\lazarus\fpc\3.0.2\source\packages I can get apache to load my echo.dll if I change the uses from   httpd,fpApache,custapache;  to   httpd24,fpApache24,custapache24; but it crashes. from apache error log, An unhandled exception occurred at $1002B424: EHTTP: No REQUEST_METHOD passed from server.   $1002B424   $1000FE13   $10011220   $5FA742E5   $5FA735FD   $5FA83E24   $5FA83EA1   $5FA7E8BB   $5FA76955   $5FA767F2   $5FA9FF63   $7587336A   $77A69902   $77A698D5 maybe the echo module example is designe d for apache 2.2? so I made a build without the 24 in the units and tested with apache 2.2. the error is shown in the browser Error: Could not determine HTTP module for request "" Stack trace: $10010437 $1000FE77 $100111C0 $5FA82465 $5FA828E2 $5FA906AE $5FA8B2A2 $5FA85205 $5FA854F3 $5FAA07C7 $7016C556 $7016C600 $7587336A $77A69902 $77A698D5 ---------------------------------------------------------------------- mobilevil · 2017-08-07 10:09 the apache module project created from new project is working with apache 2.2. I added a action to FPWebModule1 and added some dummy response procedure TFPWebModule1.TFPWebAction0Request(Sender: TObject;   ARequest: TRequest; AResponse: TResponse; Var Handled: Boolean); begin   AResponse.Content:='hello';   Handled:=true; end;  but I coudln't get it to work with 2.4. I added 24 suffix to httpd, fpApache and custApache units, and added apr24 in case. I guess I am using the wrong lib, or the FPC apache 2.4 lib has a bug so it is not getting the correct parameter? An unhandled exception occurred at $0015B9C4: EHTTP: No REQUEST_METHOD passed from server.   $0015B9C4   $0013FEB3   $001412C0   $5FA742E5   $5FA735FD   $5FA83E24   $5FA83EA1   $5FA7E8BB   $5FA76955   $5FA767F2   $5FA9FF63   $7587336A   $77A69902   $77A698D5