Fedora Linux Support Community & Resources Center
  #1  
Old 20th July 2010, 04:33 PM
Hidalgo Offline
Registered User
 
Join Date: Feb 2008
Location: Newmarket, Suffolk, UK
Posts: 6
linuxfedorafirefox
Apache does not output php

Hi everyone!

The following problem is baffling me. I have now blown Windows XP away completely and done a clean install into 80Gb hard disk (x86). I know that httpd is running and I've added the snippets to httpd.conf that output server status and server info to the web browser, so I can see that all the required PHP stuff is loaded. So something like http://localhost/server-info works fine but something like http://localhost/helloworld.htm produces the wrong output:

contents of helloworld.htm:

<?php>
print("hello world");
print(phpinfo());
<?>

This produces in web browser:

print("hello world"); print(phpinfo());

I have also tried changing localhost to 127.0.0.1 but same result.

Have I missed something? The following is my inventory of php-related software:

[root@localhost ~]# rpm -qa | grep php

php-5.2.6-2.fc8
phpMyAdmin-3.1.1-1.fc8
php-common-5.2.6-2.fc8
php-manual-en-20070617-1.fc8
php-mysql-5.2.6-2.fc8
php-cli-5.2.6-2.fc8
php-mbstring-5.2.6-2.fc8
php-mcrypt-5.2.6-2.fc8
php-Smarty-2.6.20-2.fc8
gphpedit-0.9.91-3.fc6
php-pdo-5.2.6-2.fc8

[root@localhost ~]#

here's what the same command lists for Apache:

[root@localhost ~]# rpm -qa | grep httpd

httpd-2.2.9-1.fc8
httpd-tools-2.2.9-1.fc8
httpd-manual-2.2.9-1.fc8

[root@localhost ~]#

I hope its something basic?!

Many thanks in anticipation
__________________
Do not adjust your mind; reality is at fault
Reply With Quote
  #2  
Old 20th July 2010, 05:13 PM
jpollard Offline
Registered User
 
Join Date: Aug 2009
Location: Waldorf, Maryland
Posts: 6,105
linuxfedorafirefox
Re: Apache does not output php

Is the SELinux boolean "httpd_builtin_scripting" enabled?

I'm not sure what enabled it on my system (whether it was done as part of
apache/php/.. installation or something else). But if it is off, scripting
is disabled...

You can see the value by "getsebool -a | grep httpd" which will show
all booleans related to web server use.
Reply With Quote
  #3  
Old 20th July 2010, 08:22 PM
pete_1967 Offline
Clueless in a Cuckooland
 
Join Date: Mar 2006
Location: Here now, elsewhere tomorrow.
Posts: 3,929
linuxfedorafirefox
Re: Apache does not output php

Quote:
Originally Posted by Hidalgo View Post
Hi everyone!

The following problem is baffling me. I have now blown Windows XP away completely and done a clean install into 80Gb hard disk (x86). I know that httpd is running and I've added the snippets to httpd.conf that output server status and server info to the web browser, so I can see that all the required PHP stuff is loaded. So something like http://localhost/server-info works fine but something like http://localhost/helloworld.htm produces the wrong output:

contents of helloworld.htm:

<?php>
print("hello world");
print(phpinfo());
<?>

This produces in web browser:

print("hello world"); print(phpinfo());

I have also tried changing localhost to 127.0.0.1 but same result.

Have I missed something? The following is my inventory of php-related software:

[root@localhost ~]# rpm -qa | grep php

php-5.2.6-2.fc8
phpMyAdmin-3.1.1-1.fc8
php-common-5.2.6-2.fc8
php-manual-en-20070617-1.fc8
php-mysql-5.2.6-2.fc8
php-cli-5.2.6-2.fc8
php-mbstring-5.2.6-2.fc8
php-mcrypt-5.2.6-2.fc8
php-Smarty-2.6.20-2.fc8
gphpedit-0.9.91-3.fc6
php-pdo-5.2.6-2.fc8

[root@localhost ~]#

here's what the same command lists for Apache:

[root@localhost ~]# rpm -qa | grep httpd

