LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 04-16-2004, 09:59 AM   #1
maktos
LQ Newbie
 
Registered: Mar 2004
Location: Rockford IL
Distribution: Redhat 9
Posts: 7

Rep: Reputation: 0
PHP - What to add to Apache httpd.conf file?


I'm trying to get PHP to work on my linux server (It already works great on my Windows 2000 server - but that's a whole different distro of PHP of course...)

I added "AddType x-httpd-php .php" already
but PHP isn't an .so module, so where do I tell Apache about it?
How does it even know that there is a php.ini file in another directory?

I'm just wondering what I need to add in order for .PHP pages to function as PHP pages.

Thank you in advance,

Matthew
matt@tanbooks.com
 
Old 04-16-2004, 01:34 PM   #2
coolamit78
Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: RHEL AS 3/4, Windows XP
Posts: 546

Rep: Reputation: 31
Hi maktos,

To run php code with apache, just do this:

1. From CD-1 Red Hat 9, install the php-<version>*.rpm

2. In your httpd.conf, locate the 'DirectoryIndex' line which would be something like

DirectoryIndex index.html index.html.var

Just add 'index.php' at the end of the line

DirectoryIndex index.html index.html.var index.php

You wont need to add anything extra as the php.ini file loads all required modules automatically.

Now you are ready to test php!

create a file index.php under /var/www/html if you arent using virtual hosting. Otherwise, if you are using virtual hosting, then put index.php under /var/www/html/<your-domain-name>/

Creating a php file is quite simple too...just create a normal html file and embed php under it like this

<html>
<head>
<title> My PHP Page </title>
<?php PRINT "Hello World" ?>
</head>
</html>

Hope that helps...

Regards,

amit
 
Old 04-16-2004, 01:38 PM   #3
maktos
LQ Newbie
 
Registered: Mar 2004
Location: Rockford IL
Distribution: Redhat 9
Posts: 7

Original Poster
Rep: Reputation: 0
That works, but..

I have a message board program (much like this one) written in PHP. It works great on my Windows 2000 box with that version of PHP - but I get a "server error" when I run it on my linux box. I've set the directory and all files to user/group "apache", and I think everything has the right permissions.

Is permissions the only problem I should look into? I was just wanting to verify that PHP was correctly installed.

Does the "execute" bit even matter for PHP scripts?

Matthew
 
Old 04-16-2004, 01:49 PM   #4
coolamit78
Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: RHEL AS 3/4, Windows XP
Posts: 546

Rep: Reputation: 31
Well...I havent yet ventured into php much, but I think the execute bit wont matter here ( i'll have to confirm that, so right now its just a guess!)..

However, I'd like to know where do you get this "Server Error" ?...Is it right at where you launch index.php? or is it with some particular page? BTW where is index.php located ? Also, the execute permission for index.php may be a factor, so check that too..

Have u tried to execute a simple php script before trying to run your own program? Well, at least give the sample script a try and then let us know whats happening..

Regards,

amit
 
Old 04-16-2004, 01:58 PM   #5
maktos
LQ Newbie
 
Registered: Mar 2004
Location: Rockford IL
Distribution: Redhat 9
Posts: 7

Original Poster
Rep: Reputation: 0
Well....

It was one of those old errors, like if you forgot to set the execute bit on a perl program:

http://www.chantcd.com/cgi-bin/forum/index.php

But a simple PHP like this works, so it must have to do with the complexity, etc.
http://www.chantcd.com/test2.php

I wonder what I should look into next.....

Matthew
 
Old 04-16-2004, 02:09 PM   #6
strimp099
Member
 
Registered: Mar 2004
Location: Chicago
Distribution: Fedora 12
Posts: 56

Rep: Reputation: 15
It might have something to do with the fact you have to files stored in the cgi-bin directory. Look through the httpd.conf to read what it says about that directory. I tried putting php in there and it didn't work giving similar errors.
 
Old 04-16-2004, 02:14 PM   #7
maktos
LQ Newbie
 
Registered: Mar 2004
Location: Rockford IL
Distribution: Redhat 9
Posts: 7

Original Poster
Rep: Reputation: 0
So PHP should be kept in HTDOCS

In with your main files?

That was one of my main questions actually - I guess I was a bit confused in my thinking there - after all, a PHP is not a cgi script, not even "kind of".

Matthew
 
Old 04-16-2004, 02:19 PM   #8
coolamit78
Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: RHEL AS 3/4, Windows XP
Posts: 546

Rep: Reputation: 31
Well, to be frank, I wont be able to provide you with the exact solution, but I notice that apache isnt able to find index.php located under

http://www.chantcd.com/cgi-bin/forum/

I guess you will need to alias the above directory to /cgi-bin/ directory..

locate a line starting with 'ScriptAlias' in your httpd.conf, and try aliasing /cgi-bin/ with the above directory. So it would be something like

ScriptAlias /cgi-bin/ /var/www/html/cgi-bin/forum/

Try this..If this dosent work, wait for someone who can suggest u better..

Regards,

amit
 
Old 04-16-2004, 02:27 PM   #9
coolamit78
Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: RHEL AS 3/4, Windows XP
Posts: 546

Rep: Reputation: 31
Just an after-thought...may be having the forum in cgi-bin isnt the right location, as its a php forum....try moving it somewhere else...

may be like

http://www.chantcd.com/forum/index.php

Regards,

amit
 
Old 04-17-2004, 08:18 PM   #10
ECKHART.CURT
LQ Newbie
 
Registered: Aug 2003
Posts: 3

Rep: Reputation: 0
Are you still having trouble with this? I noticed that the links you supplied still don't work. I'll see if I can help you with this when I get back to my house and look at my setup.

Meanwhile, could you answer a few questions :
- What version of apache?
- What version of php?
- What distro are you using?

Also, could you post a bit of one of the pages that's not working? You also could try replacing one of the pages that doesn't work with one of your 'simple' pages that you've posted that will work. Save away the 'real' page and replace it with a page that you know works under that same directory and filename. That way, you can eliminate issues like what directory it's in and some of the bit twiddling questions that you have. I'm guessing that your page is using some facility like database access or similar that you don't have set up on your new machine.

I'll look back into this forum in an hour or so when I get home from work to see if you've made any replies. It will be late Sunday before I can check back after that.

I'm sure I can help you at least figure out what's going on, and we may actually be able to fix it. :-)


Curt
 
  


Reply



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
Restoring Apache httpd.conf file shof515 Fedora 1 11-24-2005 10:54 PM
Apache httpd.conf file?? matux Mandriva 2 01-28-2005 09:20 AM
Fedora 1, Apache, httpd.conf file Turner Linux - Newbie 2 07-07-2004 12:11 PM
Red Hat 9 server can't write PHP script, problem in httpd.conf file? x_menno_x Linux - Newbie 27 06-29-2004 04:44 PM
httpd chokes on ScriptAlias line in Apache httpd.conf lhoff Linux - Software 1 07-14-2003 10:32 PM

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

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