Caves Travel Diving Graphics Mizar Texts Cuisine Lemkov Contact Map RSS Polski
Trybiks' Dive Texts Intraweb Intraweb as an Apache DSO module YAC Software
  Back

List

Charsets

Charts

DBExpress

Delphi

HTML

Intraweb

MSTest

PHP

Programming

R

Rhino Mocks

Software

Testing

UI Testing

VB.NET

VCL

WPF

Intraweb as an Apache DSO module
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

Comments
#1
Leandro wrote on 2014-08-21 15:37:59
hello,

My friend took a look at your post however can not understand very well.
It is possible to run the standalone compiling iw as .so in apache?

would like to give me a strength to do this, I'm willing to pay if necessary.

if you can do the project compiled as so run smoothly and be well paid.

hugs

contact,

Brazil
microgestror@gmail.com
551 11976519725

Top

Add a comment (fields with an asterisk are required)
Name / nick *
Mail (will remain hidden) *
Your website
Comment (no tags) *
Enter the text displayed below *
 

Top

Tags

Intraweb

Delphi


Related pages

Delphi interfaces... again

Checking "Dangling" Event Handlers in Delphi Forms

Drag-n-drop files onto the application window

Intraweb and MaxConnections

A Case for FreeAndNIL

"Device not supported" in Intraweb

Automated GUI Testing

Rounding and precision on the 8087 FPU

SessionTimeout in Intraweb

Using TChart with Intraweb

Unknown driver: MySQL

TIdMessage's CharSet

Software Guarantees

Automated Testing of Window Forms

TChart - Missing Labels in Axes

Memory Leaks and Connection Explosions in DBExpress

Controlling Conditional Defines and Compilation Switches

Detecting Memory Leaks with DUnit

last_insert_id() and DBExpress

Registering Extensions

DBExpress and Thread Safety

Forms as Frames

Checking Dangling Pointers vs. the New Memory Manager

</form> ... <form>

Accessing Protected Members

Objects, interfaces, and memory management in Delphi