httpd-2.2.9-1.fc8
httpd-tools-2.2.9-1.fc8
httpd-manual-2.2.9-1.fc8

[root@localhost ~]#

I hope its something basic?!

Many thanks in anticipation
You have two options, and one error in your script, error first:
<?php starts, and ?> terminates php script block.
Second error is you don't print phpinfo(), it's a function that prints out php information so do phpinfo(); alone, drop the print preceding it.

Then to your two options:
1) rename your file to helloworld.php or
2) change the line 'AddHandler php5-script .php' to 'AddHandler php5-script .php .htm' in your /etc/httpd/conf.d/php.conf and restart the server

And last but not least, visit www.php.net and start reading the manuals.
__________________
A Drink is Not Just For Christmas - SaskyCom :thumb:


“Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime” so now go and...
RTFM FIRST: http://docs.fedoraproject.org/ & http://rute.2038bug.com/index.html.gz
Reply With Quote
  #4  
Old 20th July 2010, 08:22 PM
assen Offline
Registered User
 
Join Date: Oct 2008
Posts: 492
linuxfedorafirefox
Re: Apache does not output php

Hi,

Check your httpd.conf - Apache recognizes files by extensions, so .htm is probably of type text/html where Apache will not try to execute anything. Either rename file to .php or change the .htm handler in http.conf.

WWell,
Reply With Quote
  #5  
Old 21st July 2010, 02:48 AM
Hidalgo Offline
Registered User
 
Join Date: Feb 2008
Location: Newmarket, Suffolk, UK
Posts: 6
linuxfedorafirefox
Re: Apache does not output php

Thanks for that. In my case however, the problem was elsewhere as I have SELinux turned off (its a web development workstation and with SELinux turned on, my work rate would be severely hampered!).

Quote:
Originally Posted by jpollard View Post
Is the SELinux boolean "httpd_builtin_scripting" enabled?

I'm not sure what enabled it on my system (whether it was done as part of
apache/php/.. installation or something else). But if it is off, scripting
is disabled...

You can see the value by "getsebool -a | grep httpd" which will show
all booleans related to web server use.


---------- Post added at 05:43 PM CDT ---------- Previous post was at 05:00 PM CDT ----------

Of course!!! Its simply caused by me assuming that php blocks had XML-style delimiters. Changing to <?php
.
.
.
blah...
blah...
.
.
.
?>
solved the problem. This is what happens when you immerse yourself in too many different technologies - thanks!

-Richard Prangnell ("Hidalgo")
www.prangnell.co.uk

PS By the way, print(phpinfo()) works fine, although it is overkill in this instance as the function itself calls print(). But when things start to go wrong... I try anything!


Quote:
Originally Posted by pete_1967 View Post
You have two options, and one error in your script, error first:
<?php starts, and ?> terminates php script block.
Second error is you don't print phpinfo(), it's a function that prints out php information so do phpinfo(); alone, drop the print preceding it.

Then to your two options:
1) rename your file to helloworld.php or
2) change the line 'AddHandler php5-script .php' to 'AddHandler php5-script .php .htm' in your /etc/httpd/conf.d/php.conf and restart the server

And last but not least, visit www.php.net and start reading the manuals.


---------- Post added at 05:48 PM CDT ---------- Previous post was at 05:43 PM CDT ----------

Absolutely!

QUOTE=assen;1383440]Hi,

Check your httpd.conf - Apache recognizes files by extensions, so .htm is probably of type text/html where Apache will not try to execute anything. Either rename file to .php or change the .htm handler in http.conf.
[/QUOTE]
__________________
Do not adjust your mind; reality is at fault
Reply With Quote
Reply

Tags
apache, httpd, php

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Command display output on console and simultaneously save the command and its output satimis Linux Chat 10 1st August 2008 03:02 AM
output a file to ternimal but keep the output updated Saint Mike Using Fedora 2 30th December 2006 11:22 AM
Apache DUPLICATES output & execution. GrahamB Servers & Networking 4 24th June 2005 01:27 PM


Current GMT-time: 02:39 (Friday, 24-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat