Forum Moderators: phranque

Message Too Old, No Replies

Changing documentroot in http.conf stops PHP from working

puzzling problem

         

MontanaMan

2:01 am on Oct 10, 2020 (gmt 0)

5+ Year Member



Hello:

Windows 10 workstation
Apache 2.4
PHP 7.2.

I've installed Apache and PHP on a Windows 10 workstation and everything (including PHP) works beautifully. But when I change the documentroot in the http.conf file, Apache stops sending .php files to the PHP engine. Apache opens the .php files in the new directory, but the <?php> code no longer gets parsed and processed by the php engine (php.exe). Apache no longer runs those files through the php module.

Here is what I've changed in the http.conf file:

OLD SETTING:
DocumentRoot "${SRVROOT}/htdocs"
<Directory "${SRVROOT}/htdocs">

NEW SETTING:
#DocumentRoot "${SRVROOT}/htdocs"
DocumentRoot "C:/WWW"

#<Directory "${SRVROOT}/htdocs">
<Directory "C:/WWW">

When I change it back again, PHP works just fine.

I've also tried changing the doc_root setting in php.ini, but that doesn't help. Apache never even sends the .php page to the php server.

Any thoughts or help?

Thanks!

not2easy

2:55 pm on Oct 10, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Hi MontanaMan and Welcome to WebmasterWorld [webmasterworld.com]

Generally when you install a local server stack it is configured to run within the install folder/directory. The root directory (C:/) of your computer's hard drive is usually home for your computer's OS which is not configured to process php.

It is best to use the original configuration for your local server.

lucy24

4:04 pm on Oct 10, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Now, wait. There are two different physical locations at play here: the server files with conf and php and so on, and the site files. You really don't need to move the conf stuff from wherever the installer saw fit to put it, but you should absolutely be able to put your site files--which I assume is what you're aiming for--any place you like.

Disclaimer: Both not2easy and I happen to be on Macs, which means our system details are different from yours. But I personally keep the files for several sites in a location that's convenient to me. (I recall having to go into Terminal to edit my system's Hosts file, but that's just about finding things in the browser.)

MontanaMan

4:05 pm on Oct 10, 2020 (gmt 0)

5+ Year Member



Thank you for responding. The problem was a minor one. In the fresh install of PHP, the "short_open_tag" in PHP.ini was set to "Off". The phpinfo file in Apache directory opened with "<?php>" and the file in the new directory opened with "<?>", so it didn't parse. I've changed the php.ini file with "short_open_tag = On" and all is well now.

Simple little things can sometimes trip us up.

phranque

12:13 am on Oct 11, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, MontanaMan!

MontanaMan

4:45 am on Oct 11, 2020 (gmt 0)

5+ Year Member



Thank you everyone for your welcomes and your help. This seems like a friendly and helpful forum!