LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-18-2011, 09:23 AM   #1
Shreeve
LQ Newbie
 
Registered: Oct 2011
Posts: 3

Rep: Reputation: Disabled
PHP not working properly with Apache home server


Hello everyone,

I recently decided to put my very old dell desktop computer to good use and teach myself about running a web server by learning how to set up a LAMP server.

Everything went well, i can access the default 'It Works!' website from anywhere.

When it came to attempting some php i followed the initial test by running the following script at 'http://[my-server-ip]/testphp.php':

Code:
<?php
  phpinfo ();
?>
That also worked perfectly and it gives tons of information as i'm sure it should.

I am currently running into 2 problems:

Firstly when i try to run a simple php script it doesn't seem to work properly, the following code:

Code:
<p>
<h1>Test</h1>
</p>

<?php
$my_number =6;
echo $my_number;
echo "<p>This is a php script</p>;
?>
Returns this page:

http://img850.imageshack.us/img850/8224/phpy.png

Secondly, when i try and run the exact same page with a .php extension instead of a .html extension i recieve the following page:

http://img204.imageshack.us/img204/7...rvererrorz.png

I am using Ubuntu 11.10, Apache2 and PHP5.

Sorry if i've missed off any information and i hope someone can help!
 
Old 10-18-2011, 02:09 PM   #2
JSkywalker
Member
 
Registered: Aug 2007
Distribution: openSUSE
Posts: 102

Rep: Reputation: 24
Quote:
echo "<p>This is a php script</p>;
the closing double-quote is missing.......

in your error log you can find a line like this (if you configured errors to be written to a file):
[18-Oct-2011 20:07:00] PHP Parse error: syntax error, unexpected $end in /tmp/test.php on line 10

Writing errors to a file can be done by adding a line to your PHP.INI like this:
error_log = /var/log/php-error.log (or to wherever you want this logfile to be.... )

Last edited by JSkywalker; 10-18-2011 at 02:12 PM. Reason: adding info....
 
Old 10-18-2011, 04:25 PM   #3
Shreeve
LQ Newbie
 
Registered: Oct 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
Very sorry, that was a typo on my part, the code looks exactly like this:

http://img189.imageshack.us/img189/4342/codemx.png

It seems to be completely ignoring the php and i'm stumped.

Thanks for the reply though.
 
Old 10-19-2011, 01:50 PM   #4
JSkywalker
Member
 
Registered: Aug 2007
Distribution: openSUSE
Posts: 102

Rep: Reputation: 24
add this to your Apache configuration:
Quote:
AddHandler application/x-httpd-php .php
DirectoryIndex index.php
see: http://httpd.apache.org/docs/2.0/mod...tml#addhandler
 
Old 10-19-2011, 04:24 PM   #5
Shreeve
LQ Newbie
 
Registered: Oct 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thank you!
 
  


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
pwauth is not working properly under Apache bombshell Linux - Server 0 12-27-2010 07:15 PM
php not working on apache server Beck24 Linux - Software 3 01-19-2006 02:12 AM
Apache httpd not loading php pages properly. queezythegreat Linux - Networking 0 09-26-2004 04:50 PM
PHP not working properly with redhat 9 tolindsey Linux - Newbie 3 07-23-2003 12:11 PM
apache or php doesn't work properly on RH8.0 abd_bela Linux - Networking 6 03-18-2003 06:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:03 PM.

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