LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-17-2004, 04:44 AM   #1
TheDirtyPenguin
Member
 
Registered: Feb 2004
Location: Leicester, UK
Distribution: suse 9 pro
Posts: 34

Rep: Reputation: 15
Help getting php working


Hi,

I wrote my first hello world php script last night, but when I viewed it in a web browser, all I got was a blank screen.

Apache was running at the time.

Is there something special I need to do to get php working? Should it already be installed?

Using Suse 9 Pro

Thanks
 
Old 03-17-2004, 05:21 AM   #2
andrewlkho
Member
 
Registered: Jul 2003
Location: London
Posts: 548

Rep: Reputation: 30
Okay, several things:
What do you get when you view the source of the page? I'm guessing that you get:

<html><body></body></html>

If so, then that's good - it means that php is functioning correctly. Then the problem is your code. Could you post your code? You should have something like:

<?php
echo 'Hello World!';
?>

hth
 
Old 03-17-2004, 10:42 AM   #3
shortfuse
Member
 
Registered: Feb 2004
Location: Texas
Distribution: Debian
Posts: 30

Rep: Reputation: 15
Your getting a blank screen because php is probably configured such that it willl not send error messages to the page. Check your Apache logs for errors.
 
Old 03-17-2004, 11:52 AM   #4
TheDirtyPenguin
Member
 
Registered: Feb 2004
Location: Leicester, UK
Distribution: suse 9 pro
Posts: 34

Original Poster
Rep: Reputation: 15
I dont get it!

Firstly I have just installed/reinstalled php. I did "./configure", then "make", then "make install" and everything went off happily and came back with no errors so I am asumming its I've now got it!

I restarted apache (whos logs are empty in /var/log/apache)

This is my script:

<?php
echo 'Hello World!';
?>

Which i wrote in vim and called hello.php

But when opened in Konquerer it just displays the whole thing.

The same for (written in vim, called test.php)

<?
phpinfo();
?>

This script displays nothing in Konquerer:

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>


Its perplexing me

Any ideas?
 
Old 03-17-2004, 12:03 PM   #5
TheDirtyPenguin
Member
 
Registered: Feb 2004
Location: Leicester, UK
Distribution: suse 9 pro
Posts: 34

Original Poster
Rep: Reputation: 15
I've just been reading some tutorials and one says that if you are prompted with a download box, (which I am using Mozilla, and Firefox) the php is not installed.

Do I need to configure something in apache or something?

I have also noticed in my /etc/init.d folder there is apache and apache2

Both startup and run but which one should I be running?

Sorry guys, I'm new to all this....

My brain hurts...

Last edited by TheDirtyPenguin; 03-17-2004 at 12:15 PM.
 
Old 03-17-2004, 12:25 PM   #6
shortfuse
Member
 
Registered: Feb 2004
Location: Texas
Distribution: Debian
Posts: 30

Rep: Reputation: 15
Sounds like mod_php may not be loaded, check your httpd.conf for lines like these:

LoadModule php4_module libexec/libphp4.so

AddType application/x-httpd-php .php
 
Old 03-17-2004, 12:31 PM   #7
shortfuse
Member
 
Registered: Feb 2004
Location: Texas
Distribution: Debian
Posts: 30

Rep: Reputation: 15
The main issue with Apache 2.x and php is with global vars, so if your gonna run 2.x then you may have to add this line to your php.ini file to get some code to work.

register_globals = On

Global vars can present some security issues and that's why this defaults to off but there's alot of php code in the world that still requires this to be on.
 
Old 03-17-2004, 12:52 PM   #8
TheDirtyPenguin
Member
 
Registered: Feb 2004
Location: Leicester, UK
Distribution: suse 9 pro
Posts: 34

Original Poster
Rep: Reputation: 15
Right then,

Thanks so far, I think I'm getting somewhere guys, stay with me.

I added the following to the httpd.conf file (scary file!)

LoadModule php4_module libexec/libphp4.so

AddModule mod_php4.c

(In the correct sections)

I've worked out that I'm NOT using apache2 because when I start apache I get the following error:

linux:/home/bryan # /etc/init.d/apache start
Starting httpd [ Mailman PHP4 susehelp_acl ]

Syntax error on line 262 of /etc/httpd/httpd.conf:
Cannot load /srv/www/libexec/libphp4.so into server: /srv/www/libexec/libphp4.so: cannot open shared object file: No such file or directory fail


So I am assuming something is wrong with libexec/libphp4.so

Where should I point the file to?

Nearly there!
 
Old 03-17-2004, 01:00 PM   #9
shortfuse
Member
 
Registered: Feb 2004
Location: Texas
Distribution: Debian
Posts: 30

Rep: Reputation: 15
Well either php4 isn't installed( may be another version? ) or the path is just wrong. Sorry I don't have any experience with SUSE so best I can do is tell you to:

cd /
find -name *mod_php*

If you find nothing then it's a safe bet that php isn't installed.
 
Old 03-17-2004, 01:08 PM   #10
TheDirtyPenguin
Member
 
Registered: Feb 2004
Location: Leicester, UK
Distribution: suse 9 pro
Posts: 34

Original Poster
Rep: Reputation: 15
Thats ok,

Thanks for your help though, I friend at work has a suse 9 machine with php working so I can just look at the path in that one. I'm 99% certain php is installed because I did it myself and if I do a "whereis php" i get:

php: /usr/bin/php /etc/php.ini /usr/local/bin/php /usr/local/lib/php /usr/share/php /usr/share/man/man1/php.1.gz

I'll just have to wait till the morning! If anyone has Suse and knows where to point me to please let me know.

Cookies all round for shortfuse and ho_10
 
Old 03-17-2004, 01:18 PM   #11
tintin825
LQ Newbie
 
Registered: Mar 2004
Distribution: debian
Posts: 3

Rep: Reputation: 0
Check out

http://www.php.net/manual/en/install.apache.php

This gives you all the things you need to do to get your php scripts working.

I hope this helps.
 
Old 03-17-2004, 02:58 PM   #12
andrewlkho
Member
 
Registered: Jul 2003
Location: London
Posts: 548

Rep: Reputation: 30
It sounds like apache wasn't installed with PHP support built-in - if you've got mod_so, then you should be able to add it in as a dynamic module. If not, then recompiling apache is what you've got to do...
 
Old 03-19-2004, 05:19 AM   #13
TheDirtyPenguin
Member
 
Registered: Feb 2004
Location: Leicester, UK
Distribution: suse 9 pro
Posts: 34

Original Poster
Rep: Reputation: 15
Woo hoo!

I was being a fool all along. I wasnt putting the .php files into /srv/www/htdocs so apache could see them. They didnt tell me that in the tutorials!

Doh.

Thanks for you help guys.

 
  


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
PHP not working eikeland Linux - Software 4 07-13-2005 07:00 PM
PHP not working SoftwareParadis Linux - Software 1 06-08-2003 03:02 PM
PHP Not working.. Dirt Linux - Newbie 1 06-06-2003 08:22 PM
PHP not working Tekime Slackware 6 08-22-2002 03:01 PM
PHP Not working? hubergeek Linux - Software 1 03-26-2002 10:29 AM


All times are GMT -5. The time now is 02:31 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