Jump to content

Archived

This topic is now archived and is closed to further replies.

b1

php files only work in apache root directory?

Recommended Posts

I want to test my php scripts on my computer so I have set up Apache 1.3.14 and php 4.0.5 using PHPTriad.

 

If I put my .php files in the DocumentRoot <Directory \"/apache/htdocs\"> they work fine when I go to, for example, http://localhost/test.php in my browser. However, I need to create directories inside the root, but when I do any files in those directories are basically missing in action eg. going to http://localhost/php/test.php will give me the message \"The requested URL /php/test.php was not found on this server\".

 

What do I need to do to get Apache to recognise new folders inside the root when they are created? I don\'t particularly want to use .htaccess files because I don\'t need to.

 

I\'m assuming there\'s a setting in the httpd.conf file that I need to set, but what is it?

 

I have copied what I think is the relevent portion of my httpd.conf file below.

 

Basically it\'s all just default as PHPTriad set it up - I haven\'t changed anything \'cause I\'m not familiar with the file settings (slowly learning).

 

Can anyone help? All I want to do is test my scripts. Although I can just test them all in the root things could get messy; and I need to create new directories for some tutorials I am working through.

 

Any help appreciated.

 

#

# DocumentRoot: The directory out of which you will serve your

# documents. By default, all requests are taken from this directory, but

# symbolic links and aliases may be used to point to other locations.

#

DocumentRoot \"/apache/htdocs\"

 

#

# Each directory to which Apache has access, can be configured with respect

# to which services and features are allowed and/or disabled in that

# directory (and its subdirectories).

#

# First, we configure the \"default\" to be a very restrictive set of

# permissions.

#

<Directory />

Options FollowSymLinks

AllowOverride None

</Directory>

 

#

# Note that from this point forward you must specifically allow

# particular features to be enabled - so if something\'s not working as

# you might expect, make sure that you have specifically enabled it

# below.

#

 

#

# This should be changed to whatever you set DocumentRoot to.

#

<Directory \"/apache/htdocs\">

 

#

# This may also be \"None\", \"All\", or any combination of \"Indexes\",

# \"Includes\", \"FollowSymLinks\", \"ExecCGI\", or \"MultiViews\".

#

# Note that \"MultiViews\" must be named *explicitly* --- \"Options All\"

# doesn\'t give it to you.

#

Options Indexes FollowSymLinks MultiViews ExecCGI

 

#

# This controls which options the .htaccess files in directories can

# override. Can also be \"All\", or any combination of \"Options\", \"FileInfo\",

# \"AuthConfig\", and \"Limit\"

#

AllowOverride None

 

#

# Controls who can get stuff from this server.

#

Order allow,deny

Allow from all

</Directory>

 

#

# UserDir: The name of the directory which is appended onto a user\'s home

# directory if a ~user request is received.

#

# Under Win32, we do not currently try to determine the home directory of

# a Windows login, so a format such as that below needs to be used. See

# the UserDir documentation for details.

#

<IfModule mod_userdir.c>

UserDir \"/apache/users/\"

</IfModule>

 

#

# Control access to UserDir directories. The following is an example

# for a site where these directories are restricted to read-only.

#

#<Directory \"c:/apache/users\">

# AllowOverride FileInfo AuthConfig Limit

# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec

# <Limit GET POST OPTIONS PROPFIND>

# Order allow,deny

# Allow from all

# </Limit>

# <LimitExcept GET POST OPTIONS PROPFIND>

# Order deny,allow

# Deny from all

# </LimitExcept>

#</Directory>

 

#

# 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

DirectoryIndex index.htm

DirectoryIndex index.php

DirectoryIndex index.php3

DirectoryIndex default.html

DirectoryIndex default.htm

 

</IfModule>

 

#

# AccessFileName: The name of the file to look for in each directory

# for access control information.

#

AccessFileName .htaccess

 

#

# The following lines prevent .htaccess files from being viewed by

# Web clients. Since .htaccess files often contain authorization

# information, access is disallowed for security reasons. Comment

# these lines out if you want Web visitors to see the contents of

# .htaccess files. If you change the AccessFileName directive above,

# be sure to make the corresponding changes here.

#

# Also, folks tend to use names such as .htpasswd for password

# files, so this will protect those as well.

#

<Files ~ \"^.ht\">

Order allow,deny

Deny from all

</Files>

 

#

# CacheNegotiatedDocs: By default, Apache sends \"Pragma: no-cache\" with each

# document that was negotiated on the basis of content. This asks proxy

# servers not to cache the document. Uncommenting the following line disables

# this behavior, and proxies will be allowed to cache the documents.

#

#CacheNegotiatedDocs

 

#

# UseCanonicalName: (new for 1.3) With this setting turned on, whenever

# Apache needs to construct a self-referencing URL (a URL that refers back

# to the server the response is coming from) it will use ServerName and

# Port to form a \"canonical\" name. With this setting off, Apache will

# use the hostname:port that the client supplied, when possible. This

# also affects SERVER_NAME and SERVER_PORT in CGI scripts.

#

UseCanonicalName On

 

#

# TypesConfig describes where the mime.types file (or equivalent) is

# to be found.

#

<IfModule mod_mime.c>

TypesConfig conf/mime.types

</IfModule>

 

#

# DefaultType is the default MIME type the server will use for a document

# if it cannot otherwise determine one, such as from filename extensions.

# If your server contains mostly text or HTML documents, \"text/plain\" is

# a good value. If most of your content is binary, such as applications

# or images, you may want to use \"application/octet-stream\" instead to

