Page 1 of 1

when trying to view a .php file my browser tries to download

Posted: Tue Mar 11, 2003 3:06 am
by romeijn
I have istalled Apache/1.3.27 Server on a .NET windows 2003 server and the nessesary files to install PHP.
but when I try to view a website which is PHP based apache shows me the folderlist and not the index.php file.
I have checked if all files are on the right places and that should be ok.

Can somebody help me?

Posted: Tue Mar 11, 2003 3:25 am
by volka
take a look at http://httpd.apache.org/docs/mod/mod_dir.html#directoryindex e.g.

Code: Select all

DirectoryIndex index.html index.php /forbidden.html
This directive needs mod_dir to be enabled

some answers needed.

Posted: Tue Mar 11, 2003 4:08 am
by romeijn
I have checked my httpd.conf file and as far as i know mod_dir is enabled, but where do i place the line you described in the box above ?

Posted: Tue Mar 11, 2003 6:40 am
by mzfp2
i think you also need to set the DocumentRoot setting in httpd.conf to something like this
DocumentRoot "c:/websites/mywebsite"

but im not sure if this is the cause of your problem, but i hope it helps

I have tried it but it didn;t work,

Posted: Tue Mar 11, 2003 9:15 am
by romeijn
I have uninstalled apache 1.3 and installed apache 2.0 and followed all the instructions as described in the manual and still have the problem that if I want to open a file named phpinfo.php my browser wants to download the file instead of showing the results in my browserscreen. :(

Posted: Tue Mar 11, 2003 9:19 am
by volka
The default httpd.conf (shipped with the installation) contains a section
#
# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index. Separate multiple entries with spaces.
#
<IfModule mod_dir.c>
DirectoryIndex index.html
</IfModule>
causing your apache to only search for index.html in each directory. Replaced by
<IfModule mod_dir.c>
DirectoryIndex index.html index.php /forbidden.html
</IfModule>
apache will search for a file index.html, if not found for a file index.php in each directory and the last try is /forbidden.html (a file in your DocumentRoot whatever directory has been requested, e.g. to present a custom "directory listing forbidden"-page)

Posted: Tue Mar 11, 2003 10:12 am
by m3mn0n
I agree, the last post by volka should fix it. :)

Posted: Tue Mar 11, 2003 10:47 am
by volka
that if I want to open a file named phpinfo.php my browser wants to download the file instead of showing the results in my browserscreen.
oops, I missed that post. No, that probably can't be fixed via DocumentRoot.
But again take a look at httpd.conf. There should be a line
#LoadModule info_module modules/mod_info.so
remove the hasmark to uncomment the line. There should also be a section
#
# Allow remote server configuration reports, with the URL of
# http://servername/server-info (requires that mod_info.c be loaded).
# Change the "..." to match your domain to enable.
#
#<Location /server-info>
# SetHandler server-info
# Order deny,allow
# Deny from all
# Allow from ....
#</Location>
change it to

Code: Select all

<Location /server-info>
    SetHandler server-info
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Location>
restart apache(!) and visit http://127.0.0.1/server-info with your browser.
This should show you the "Apache Server Information"-page.
If php is installed correctly there should be something like
Server Version: Apache/1.3.27 (Win32) PHP/4.3.1
...
Module Name: mod_php4.c
Content handlers: application/x-httpd-php , application/x-httpd-php-source , text/html
Configuration Phase Participation: Create Directory Config, Merge Directory Configs, Child Exit
if not check again the installation steps in install.txt (if you've downloaded the zip-package of php from http://www.php.net/downloads.php)

http://www.php.net/manual/en/installation.php will guide you, too.

bad news

Posted: Tue Mar 11, 2003 12:28 pm
by romeijn
I have tried everything you wrote down but still can't get it to work.
It seems that the mod_php4.c can't be loaded.
The server_info tells me the following about php....
http://prj-romeijn.demon.nl/server-info

Posted: Tue Mar 11, 2003 12:57 pm
by volka
Module Name: sapi_apache2.c
php is loaded.

[I just installed apache2 on my box (again). Hey, this tray thingeling let me even choose between apache and apache2, nice ;) ]

in the httpd.conf that ships with the default installation, there is a line
AddType image/x-icon .ico
add the

Code: Select all

AddType application/x-httpd-php .php
right after that and restart apache2 (only guessing)

Finally it works

Posted: Tue Mar 11, 2003 1:03 pm
by romeijn
Thank you all for all the help and tips you gave me today. :D

Posted: Tue Mar 11, 2003 1:26 pm
by volka
one thing, your phpinfo.php says
session.save_path /tmp /tmp
you should change that to a valid directory in your php.ini

last question

Posted: Tue Mar 11, 2003 1:42 pm
by romeijn
In what directory should the tmp be ?
what is the usual path?

Posted: Tue Mar 11, 2003 1:57 pm
by volka
doesn't matter at all. Only make sure that the apache-process has read/write access to it. I e.g. have a directory e:\webserver

Code: Select all

*E:\webserver
	*ftp
	*htdocs
	*icons
	*sessions
	*uploadtmp
DocumentRoot (httpd.conf) and doc_root point to e:/webserver/htdocs.
upload_tmp_dir to e:/webserver/uploadtmp
and session.save_path to e:/webserver/sessions

all changed

Posted: Tue Mar 11, 2003 2:06 pm
by romeijn
thanx very much