Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-09

fpweb basic Apache module on Ubuntu not working

20 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ABorka

Hi,

I've created a basic apache module using Lazarus "file -> new -> apache module" (after adding the fpweb package/components to Lazarus), created a web action which replies with a '<html>hello</html>' and compiled it. However, when I try to load apache2 it says "Can't locate API module structure" at the httpd.conf line where the created module would be loaded: httpd.conf:

LoadModule mod_apache1 "/path to the module/mod_apache1" <Location /myapache>
SetHandler mod_apache1
Order allow,deny
Allow from all
</Location>

Tried both in Ubuntu 8.04 and latest Debian stable. It's the same in both. The same code compiled and run under windows is working. Used the latest trunk checkout for both FPC and Lazarus on Ubuntu.

Any suggestions to make the sample basic apache module work from Lazarus on Linux? Is it the same for anyone else?

AB

Reply by email

Michael Van Canneyt
to ABorka
ABorka wrote 15 lines
Hi, I've created a basic apache module using Lazarus "file -> new -> apache module" (after adding the fpweb package/components to Lazarus), created a web action which replies with a '<html>hello</html>' and compiled it. However, when I try to load apache2 it says "Can't locate API module structure" at the httpd.conf line where the created module would be loaded: httpd.conf: LoadModule mod_apache1 "/path to the module/mod_apache1" <Location /myapache> SetHandler mod_apache1 Order allow,deny Allow from all </Location>

1. Do you export the mod_apache1 structure ?
2. Are you using the correct apache units ?

Michael.

Reply by email

ABorka
to Michael Van Canneyt

Well, the real question is whether Lazarus does that correctly when one creates a vanilla apache module from the file menu and compiles it right away unchanged. On Linux it did not work for me, maybe someone else could confirm or deny.

Show quoted text 30 lines
On Sat, 20 Sep 2008, ABorka wrote: > Hi, > > I've created a basic apache module using Lazarus "file -> new -> apache > module" (after adding the fpweb package/components to Lazarus), created > a web action which replies with a '<html>hello</html>' and compiled it. > However, when I try to load apache2 it says "Can't locate API module > structure" at the httpd.conf line where the created module would be > loaded: > httpd.conf: > > LoadModule mod_apache1 "/path to the module/mod_apache1" > <Location /myapache> > SetHandler mod_apache1 > Order allow,deny > Allow from all > </Location> 1. Do you export the mod_apache1 structure ? 2. Are you using the correct apache units ? Michael. _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Michael Van Canneyt
to ABorka
ABorka wrote
Well, the real question is whether Lazarus does that correctly when one creates a vanilla apache module from the file menu and compiles it right away unchanged. On Linux it did not work for me, maybe someone else could confirm or deny.

Can you show the generated source ?

Michael.

Reply by email

ABorka
to Felipe Monteiro de Carvalho

Compiling the mod_hello.pp (to make mod_hello.so) from fpc/packages/httpd22/examples gives the same error even when all steps are done on the wiki page (project options, paths, etc.). Ubuntu 8.04 with Apache2.2, latest fpc/lazarus svn trunk

apache2: Syntax error on line 16 of /etc/apache2/apache2.conf: Can't locate API module structure `test_module' in file
/usr/lib/apache2/modules/mod_hello.so:
/usr/lib/apache2/modules/mod_hello.so: undefined symbol: test_module

Felipe Monteiro de Carvalho wrote

Reply by email

Michael Van Canneyt
to ABorka
ABorka wrote 9 lines
Compiling the mod_hello.pp (to make mod_hello.so) from fpc/packages/httpd22/examples gives the same error even when all steps are done on the wiki page (project options, paths, etc.). Ubuntu 8.04 with Apache2.2, latest fpc/lazarus svn trunk apache2: Syntax error on line 16 of /etc/apache2/apache2.conf: Can't locate API module structure `test_module' in file /usr/lib/apache2/modules/mod_hello.so: /usr/lib/apache2/modules/mod_hello.so: undefined symbol: test_module

in mod_hello, change the line

var
 test_module: module; public name 'hello_module';
to
var
 test_module: module; public name 'test_module';

and it should work.

Michael.

Reply by email

ABorka
to Michael Van Canneyt

Good catch (someone should fix it in SVN), but I get the same error even after doing this change.

Something else is the problem because if you create a new apache project that gives the same error.
Also, the same error happens when compiling the testmodule.pp example in fpc/packages/httpd22/examples.

apache2: Syntax error on line 17 of /etc/apache2/apache2.conf: Can't locate API module structure `test_module' in file
/usr/lib/apache2/modules/testmodule.so:
/usr/lib/apache2/modules/testmodule.so: undefined symbol: test_module

Any of these examples working for anyone on a 32bit Linux?

