LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-01-2008, 08:54 PM   #1
PatUbu
LQ Newbie
 
Registered: Aug 2008
Posts: 5

Rep: Reputation: 0
PHP not working


(running apache 2.2.8-1ubuntu0.3, ubuntu 8.04, firefox 3.01)
I installed apache, go to localhost and see my test page fine. Then I add a single line of php and it does not display (after Ctrl-r).

Any help is appreciated.
thx
Pat

Here is the html file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html401/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Hello</title>
</head>

<body>
<h1>It almost WORKS! file is at /var/www/index.html</h1>
<?php print "This text does not print"; ?>

more text (this prints fine)

</body></html>
 
Old 08-01-2008, 09:05 PM   #2
AdaHacker
Member
 
Registered: Oct 2001
Location: Brockport, NY
Distribution: Kubuntu
Posts: 384

Rep: Reputation: 31
Sounds to me like PHP either isn't installed or isn't enabled. Make sure you have the php5 package installed and that the php5.load file is properly linked to in your /etc/apache2/mods-enabled directory.
 
Old 08-01-2008, 09:18 PM   #3
PatUbu
LQ Newbie
 
Registered: Aug 2008
Posts: 5

Original Poster
Rep: Reputation: 0
I can link to php file but php code in html page not working

Doing more debugging, if I link to a file phpinfo.php that contains only the line <?php phpinfo(); ?>

this works and I get a nice (long) page of info. But my php code on html pages does not display anything.

Any ideas?
thx
Pat
 
Old 08-01-2008, 09:33 PM   #4
AdaHacker
Member
 
Registered: Oct 2001
Location: Brockport, NY
Distribution: Kubuntu
Posts: 384

Rep: Reputation: 31
What's the file extension on that file? If it's .html, then in the default configuration, Apache won't pass it to PHP at all. Use a .php extension instead. Or you can modify your Apache configuration to treat all .html files as PHP.
 
Old 08-01-2008, 09:38 PM   #5
PatUbu
LQ Newbie
 
Registered: Aug 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Doh!!

I was putting the php code in a file named index.html and the html worked fine but php was ignored. I renamed the file to index.php and it works great! I guess any file with php needs to have the .php extension.

thx
Pat
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't Get PHP Working JamesBo SUSE / openSUSE 2 11-30-2006 07:16 PM
Apache working, PHP not working xmrkite Linux - Server 1 10-08-2006 03:01 PM
PHP header("Location: xxx.php") not working? baddah Programming 7 05-10-2006 10:00 AM
PHP Not Working Right? johndmann Linux - Software 1 03-12-2006 03:08 PM
Help getting php working TheDirtyPenguin Linux - Software 12 03-19-2004 06:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration