PHP script NOT working in Apache/Firefox

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
UnivKen
Forum Newbie
Posts: 4
Joined: Wed Sep 05, 2007 10:35 am

PHP script NOT working in Apache/Firefox

Post 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]
User avatar
TheMoose
Forum Contributor
Posts: 351
Joined: Tue May 23, 2006 10:42 am

Post 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.
UnivKen
Forum Newbie
Posts: 4
Joined: Wed Sep 05, 2007 10:35 am

RE: PHP script NOT working in Apache/Firefox

Post 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
_________________
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post 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 ...
There are 10 types of people in this world, those who understand binary and those who don't
UnivKen
Forum Newbie
Posts: 4
Joined: Wed Sep 05, 2007 10:35 am

RE: PHP script NOT working in Apache/Firefox

Post 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
Post Reply