# keep browsers from trying to display binary files as though they are

# text.

#

DefaultType text/plain

Share this post


Link to post
Share on other sites

I don\'t think there is anything extra you need to do

 

I don\'t exactly understand why you\'re having this problem

 

I used PHPTriad myself and never had a real problem

cept with my damn virtual hosts

:evil:

Share this post


Link to post
Share on other sites

So what you\'re saying is that normally it should work for all directories regardless - no setting access rights for each folder etc. I guess that tells me something in itself.

 

By the response to this post I\'d say this is a rare problem and therefore probably something specific to my machine, and nothing to do with httpd.conf file settings.

 

All I can do is try reloading the program again; it didn\'t work the last time but I\'ll give it another go.

 

If anyone has any ideas on how I could pinpoint the cause of the problem please post. Thx

Share this post


Link to post
Share on other sites

i am unsure. i have not had this problem, but i have only worked with versions of apache 2. does the new directory have the correct permissions for the apache user?

Share this post


Link to post
Share on other sites

How do you find out what the folder access permissions are? Is that the windows > properties sharing information? When I access the space my ISP has provided I use WSFTP and use the chmod settings - there are no such settings to adjust when using local folders.

 

Perhaps if I just put a htaccess file into my php folder that will allow me to use WSFTP locally to change folder permissions?

Share this post


Link to post
Share on other sites

:shock: ah... windows. i haven\'t ftp\'d in awhile; use the help features to get a command listing and see what you can find out about the permissions.

Share this post


Link to post
Share on other sites

have you only tried using a folder in document root named \"php\" ?

 

...because if php is also installed as cgi(phpTriad?) then php will look for \"test.php\" in your php binary directory ...at which point your webserver might give you that 404.

Share this post


Link to post
Share on other sites
have you only tried using a folder in document root named \"php\" ?

 

...because if php is also installed as cgi(phpTriad?) then php will look for \"test.php\" in your php binary directory ...at which point your webserver might give you that 404.

 

php doesn\'t work like cgi man

Share this post


Link to post
Share on other sites

ok sorry i meant to say \"installed as a cgi Binary\" :P ...chk the windows installation txt my friend

 

...he did say phpTriad.

 

 

/edit

i said it would look for php in his php binary folder cuz he\'s using the default setup i imagine with apache

 

..anyway

 

The Windows PHP installer is available from the downloads page at

www.php.net. This installs the CGI version of PHP and, for IIS, PWS,

and Xitami, configures the web server as well.

Note that this version does *NOT* install any extensions or server

api versions of PHP.

 

Share this post


Link to post
Share on other sites

...and...

 

Installing PHP for Apache as CGI binary

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

If you wish to install PHP as a CGI binary, read this first:

 

http://www.cert.org/advisories/CA-1996-11.html

 

and then if you are really sure, insert these lines to your conf file:

 

ScriptAlias /php/ \"c:/php/\"

AddType application/x-httpd-php .php

Action application/x-httpd-php \"/php/php.exe\"

 

..from php install.txt ...

Share this post


Link to post
Share on other sites
have you only tried using a folder in document root named \\\"php\\\" ?

 

...because if php is also installed as cgi(phpTriad?)  then php will look for \\\"test.php\\\" in your php binary directory ...at which point your webserver might give you that 404.

 

It would appear the problem was the name of the folder \"php\". Just my bad luck to pick the wrong one. I was running php as a CGI binary according to my htttpd.conf file I think.

 

# Aliases: Add here as many aliases as you need (with no limit). The format is  

# Alias fakename realname

#

<IfModule mod_alias.c>

 

   #

   # Note that if you include a trailing / on fakename then the server will

   # require it to be present in the URL.  So \\\"/icons\\\" isn\'t aliased in this

   # example, only \\\"/icons/\\\"..

   #

   Alias /icons/ \\\"/apache/icons/\\\"

 

   <Directory \\\"/apache/icons\\\">

       Options Indexes MultiViews

       AllowOverride None

       Order allow,deny

       Allow from all

   </Directory>

 

   #

   # ScriptAlias: This controls which directories contain server scripts.

   # ScriptAliases are essentially the same as Aliases, except that

   # documents in the realname directory are treated as applications and

   # run by the server when requested rather than as documents sent to the client.

   # The same rules about trailing \\\"/\\\" apply to ScriptAlias directives as to

   # Alias.

   #

   ScriptAlias /cgi-bin/ \\\"/apache/cgi-bin/\\\"

   ScriptAlias /php/ \\\"/apache/php/\\\"  

 

   #

   # \\\"c:/apache/cgi-bin\\\" should be changed to whatever your ScriptAliased

   # CGI directory exists, if you have that configured.

   #

   <Directory \\\"/apache/cgi-bin\\\">

       AllowOverride None

       Options None

       Order allow,deny

       Allow from all

   </Directory>

 

</IfModule>

# End of aliases.

 

I set the folder name to \"a\" and my script worked, then set it to a whole lot of different names and they all worked, except \"php\".

 

I think I\'m set for now. I\'m more interested in learning php than getting into the details of running a server. Hopefully I\'ll have no more problems. When I get to the point of setting my site up on a server I\'ll either just pay for it to be stored externally, or set up a linux box (it doesn\'t sound wise to use a windows based server).

 

Thx for your help, and my apologies for my slow replies, I\'ve had the flu.

Share this post


Link to post
Share on other sites

i also started on learning php @ first rather than concentrating on the details of setting it up :D ... anyway, glad we could help 8)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.