Page 1 of 1

PHP script NOT working in Apache/Firefox

Posted: Wed Sep 05, 2007 10:52 am
by UnivKen
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi

OS               : Linux ( Xandros -> Debian ) 
Webserver     : Apache/1.3.33 (Debian GNU/Linux) 
Web-browser : Firefox 1.5.0.5

A simple PHP script doesn't work !!

[b]When invoked   in firefox browser:[/b]        http://localhost/php1.php
[b]its didn't execute but just provides two options ( radio buttons):  "[color=violet]Open with [/color]"   and [color=violet]"Save To Disk"[/color][/b]

Following is the php1.php script

Code: Select all

<?php
        echo "This is PHP script in Apache/Firefox !";
?>
I had modified the script as follows
-----------------------------------------

Code: Select all

<html>
<head>
<title>A simple  PHP script </title>
</head>
<body>
<b>
<?php
        echo "This is PHP script in Apache/Firefox  !";
?>
</b>
</body>
</html>

Again it didn't execute but provids those 2 options "Open with " and "Save To Disk" !!!!


univken

---------------------------------------
Registered Linux User = #450073


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Sep 05, 2007 10:57 am
by TheMoose
Sounds like Apache isn't configured to handle PHP files. You need to setup Apache to set the handler for PHP files to be the PHP engine.

RE: PHP script NOT working in Apache/Firefox

Posted: Thu Sep 06, 2007 12:50 pm
by UnivKen
Hi

Had uncommented the following two lines , in file : /etc/apache/httpd.conf
And restarted apache ; but still its not executing the php in browser.


AddType application/x-httpd-php .php php4 .php3 .phtml
AddType application/x-httpd-php-source .phps



- Univken
_________________

Posted: Thu Sep 06, 2007 1:21 pm
by VladSun
Try to add/uncoment these lines:

Code: Select all

AddModule  mod_php4.c
LoadModule php4_module  libexec/libphp4.so
Also check if the path libexec/libphp4.so is correct ...

RE: PHP script NOT working in Apache/Firefox

Posted: Thu Sep 06, 2007 3:18 pm
by UnivKen
Hi

After installing the Apache/PHP integration library module libapache-mod-php4 , PHP script executes successfully in the Browser / Apache server.

Code: Select all

#apt-get install libapache-mod-php4
However , this installation completed partially with error code 10 , which is explained in following Debian-Apache Bug tracking:
http://www.mail-archive.com/debian-apac ... 07417.html


Hence the following manual configuration are necessary:
1) Uncomment (or add) the following lines in /etc/apache/httpd.conf file:

Code: Select all

AddType application/x-httpd-php .php php4 .php3 .phtml
AddType application/x-httpd-php-source .phps
2) Add the following line in /etc/apache/httpd.conf file:

Code: Select all

AddModule mod_php4.c
3) Include the following line in /etc/apache/modules.conf file:

Code: Select all

LoadModule php4_module /usr/lib/apache/1.3/libphp4.so
4) Restart Apache:

Code: Select all

/etc/init.d/apache stop
/etc/init.d/apache start

And all is fine.

However , there is a small issue: when listing the files in the parent directory of script php1.php , the icon for php1.php ( or any other .php files) is "a Question mark icon" with properties as -> http://localhost/icons/unknown.gif

thanks for the suggestions !

Univken