Michael Van Canneyt wrote 30 lines
On Sun, 21 Sep 2008, ABorka wrote: > Compiling the mod_hello.pp (to make mod_hello.so) from > fpc/packages/httpd22/examples gives the same error even when all steps > are done on the wiki page (project options, paths, etc.). > Ubuntu 8.04 with Apache2.2, latest fpc/lazarus svn trunk > > apache2: Syntax error on line 16 of /etc/apache2/apache2.conf: Can't > locate API module structure `test_module' in file > /usr/lib/apache2/modules/mod_hello.so: > /usr/lib/apache2/modules/mod_hello.so: undefined symbol: test_module in mod_hello, change the line var test_module: module; public name 'hello_module'; to var test_module: module; public name 'test_module'; and it should work. Michael. _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

ABorka
to ABorka

forgot to mention that for the testmodule.pp example I added

{*******************************************************************
* Test library of the Apache Pascal Headers
*******************************************************************} library testmodule;
{$DEFINE Apache2_2} <-- added this

to the top (this probably should be added to the SVN too for all examples that don't have it so by default compile for Apache 2.2)

ABorka wrote 51 lines
Good catch (someone should fix it in SVN), but I get the same error even after doing this change. Something else is the problem because if you create a new apache project that gives the same error. Also, the same error happens when compiling the testmodule.pp example in fpc/packages/httpd22/examples. apache2: Syntax error on line 17 of /etc/apache2/apache2.conf: Can't locate API module structure `test_module' in file /usr/lib/apache2/modules/testmodule.so: /usr/lib/apache2/modules/testmodule.so: undefined symbol: test_module Any of these examples working for anyone on a 32bit Linux? Michael Van Canneyt wrote: > On Sun, 21 Sep 2008, ABorka wrote: > >> Compiling the mod_hello.pp (to make mod_hello.so) from >> fpc/packages/httpd22/examples gives the same error even when all steps >> are done on the wiki page (project options, paths, etc.). >> Ubuntu 8.04 with Apache2.2, latest fpc/lazarus svn trunk >> >> apache2: Syntax error on line 16 of /etc/apache2/apache2.conf: Can't >> locate API module structure `test_module' in file >> /usr/lib/apache2/modules/mod_hello.so: >> /usr/lib/apache2/modules/mod_hello.so: undefined symbol: test_module > in mod_hello, change the line > > var > test_module: module; public name 'hello_module'; > to > > var > test_module: module; public name 'test_module'; > > and it should work. > > Michael. > _______________________________________________ > Lazarus mailing list > > http://www.lazarus.freepascal.org/mailman/listinfo/lazarus > _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Felipe Monteiro de Carvalho
to ABorka
Any of these examples working for anyone on a 32bit Linux?

They worked for me when I wrote the headers. I don't know why they stoped working.

Felipe Monteiro de Carvalho

Reply by email

Michael Van Canneyt
to ABorka: forgot to mention that for the testmodule.pp example I added…
ABorka wrote 10 lines
forgot to mention that for the testmodule.pp example I added {******************************************************************* * Test library of the Apache Pascal Headers *******************************************************************} library testmodule; {$DEFINE Apache2_2} <-- added this to the top (this probably should be added to the SVN too for all examples that don't have it so by default compile for Apache 2.2)

There is no need for this; it won't help you in any way. The define should be in the fpc.cfg file.

Michael.

Show quoted text 60 lines
ABorka wrote: > Good catch (someone should fix it in SVN), but I get the same error even > after doing this change. > > Something else is the problem because if you create a new apache project > that gives the same error. > Also, the same error happens when compiling the testmodule.pp example in > fpc/packages/httpd22/examples. > > apache2: Syntax error on line 17 of /etc/apache2/apache2.conf: Can't > locate API module structure `test_module' in file > /usr/lib/apache2/modules/testmodule.so: > /usr/lib/apache2/modules/testmodule.so: undefined symbol: test_module > > Any of these examples working for anyone on a 32bit Linux? > > > Michael Van Canneyt wrote: >> On Sun, 21 Sep 2008, ABorka wrote: >> >>> Compiling the mod_hello.pp (to make mod_hello.so) from >>> fpc/packages/httpd22/examples gives the same error even when all steps >>> are done on the wiki page (project options, paths, etc.). >>> Ubuntu 8.04 with Apache2.2, latest fpc/lazarus svn trunk >>> >>> apache2: Syntax error on line 16 of /etc/apache2/apache2.conf: Can't >>> locate API module structure `test_module' in file >>> /usr/lib/apache2/modules/mod_hello.so: >>> /usr/lib/apache2/modules/mod_hello.so: undefined symbol: test_module >> in mod_hello, change the line >> >> var >> test_module: module; public name 'hello_module'; >> to >> >> var >> test_module: module; public name 'test_module'; >> >> and it should work. >> >> Michael. >> _______________________________________________ >> Lazarus mailing list >> >> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus >> > > _______________________________________________ > Lazarus mailing list > > http://www.lazarus.freepascal.org/mailman/listinfo/lazarus > _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Felipe Monteiro de Carvalho
to Michael Van Canneyt
Michael Van Canneyt wrote
There is no need for this; it won't help you in any way. The define should be in the fpc.cfg file.

This shouldn't be necessary in fpc.cfg, because apache 2.2 is the default one.

Some older examples have this define to keep source which works with many versions of apache, before this define system was added.

Felipe Monteiro de Carvalho

Reply by email

ABorka
to Felipe Monteiro de Carvalho: On Mon, Sep 22, 2008 at 3:43 AM, Michael Van Canneyt This shouldn't be necessary in…

How can we check which one is the default in Lazarus?

Right now both in /fcl/packages/httpd20/examples and /fcl/packages/httpd22/examples the define.inc sets it to APACHE20 by default. And this define.inc is included in the examples except mod_hello.pp where it is set to apache22 in the code.

on Windows in the installed Lazarus the
\Lazarus\fpc\2.2.3\bin\i386-win32\fpc.cfg after install it has:

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

(same in the samplecfg file on Linux if someone compiles fpc from source) Is it using the 3rd entry by default?
In the Ubuntu apt-get install /etc/fpc.cfg there's no apache setting.

What is the default if there is no fpc.cfg? Which httpd.o and .ppu will Lazarus use (/httpd20 or /httpd22)?

AB

Felipe Monteiro de Carvalho wrote 10 lines
On Mon, Sep 22, 2008 at 3:43 AM, Michael Van Canneyt wrote: > There is no need for this; it won't help you in any way. > The define should be in the fpc.cfg file. This shouldn't be necessary in fpc.cfg, because apache 2.2 is the default one. Some older examples have this define to keep source which works with many versions of apache, before this define system was added.

Reply by email

ABorka
to Inoussa OUEDRAOGO: I once got a module working, modeled after the examples. There were a problem with a…

I am using the latest SVN source and the apache modules are not working on the current Apache 2.2.9 on Linux for some reason (Windows is OK).

btw, In the httpd2.pas for Delphi

   {$IFDEF MSWINDOWS}
   apr_off_t = Int64;
   {$EXTERNALSYM apr_off_t}
   {$ENDIF}
   {$IFDEF LINUX}
   apr_off_t = Integer;
   {$EXTERNALSYM apr_off_t}
   {$ENDIF}

in FPC, fpc/packages/httpd22/src/apr/apr.pas :

   apr_off_t = Int64;

in Apache 2.2.9 source code apr.hw

#if APR_HAS_LARGE_FILES
typedef __int64 apr_off_t;
#else
typedef int apr_off_t;
#endif

Could it be that for Linux this - and maybe some other things - should be different than for Windows?

Currently apache modules work on windows for me from Lazarus/FPC but not on Linux.

AB

Inoussa OUEDRAOGO wrote 8 lines
> Any of these examples working for anyone on a 32bit Linux? I once got a module working, modeled after the examples. There were a problem with a typedef ( apr_off_t ) but it has been corrected, at least in fpc/trunk. See the wiki page for more info about apr_off_t ( http://wiki.freepascal.org/FPC_and_Apache_Modules#Bug_Reporting )

Reply by email

ABorka
to Felipe Monteiro de Carvalho: I tryed to reproduce the problem, but I am having trouble in my Linux partition, and I…

Don't tell me... I've spent 2 days to make Ubuntu on VMWare with fpc/lazarus work :)
Finally, now I can do some tests and compare both windows and linux. But there is always something to prevent me to go further in trying to enhance fpweb/fcl-web and develop a working apache module on Linux.

Felipe Monteiro de Carvalho wrote
I tryed to reproduce the problem, but I am having trouble in my Linux partition, and I can't get apache working.

Reply by email

ABorka
to Michael Van Canneyt: Can you show the generated source ? Michael.

Sorry, it seems I did not notice your question till now. Here is the project source:
====================================
Library mod_testapache1;

{$mode objfpc}{$H+}
Uses fpWeb,lazweb,httpd,fpApache, unit1;
Const

{ The following constant is used to export the module record. It must always match the name in the LoadModule statement in the apache configuration file(s). It is case sensitive !}

   ModuleName='mod_apache1';

{ The following constant is used to determine whether the module will handle a request. It should match the name in the SetHandler statement in the apache configuration file(s). It is not case sensitive. }

   HandlerName=ModuleName;

Var
DefaultModule : module; {$ifdef unix} public name ModuleName;{$endif unix}

{$ifdef windows}
Exports defaultmodule name ModuleName;
{$endif windows}
begin
   Application.Title:='mod_apache1';
   Application.ModuleName:=ModuleName;
   Application.HandlerName:=HandlerName;
   Application.SetModuleRecord(DefaultModule);
   Application.Initialize;
end.
======================================
When starting up apache2 in Ubuntu 8.04:

apache2: Syntax error on line 2 of /etc/apache2/apache2.conf: Can't locate API module structure `mod_apache1' in file .../mod_testapache1: .../mod_testapache1: undefined symbol: mod_apache1

apache2.conf entry:
LoadModule mod_apache1 "...path.../mod_testapache1" <Location /myapache>
SetHandler mod_apache1
Order allow,deny
Allow from all
</Location>

Michael Van Canneyt wrote 16 lines
On Sun, 21 Sep 2008, ABorka wrote: > Well, the real question is whether Lazarus does that correctly when one > creates a vanilla apache module from the file menu and compiles it right > away unchanged. On Linux it did not work for me, maybe someone else could > confirm or deny. Can you show the generated source ? Michael. _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email