LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 08-03-2005, 11:14 AM   #1
Tomo3000
LQ Newbie
 
Registered: Aug 2005
Posts: 4

Rep: Reputation: 0
Have installed PHP for Apache2 but source code showing


Hello there.

I wanted to start learning PHP today, so I blew away a box and performed a fresh SuSE 9.3 Pro installation. I selected "Simple Webserver with Apache2" and ensured that the package "apache2-mod_php4" was also ticked.

Now, I've started apache2 and, entering localhost as the URL, brought up the default page. So far, so good. Apache2 is running.

Then I created /srv/www/htdocs/index.html, put "Hello from HTML" (without the quotes) in the body part, and also inside the body put:

<?php echo "Hello from PHP"; ?>

Pressing refresh makes the html "hello" part of the page display, but not the php "hello". Viewing the page source code shows the php part as above, so Apache isn't recognising it as php, I'm guessing.

Surely, after installing the php4 modile, Apache should then recognise embedded php?

I've been through the /usr/share/doc/packages/php4/README.SuSE file and determined that the php4 module is loaded.

There must be something else I need to do to make Apache2 interpret the <?php ...?> section, but what?

I haven't tinkered with the installation in any other way.
 
Old 08-03-2005, 11:50 AM   #2
barrythai
Member
 
Registered: Dec 2004
Location: thailand
Distribution: suse9.3, Mandrake10.1
Posts: 381

Rep: Reputation: 30
you haven't got your php installed. You need to add the php modules if you are going to use mysql etc then you should also load the php-mysql etc.

After you have added your php rpm's you must reboot or restart apache.
 
Old 08-03-2005, 01:07 PM   #3
Tomo3000
LQ Newbie
 
Registered: Aug 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Actually, it's curious. To test that idea, I created index.php and pointed my browser at localhost/index.php and it works!

It's just that apache2 doesn't seem to want to process php embedded in html.

Any ideas?
 
Old 08-04-2005, 05:25 AM   #4
Tomo3000
LQ Newbie
 
Registered: Aug 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Got it!

I've solved it myself.

Instead of using index.html, use index.php and Apache2 correctly passes any embedded php to the php processor.

Job's a good 'un.
 
Old 08-04-2005, 07:14 PM   #5
barrythai
Member
 
Registered: Dec 2004
Location: thailand
Distribution: suse9.3, Mandrake10.1
Posts: 381

Rep: Reputation: 30
Guess I didn't read your original .html statement, because it was clear in your message the error. True you must use the index.php file which takes priority in your directory over the .html and .shtml.

Yes, I found that out myself and was confused too.

I think it should be made clearer in the docs to use php it must be in a .php file.

Another confusion I find is the include(somefilein.php):
this has to have <? code ?> and you just cannot have php code by itself.

I find it odd as it is php imbedded in php ie <?php code -include file called- <?php code ?> more php code ?>
I am sure there is a reason? I would have thought an include(file.php); would not need the self evident repetition?

Just wait until you start to use some of the graphics commands it fails to tell you that some of the code requires the BD graphics extensions, took two days to figure this out.


Last edited by barrythai; 08-04-2005 at 07:18 PM.
 
  


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
Apache2.0.52, t1lib-5.0.2, php-apache2-5.0.2 wizard7423 Slackware 2 04-04-2011 08:09 PM
Apache2: showing password protected directories hamish Linux - Software 7 11-15-2004 12:50 PM
how to uninstall apache2 which is installed by emerge apache2 flybirdlong Linux - Software 1 07-17-2004 11:46 AM
Remove program which installed by source code cccc Linux - Software 3 09-09-2003 01:24 PM
Apache2, php code parsed as *.shtml bmar Linux - General 4 06-29-2003 04:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 01:42 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
Open Source Consulting | Domain Registration