473,396 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Custom php handler using Apache's mod_actions

Hi folks,

i have a problem using a PHP script as a custom handler in Apache.
What i wanna do is this:

Whenever a .html file is requested by a browser, i want Apache to call a
CGI that outputs a header, then the requested file and then a footer.
I want to use PHP for this, as i also want to do some template parsing.

Well, basically, this can be done using Apache's mod_action module,
where a custom handler can be defined for a certain filetype.
This does work correctly. If i request a .html file, the handler is
activated.

The strange thing is this: PHP does not output anything but the html header!

This is my custom handler file:
------------<htmlhandler.cgi>---------------
#!/bin/bash
/usr/bin/php-cgi test.php
--------------------------------------------

You see, php-cgi is called to execute test.php, which looks like this:

------------<test.php>----------------------
<?php
phpinfo();
?>
--------------------------------------------

So, what i would expect is, that the PHP info page is being sent to the
browser, which is not the case. All that is sent back is the .html file
i requested. And the strange thing is: If i execute the CGI from
commandline, i get all the phpinfo output! It just doesn't work when
called by apache!

You might think that the handler is not activated at all, but it is,
because if i change something in the custom handler config, like
spelling the filename wrong, i get a server error.

Also, i tried this using php-cgi directly, like this:

------------<htmlhandler.cgi>---------------
#!/usr/bin/php-cgi
<?php
phpinfo();
?>
--------------------------------------------
Which just gives me back the exact same results (just the requested
..html file).
Now for the funny part:
I also tried to do this using bash commands, like this:
------------<htmlhandler.cgi>---------------
#!/bin/bash
echo "Content-Type: text/html"
echo ""
echo "Hello World"
--------------------------------------------

This one works!! Hello world is being sent to the browser!

I am quite desperate, don't know what's left to try. Any ideas?
By the way, i'm using Apache 2.0.40 and PHP 3.3.8.


Thanks in Advance,

Tobias
Jul 17 '05 #1
2 3206
Hi again,
By the way, i'm using Apache 2.0.40 and PHP 3.3.8.

4.3.8 that is, as you might have figured out already ;)

greets

Tobias
Jul 17 '05 #2
> Whenever a .html file is requested by a browser, i want Apache to call a
CGI that outputs a header, then the requested file and then a footer.
I want to use PHP for this, as i also want to do some template parsing.


Does it have to be a cgi that calls a PHP file? Can it just call a PHP file
directly?
If so, you can use the directives:

auto_prepend_file
auto_append_file

for the header and footer respectively --

____________________________________
Wil Moore III, MCP | Integrations Specialist
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Randell D. | last post by:
Folks, I've never implemented a secure server before - and I now have a project for it - It will be an Apache 1.3 environment tuned with PHP and MySQL - and I'd appreciate any...
2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
3
by: Ryan Riehle | last post by:
Hi All! Trying to upgrade to Apache 2.0.49 and getting compile errors related to mod_auth_pgsql, any clue?: make: Entering directory `/usr/src/httpd-2.0.49'...
5
by: voronwae | last post by:
Hi folks. Either I'm missing something really obvious (most likely) or I'm missing something really subtle. I've been building up a machine as an IMP webmail server, with php 5.1.2, cyrus-sasl,...
11
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package...
6
by: MaiyaHolliday | last post by:
Hello, I've recently installed apache on a new computer, and cannot figure out why my site will not process any includes. (it was working on my old one) There are no errors on the page such as...
27
by: parashar123 | last post by:
There are two pl files: realtimechart.pl and realtimedemo.pl realtimechart generates a realtime graph which would an image file(png,gif,jpeg etc) and realtimedemo generates a html file alongwith...
22
by: parashar123 | last post by:
Trying to solve the issue, I found one thing which is not there in my Apache version and that might be affecting the result LoadModule perl_module modules/mod_perl.so in httpd.conf file But for...
6
by: josequinonesii | last post by:
I've searched, I've read, I've tested and re-read numerous post but to no avail yet... Quite simply, the settings I've applied to my httpd.conf, httpd-vhost.conf and my hosts files simply does not...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.