Recent

Author Topic: Apache module compiling with 0.9.26  (Read 19184 times)

sandeep_c24

  • Full Member
  • ***
  • Posts: 114
Apache module compiling with 0.9.26
« on: February 14, 2009, 03:08:25 am »
I am trying to write apache module using Lazarus 0.9.26 and I followed the instructions on the page

http://wiki.lazarus.freepascal.org/FPC_and_Apache_Modules#Advantages_of_writing_a_Apache_module_on_Free_Pascal

But for some reason the httpd file linked in is for http13 and not httpd22.

Has anyone ever managed to get this to work, please help if have.

Sandeep

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: Apache module compiling with 0.9.26
« Reply #1 on: February 14, 2009, 08:36:18 am »
Did you choose the version using a define? Or is that choice made in your fpc.cfg?

sandeep_c24

  • Full Member
  • ***
  • Posts: 114
Re: Apache module compiling with 0.9.26
« Reply #2 on: February 14, 2009, 09:52:21 am »
I didn't change anything in fpc.cfg, it used default settings.

Sandeep

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: Apache module compiling with 0.9.26
« Reply #3 on: February 14, 2009, 08:58:48 pm »
Can you look at the fpc.cfg to make sure you are using the right httpd units dir?

sandeep_c24

  • Full Member
  • ***
  • Posts: 114
Re: Apache module compiling with 0.9.26
« Reply #4 on: February 15, 2009, 04:08:00 am »
This is what the fpc.cfg looks like

#IFDEF FPCAPACHE_1_13
-Fuc:\lazarus0926\fpc\2.2.2/units/$FPCTARGET/httpd-1.3/
#ELSE
#IFDEF FPCAPACHE_2_0
-Fuc:\lazarus0926\fpc\2.2.2/units/$FPCTARGET/httpd-2.0
#ELSE
-Fuc:\lazarus0926\fpc\2.2.2/units/$FPCTARGET/httpd-2.2
#ENDIF
#ENDIF


Could you please tell what I need to change to use 2.2 and what do I need to recompile for this to work.

Sandeep

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: Apache module compiling with 0.9.26
« Reply #5 on: February 15, 2009, 09:55:43 am »
The directory name is wrong, it does not contain hyphen (-) or dot (.).

So it should be:
Code: [Select]
#IFDEF FPCAPACHE_1_13
-Fuc:\lazarus0926\fpc\2.2.2/units/$FPCTARGET/httpd13
#ELSE
#IFDEF FPCAPACHE_2_0
-Fuc:\lazarus0926\fpc\2.2.2/units/$FPCTARGET/httpd20
#ELSE
-Fuc:\lazarus0926\fpc\2.2.2/units/$FPCTARGET/httpd22
#ENDIF
#ENDIF

If that doesn't work, you may need to remove the httpd13 and httpd20 directories, so that the compile cannot find the units in those directories.

sandeep_c24

  • Full Member
  • ***
  • Posts: 114
Re: Apache module compiling with 0.9.26
« Reply #6 on: February 15, 2009, 11:45:58 am »
Deleting those folders helped.

I can get mod_hello example to work properly.

I am now trying a simple apache module created using Lazarus and it just hangs. After debugging I found the app hangs in procedure  GetAWebModule;

      if (M=nil) then
      begin
        M:=MC.Create(Self);<-- This is the line where it hangs
        M.Name := '';
      end;

What should I try now?

Sandeep



Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: Apache module compiling with 0.9.26
« Reply #7 on: February 15, 2009, 11:51:01 am »
No idea.

sandeep_c24

  • Full Member
  • ***
  • Posts: 114
Re: Apache module compiling with 0.9.26
« Reply #8 on: February 15, 2009, 11:55:27 am »
Is apache module working with TFPWebModule in any version of FPC?

Sandeep

bobo

  • Full Member
  • ***
  • Posts: 171
Re: Apache module compiling with 0.9.26
« Reply #9 on: February 16, 2009, 04:00:43 am »
No, with 0.9.26
Yes, with the latest SVN for fpc and lazarus they should work with apache 2.2

You have to make sure that you are using the right httpd22 directory in your project and not the httpd13 or httpd20 ones for your compilations.

I didn't play with apache modules for a few months, but all bug reports and patches are done now in this area.
(0012373, 0012374, 0012375, 0012389, etc.)
« Last Edit: February 16, 2009, 04:02:50 am by bobo »

sandeep_c24

  • Full Member
  • ***
  • Posts: 114
Re: Apache module compiling with 0.9.26
« Reply #10 on: February 16, 2009, 11:13:17 am »
The example on page

http://wiki.lazarus.freepascal.org/FPC_and_Apache_Modules#Hello_World_Module

works fine on windows but it doe not work at all on Linux. I can compile it but when I restart apache I get an error about tes_module not in the so.

Has anyone been able to get this to work on linux?

Regards

Sandeep

bobo

  • Full Member
  • ***
  • Posts: 171
Re: Apache module compiling with 0.9.26
« Reply #11 on: February 16, 2009, 10:09:12 pm »
The wiki is not up to date with the latest changes.

For example:
{$ifdef WINDOWS}
exports
 test_module name 'test_module';
{$endif}

is not correct because it is supported under Linux now. Should be

exports test_module name 'test_module';

(note: The module name must be the same as the exports name)
In the latest FPC SVN checkout /packages/httpd22/examples/mod_hello.pp contains the correct code.

Also, for apache modules using fpApache, fpWeb, lazweb the main program's first uses clause should look like
.
.
.
uses
{$ifdef unix}
  cthreads,
{$endif}
.
.
.

This is also included in the latest Lazarus SVN so theoretically it should be there when someone creates a new apache module from Lazarus.
« Last Edit: February 16, 2009, 10:16:39 pm by bobo »

sandeep_c24

  • Full Member
  • ***
  • Posts: 114
Re: Apache module compiling with 0.9.26
« Reply #12 on: February 17, 2009, 08:53:01 am »
Hi bobo

After doing the changes as suggested by you, the apache server now starts. The problem now I have is that the page is not visible when I go to http://localhost/pmod.
____________________________________________________
This is the log in apache error log
Heap dump by heaptrc unit
20 memory blocks allocated : 1282/1320
20 memory blocks freed     : 1282/1320
0 unfreed memory blocks : 0
True heap size : 360448
True free heap : 360448
____________________________________________________


I am using Lazarus 0.9.26.

Sandeep
« Last Edit: February 17, 2009, 09:06:21 am by sandeep_c24 »

bobo

  • Full Member
  • ***
  • Posts: 171
Re: Apache module compiling with 0.9.26
« Reply #13 on: February 17, 2009, 09:55:58 am »
I dont think itll work with 0.9.26 , the patches I listed previously are not applied in there. You need to both compile the latest FPC and Lazarus from SVN source.

sandeep_c24

  • Full Member
  • ***
  • Posts: 114
Re: Apache module compiling with 0.9.26
« Reply #14 on: February 17, 2009, 09:58:00 am »
Where can I download the latest version for Kubuntu. I am new to linux and Lazarus.

I think I should download using SVN so that I can keep things up to date. Is there any tutorial on this?

Sandeep
« Last Edit: February 17, 2009, 10:38:21 pm by sandeep_c24 »

 

TinyPortal © 2005-2018