php not found in localhost subdirectories

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

php not found in localhost subdirectories

Postby JRR » 18. February 2020 00:21

OSX 10.13.6, Macbook Pro 2012, XAMPP 5.6.11-1, Firefox 73.0

HTML works fine.

I have PHP issues:

When I do my basic http://localhost (or 127.0.0.1) I get the php information page which shows PHP 5.6.11 (note that I do not see any sort of Control Panel that is suggested on some web pages).
When I have the directory one away from localhost, and try to launch a simple PHP info file eg: localhost/somedirectory/phpinfo.php (<?php phpinfo(); ?>) it does not work - I get the Object not found message.

I have this in http.conf:

#DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
DocumentRoot "/Users/somedirectory/Sites"

#<Directory "/Applications/XAMPP/xamppfiles/htdocs">
<Directory "/Users/somedirectory/Sites">

It would appear to be some sort of path issue, but I am not sure how to resolve that...will check error msgs later, but have to go right now...
JRR
 
Posts: 4
Joined: 20. February 2015 19:19
Operating System: OSX Yosemite 10.10.0.2

Re: php not found in localhost subdirectories

Postby JRR » 18. February 2020 07:47

I have edited .bash_profile to:

export XAMPP_HOME=Users/somedirectory/Applications/XAMPP/xamppfiles
export PATH=${XAMPP_HOME}/bin:${PATH}
export PATH

In Terminal:

When I do the echo $PATH I get - /Users/somedirectory/Applications/XAMPP/xamppfiles/bin

which php - I get the correct directory - /Applications/XAMPP/xamppfiles/bin/php

php -v - I get the correct version of PHP - PHP 5.6.11

Still trying to figure out what is wrong. I only get phpinfo behaving correctly in the localhost directoryas set in DocumentRoot, not in any subdirectories.

Not having much fun at this point...

thanks!
JRR
 
Posts: 4
Joined: 20. February 2015 19:19
Operating System: OSX Yosemite 10.10.0.2

Re: php not found in localhost subdirectories

Postby Nobbie » 18. February 2020 11:15

If you change DocumentRoot, you also must grant Apache appropriate rights to load files from there. There is an <Directory ...> block in your configuration, which contains options for the htdocs folder, you must adapt these for your newly DocumentRoot. Additionally you must keep in mind, that Apache runs with a different UserId than yourself, you have to grant at least sufficient rights on file system level that Apache can read your private files and folders from your home.

"Not having fun" - because of missing skill, installing a webserver usually is a task for an educated administrator, thats the reason why Xampp comes preconfigured to run out of the box. If you want to change such basic settings like DocumentRoot, you have to know what you are doing. Apache is not a simple toy.
Nobbie
 
Posts: 13181
Joined: 09. March 2008 13:04

Re: php not found in localhost subdirectories

Postby JRR » 19. February 2020 03:49

Thanks for taking the time to reply. I did decide to move my web site test files to htdocs, and edit back the Document Root. While my web files ran fine (html) nothing php based would work (as per above)... I may just reinstall XAMPP, as you say it is not for the faint at heart and I have spent enough hours trying to make it do something it really wasn't designed to easily do.
I'll try not to break anything else!
JRR
 
Posts: 4
Joined: 20. February 2015 19:19
Operating System: OSX Yosemite 10.10.0.2


Return to XAMPP for macOS

Who is online

Users browsing this forum: No registered users and 27 guests