1.

Solve : Multiple DocRoots with Apache??

Answer»

Situation:
I installed Apache-no-sll 2.054 with PHP 5.04 manually.

Problem:
My .php files are not parsed in any other place than http://localhost/ in my browsers (Opera 7.5 and IExlorer).
For example my test.php only runs in http://localhost/test.php
I want my .php files to run at any location.

What I tried:
http://us3.php.net/manual/en/install.windows.manual.php
Both Apache and "Manual Installation Steps" I read carefully and executed the steps.
I've searched and discussed, even modified the DocRoot directives in both php.ini and httpd.conf..no luck.
What works: command line PHP. The exe is called when typing "php path/phpfile.php",
and thus I also found in the registry that php.exe is called when running .php files.
However, I don't want command line, I want it through browser.

Information:
Here is my httpd.conf:
http://pastebin.com/635907
My Apache error log:
http://pastebin.com/636612
My php.ini:
http://pastebin.com/636617
System:
Microsoft Windows XP [Version 5.1.2600] with SP2. AMD Athlon XP 2400+. 1 GB DDR RAM.
C:\Windows, D: and F: for data. PHP version: 5.04 | Apache version: 2.054 (no ssl).
Apache dir: D:\APPZ\Apache2054\Apache2
PHP dir: D:\APPZ\PHP504

My question is:
What must I do for my .php files to be able to be parsed and interpreted correctly
by the browser, regardless of the directory where the .php file is (other than the location http://localhost)?

Many thanks for your attention and patience.

Treval
The link to your httpd.conf file is showing an empty file unfortunately. PLEASE try that again. It may be that's where the error lies.

In the meantime, I see some other PHP errors in the Apache log:

Code: [SELECT][client 127.0.0.1] script 'D:/APPZ/Apache2054/Apache2/htdocs/insert.php' not found or unable to stat, referer: http://localhost/guestbook.phpThe 'insert.php' file could not be found. Are you trying to link to an absolute file path? (D:/... rather than just /insert.php)


Code: [Select][client 127.0.0.1] PHP Notice: Undefined index: Username in D:\\APPZ\\Apache2054\\Apache2\\htdocs\\loginregister\\index1.php on line 2These and several similar errors mean that you are attempt to access an array variable that has not yet been set.

Code: [Select][client 127.0.0.1] PHP Fatal error: Call to undefined function mysql_connect() in D:\\APPZ\\Apache2054\\Apache2\\htdocs\\loginregister\\index1.php on line 7In your php.ini (in the C:\Windows folder) uncomment the line ';extension=php_mysql.dll'. Locate the php_mysql.dll file in your PHP installation folder and copy it to C:\Windows\system32 (or C:\Windows\system for Win9x). Ensure the MySQL server is running. Restart Apache.My httpd.conf:
http://www.valter.be/txt/httpd.conf
My PHP.ini:
http://www.valter.be/txt/php.ini

These 3 errors were because of a test script I was running (a guestbook with files outside the docroot (in a lower folder loginregister\, and the path defined in guestbook.php is RELATIVE). It doesn't really point out any errors that could trace back to my problem (I don't have mysql server neither).

I just want to change to DocRoot of my CURRENT and only localhost (localhost://) to D:\ or something. I want any .php file being handled by the browser anywhere (any dir). I heard this was done by creating a new VirtualHost, but since I can define a docroot for it, I want to define my current localhost DocRoot. Nor did AddHandler nor AddType work.

Regards,
Treval


Please create a folder under your webroot, put a php file into it and try to access it. Please post details of any error message you see or that appears in Apache's error log. For php purposes, your httpd.conf appears to be correct, although you may wish to add a line:
DirectoryIndex index.php
so that index.php can be a default home page in any folder.

For security reasons, you DO NOT want to change the document root to D:\. Neither do you need a VirtualHost for this purpose.Behold my giant error log (due to a looping series of the same error):
http://www.valter.be/txt/error.log

Can I delete the redundant lines of the OS 10038 error lines safely?
It lags my harddisk and isn't really necessary in my opinion.

Accessing test.php from within my newly created folder under the document root worked (happy ),
but putting index.php in another folder than the docroot scope(any other dir outside) does not work.
I just get plain text in the browser.
So it's true that Apache only calls up the PHP interpreter inside the docroot?

Treval
Quote

Behold my giant error log
Yikes!

Quote
Can I delete the redundant lines of the OS 10038 error lines safely?
You can safely delete the entire log any time you wish.

Quote
Accessing test.php from within my newly created folder under the document root worked (happy ),
Good. That is as expected then,

Quote
but putting index.php in another folder than the docroot scope(any other dir outside) does not work. I just get plain text in the browser.
BING! A light bulb has just gone on in my head. Are you (for example) putting the PHP file in D:\ and then pointing your browser at D:\? If so, Apache is not involved in that transaction at all. Your browser retrieves it directly. Only a client-server query on port 80 will cause Apache to parse PHP files: this is what happens when you point your browser at 127.0.0.1. Otherwise the browser ignores the normal web server protocol and retrieves the file from the filesystem, not from the web server.

Does that make sense? If you see "file://" in your browser's address bar, you know the page has been retrieved via the filesystem. If you see "http://" the file has been retrieve via the HyperText Transfer Protocol (i.e. the web).Hey Rob !

Problem solved. Finally. It took ages.
Thank you immensely for your coopeartion and patience.

Solution:

Alias /Websites "F:\\Websites"

Options +Indexes
Order allow,deny
Allow from all


Regards,
Treval
Er... RIGHT. That doesn't seem to bear much relationship to your original question, but I'm glad you have it set up the way you want it now.


Discussion

No Comment Found