There are already great articles and blog entries on creating Apache DSO's with Delphi and Intraweb (VCL for the Web) -
(here,
here, and
here).
These mainly discuss changes that need to be made to the HTTPD2.pas file.
The most important modifications are as follows (basing on D2007's HTTPD.pas file):
-
For Apache 2.0.63 (latest 2.0.x version):
change MODULE_MAGIC_NUMBER_MINOR's value to 4
-
For Apache 2.2.14:
change LibAPR's value to 'libpar-1.dll'
change MODULE_MAGIC_COOKIE's value to $041503232
change MODULE_MAGIC_NUMBER_MAJOR's value to 20051115
leave MODULE_MAGIC_NUMBER_MINOR's value at 0
IME, these changes are quite sufficient (though I'm no Apache guru)... ;-)
OTOH, I guess you may be better off making all suggested changes?
Anyway, that's not exactly what I wanted to write about.
I've always had problems with making changes to Apache's httpd.conf file.
After making the necessary changes, uploading the .so module, and restarting the Apache service,
I either got a "The requested operation has failed!" error
or a non-working location - the "Not Found" / "The requested URL /xyz was not found on this server." page.
So, let's take a look at this example project:
library project_name;
uses
ApacheTwoApp,
IWInitApacheTwo,
Main in 'Main.pas' {MainForm: TIWAppForm},
Server in 'ServerController.pas' {IWServerController: TIWServerControllerBase},
Session in 'UserSessionUnit.pas' {IWUserSession: TIWUserSessionBase};
{$E so}
{$R *.RES}
exports
apache_module name 'module_name';
begin
IWRun;
end.
Note the project's name - project_name, and the output extension - so.
The project will be compiled to the file project_name.so.
Note also the apache_module definition - module_name.
Obviously, you can change these names to anything you want to,
but these will appear later on and I wanted for them to be different.
Having this, the changes that need to be made to the httpd.conf file go as follows:
LoadModule module_name modules/project_name.so
<Location /module_path>
SetHandler project_name-handler
</Location>
In the above, we have:
-
A LoadModule directive that uses the apache_module name defined in the project file;
it points to the location of the module binary - project_name.so - that is usually copied to Apache's modules\ directory;
if LoadModule doesn't succeed (e.g. module_name is entered incorrectly),
the "The requested operation has failed!" error will appear.
-
A Location directive - it tells Apache that
if the user enters /module_path (e.g. http://127.0.0.1/module_path) after your site's address,
it should not look for the directory in htdocs\ (or Apache's document root directory),
but should redirect traffic to the handler defined in the SetHandler directive.
-
A SetHandler directive - this tells Apache, which module should handle requests with /module_path.
Note that we're using here the project's name (project_name) followed by -handler.
If this name is entered incorrectly, you'll get a "Not Found" page.
Oh, and BTW, note that when making changes to the file HTTPD2.pas
(obviously, on a copy in some other location than Delphi's source files),
you'll also need to pull out the ApacheTwoApp.pas file.
It will also need to be compiled after changes to HTTPD2's interface section.
Otherwise, you'll get this error (or something similar):
[DCC Error] project_name.dpr(9): F2051 Unit ApacheTwoApp was compiled with a different version of HTTPD2.MODULE_MAGIC_NUMBER_MAJOR.
HTH
Top
|