LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   PHP - What to add to Apache httpd.conf file? (https://www.linuxquestions.org/questions/linux-software-2/php-what-to-add-to-apache-httpd-conf-file-170920/)

maktos 04-16-2004 09:59 AM

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

coolamit78 04-16-2004 01:34 PM

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

maktos 04-16-2004 01:38 PM

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

coolamit78 04-16-2004 01:49 PM

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

maktos 04-16-2004 01:58 PM

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

strimp099 04-16-2004 02:09 PM

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.

maktos 04-16-2004 02:14 PM

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

coolamit78 04-16-2004 02:19 PM

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

coolamit78 04-16-2004 02:27 PM

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

ECKHART.CURT 04-17-2004 08:18 PM

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


All times are GMT -5. The time now is 02:31 PM.