Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enable php in httpd

Status
Not open for further replies.

sarm

Programmer
Aug 13, 2001
77
US
Hello,
What is required in my httpd file to enable php files to work.

Thanks
 
In addition to the above how do I find the version of php installed on my system.
Thanks
 
You need the LoadModule line and the AddType application/x-httpd-php .php line. Then you can run a PHP file that would look like this:
<?php
phpinfo();
?>
That would print a lot of info about your PHP build. //Daniel
 
Hi,

You need the following lines in each of the relevant sections of httpd.conf :

LoadModule php4_module modules/libphp4.so

AddModule mod_php4.c

AddType application/x-httpd-php .php .php4


A test page would be as mentioned by danielhozac but it needs html wrapped around it :

<!- PHPtest.php -->
<html>
<body>
<?php
phpinfo()
?>
</body>
</html>


Incidentally, the 'modules/libphp4.so' shown above on LoadModule would be OK on redhat linux but you may need to change it a bit for your installation. It respresents the relative path to the module based on ServerRoot. Also if its win32, it would be a .dll and not a .so .

Hope this helps



 
I wish it were that simple in my case.

I've got all the requisite entries in httpd.conf. The &quot;LoadModule&quot; entry points to the right place. However, PHP is still not working.

I have the following file on my server.

Code:
<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
  <p>This sentence should be visible if regular HTML is processed corrrectly.</p>
  <?php echo &quot;<p>This sentence should be visible if PHP code is processed correctly.</p>&quot;; ?>
 </body>
</html>

When I view the page, the title and first line are visible. The second line is not visible.
 
What is that file called? What version are you using? Do you get any errors in your error_log? //Daniel
 
Did you compile apache with DSO support?

Did you compile PHP with apache support?

If you didn't, then I promise that php won't work properly... Also, what versions of Php and Apache are you using?

Thomas
 
I'm one for diagnosing and fixing a problem. But someone's put together a nice php+mysql+apache package for windows. You can download it here:

Not as good as a real fix, but should be a good start towards a solution ;-)

(and phpinfo() provides it's own HTML, and even a couple HTTP headers) --
JR
 
The file is called &quot;hello.php&quot;. I am using Apache 1.3.23, PHP 4.1.2, and RedHat Linux 7.2. The Apache server was compiled with DSO support and PHP was compiled with Apache support. Nothing's showing up in error_log.
 
OK, this is odd. I restarted Apache and got this response:

Code:
Syntax error on line 205 of /usr/local/apache/conf/httpd.conf:
Invalid command 'LoadModule', perhaps mis-spelled or defind by a module not included in the server configuration
/usr/local/apache/bin/apachectl start: httpd could not be started

I also got this entry in my error_log file:

Code:
[Mon Feb 24 11:02:29 2003] [alert] httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Mon Feb 24 11:02:29 2003] [crit] (98)Address already in use: make_sock: could not bind to port 80
 
The [tt]LoadModule[/tt] error sure makes it look like you didn't compile Apache with DSO support. //Daniel
 
OK, I re-configured and re-compiled everything. I'm no longer getting the &quot;LoadModule&quot; error message, and DSO support seems to be functional...I think.

Code:
$ httpd -l

Compiled-in modules:
  http_core.c
  mod_so.c
suexec: disabled; invalid wrapper /usr/local/apache/bin/suexec

Still the same problem: I can see the plain HTML portion of hello.php, but not the PHP output.
 
And you have the correct [tt]AddType[/tt] line in your [tt]httpd.conf[/tt]? //Daniel
 
Here's the pertinent entries in my httpd.conf:

Code:
LoadModule php4_module        libexec/libphp4.so

AddModule mod_php4.c

AddType application/x-httpd-php .php
 
The problem is solved now. I knew it would be something that would cause me to slap myself in the forehead hard.

I rebooted the machine, then restarted httpd. That's all. I can now see the PHP output. I never knew plain text could be so beautiful.

Pardon me while I go take an aspirin. :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top