1

I have been trying to set up PHP from php.net in my Apache web server (localhost).

Over the last day and a half I've been chasing through documentation at the Apache site, the php.net site, SO, and anywhere else shows a hit for the current error, to try and solve the problems. Here are some details of my current set-up and (possible mis)understanding.

Define SRVROOT "/Apache/00"
ServerRoot "${SRVROOT}"

The public directory of Apache is set to htdocs. Apache is producing listings of the directories under it without any problems through localhost. Just to make bleeding sure that I have the right address and it it is Apache, I do an on/off test as described below.

I ran the Windows MSI supplied for PHP. Then I adjusted the /conf/httpd.conf file to add:

ScriptAlias /php/ "${SRVROOT}/php/"
AddType application/x-httpd-php .php

Note: php, htdocs (public files) & conf directories are all in the root of the same directory, SRVROOT.

Test Apache

http://localhost/lib/ 

might produce:

Index of /lib

    Parent Directory
    amd64/
    web.jar
    x86/

While shutting down Apache and refreshing the listing I see a FF error.

Unable to connect
Firefox can't establish a connection to the server at localhost.

So Apache itself seems to be working fine, when it is running I can do directory listings.

Test PHP

http://localhost/php/

Shows:

Forbidden
You don't have permission to access /php/ on this server.

OK that seems logical, Apache now acknowledges the existence of the directory but says it is not intended to by publicly browsed.

I have an phpinfo.php in the root of the php directory containing.

<?phpinfo();?>

I expect that if I browse to http://localhost/phpinfo.php is should give me information, but instead I get 404 message:

Not Found

The requested URL /phpinfo.php was not found on this server.

For http://localhost/php/phpinfo.php I get forbidden message:

Forbidden
You don't have permission to access /php/phpinfo.php on this server.

Typical error.log

sl:warn] [pid 1504:tid 336] AH01909: RSA certificate configured for localhost:443 does NOT include an ID which matches the server name
[Sun Aug 04 19:06:01.995343 2013] [ssl:warn] [pid 1504:tid 336] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Sun Aug 04 19:06:02.298078 2013] [ssl:warn] [pid 1504:tid 336] AH01909: RSA certificate configured for localhost:443 does NOT include an ID which matches the server name
[Sun Aug 04 19:06:02.298078 2013] [ssl:warn] [pid 1504:tid 336] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Sun Aug 04 19:06:02.300031 2013] [mpm_winnt:notice] [pid 1504:tid 336] AH00354: Child: Starting 64 worker threads.
[Sun Aug 04 19:06:03.279523 2013] [authz_core:error] [pid 1504:tid 1004] [client ::1:50589] AH01630: client denied by server configuration: I:/Apache/00/php/index.html
[Sun Aug 04 19:15:39.932843 2013] [authz_core:error] [pid 1504:tid 1004] [client ::1:50599] AH01630: client denied by server configuration: I:/Apache/00/php/
[Sun Aug 04 19:21:49.700421 2013] [authz_core:error] [pid 1504:tid 1004] [client ::1:50608] AH01630: client denied by server configuration: I:/Apache/00/php/phpinfo.php
[Sun Aug 04 19:26:58.432843 2013] [authz_core:error] [pid 1504:tid 1004] [client ::1:50621] AH01630: client denied by server configuration: I:/Apache/00/php/phpinfo.php
[Sun Aug 04 19:37:26.403546 2013] [mpm_winnt:notice] [pid 4400:tid 324] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sun Aug 04 19:37:28.403546 2013] [mpm_winnt:notice] [pid 1504:tid 336] AH00364: Child: All worker threads have exited.
[Sun Aug 04 19:37:28.418195 2013] [mpm_winnt:notice] [pid 4400:tid 324] AH00430: Parent: Child process 1504 exited successfully.

Question

I want to show the phpinfo.php document. Can anyone see the dumb mistake I am making (I am a newbie at this)?

See also:

These are the primary docs I've been looking at:

1 Answer 1

1

You're probably getting the permission error because the phpinfo.php file does not have permissions set such that the Apache server you're running can read it. Apache can be configured to drop privileges to a limited user account when it runs, and if your file security permissions for a file don't allow that user account to read the file, you will get permission errors. Remember that this applies to every directory in the final path name, i.e. /Apache and /Apache/00 and /Apache/00/php and /Apache/00/php/phpinfo.php must ALL be readable by the user account that Apache runs under.

Another possibility is that you may need to add a Directory directive in httpd.conf to allow access to /php/ if your httpd.conf has a Directory directive for a default access policy of deny-first.

I also don't see any mention of where you've installed the PHP Apache module DLL into the Apache modules folder, nor where you've added the module in your httpd.conf file. If you don't load the PHP module, PHP files will not pass through PHP.

Sign up to request clarification or add additional context in comments.

4 Comments

In regard to the permissions, I am confident that the htdoc directory hierarchy and files (the 'public web' element) is accessible, should I move the php directory inside of it? Is it more common to have the PHP base inside or alongside the public documents directory? Still looking into some of your other points, thanks..
If there is no compelling reason to have the directory outside of the document root, it's better to keep it where it is intended to be used, at least from a management perspective.
Would you be a Windows user, BTW?(1) I ask because the client I am working for has agreed to set up the 'test PHP server' I need to progress. It means I can upload PHP to test ideas, and if I break anything, it is not a great problem. However I still want a local app. capable of running a PHP when I access it from a browser. I am willing to abandon Apache if there is an easier way ((1) on Windows 7) to get a PHP rendered (e.g. IIS) without using any remote server, I'd love to hear about it. If you think I should start a new thread on that matter, I'll do so..
If you need to quickly set up a fully functional Apache installation with MySQL and PHP, take a look at WampServer. It will install a WAMP stack without any serious effort which can be accessed in a browser using the URL localhost

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.