Page 1 of 1

running php locally

Posted: Wed Nov 22, 2006 2:53 pm
by allelopath
I'm getting back into writing some php, after quite some time. I'm a little rusty.

I have apache started. Document Root is /srv/www/htdocs. The site I am working on is in /srv/www/htdoc/MySite/. In that directory are index.htm and mypage.php. index.htm displays, with a link to mypage.php.When I click on this link, firefox says:

You have chosen to open mypage.php
which is a: PHP file
from: /srv/www/htdocs/MySite
What should firefox do with this file?
Open with [Browse[
Save to disk

What have I forgotten to set up, initialize, turn on ...?

Posted: Wed Nov 22, 2006 3:09 pm
by RobertGonzalez
Yuo need to add the directive in httpd.conf that tells apache what to do with php files. I added this at the end of my apache config file

Code: Select all

# For PHP 5 do something like this:
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "C:/php"

Posted: Wed Nov 22, 2006 3:55 pm
by allelopath
Running linux, not windows, my bad for not specifying.

I already have this in /etc/apache2/httpd.conf:
AddType application/x-httpd-php .php

Also there is this statement:
# generated from APACHE_MODULES in /etc/sysconfig/apache2
Include /etc/apache2/sysconfig.d/loadmodule.conf

loadmodule.conf has this line:
LoadModule php4_module /usr/lib/apache2-prefork/libphp4.so

I have verified that libphp4.so is there.

hmph.

Posted: Wed Nov 22, 2006 4:10 pm
by volka
Did you restart the apache?
What linux distriution do you use? How did you install apache and php?

Posted: Wed Nov 22, 2006 4:17 pm
by allelopath
I did restart apache, though there was really no reason to because the conf file stuff was already there.

SuSE 9.2 Pro

I think I installed apache and php via Yast (some time ago)

This worked at one point, so I think everything that is needed is installed.
Something just not initialized.