Links to files outside htdocs folder

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

Links to files outside htdocs folder

Postby nucleoest » 22. December 2020 21:58

Hi,

I am using XAMPP 8.0.0 and currently testing on MacOS 11.0.1 (though later live version would use an older version of MacOS, still the issue is the same there).

I developed an app on XAMPP 8.0.0 and running Windows 10. Everything works just fine. The app grabs some log files and then does its thing with them. On Windows option the log files were copied to htdocs folder for testing. Now, when I moved the app to the live machine on MacOS, the app works but it cannot reach the files that now lie outside the htdocs folder (admittedly I did not test for a similar situation on Windows but that is not so important because I need this to work on MacOS).

Config (program and log file names changed):
Code: Select all
// live/development specific settings
if(LIVE) {
    // If site in live mode
    define('SPOOLER_LOG_FILE', '/opt/program_name/var/tmp/logfile.log');
} else {
    // If site is in development mode
    define('SPOOLER_LOG_FILE', 'C:/xampp/htdocs/logfile.log');
}


The code breaks when I use file_exist() function to check things before continuing:
Code: Select all
// Get the log file location and Load the log file contents into an array
if(file_exists(SPOOLER_LOG_FILE)) {
    $spooler_log_array = load_tabbed_file(SPOOLER_LOG_FILE);
} else {
    die('LOG NOT FOUND!');
}


Though running load_tabbed_file() function directly doesn't work, either.

Only time when I got the log file to load was when I copied one under htdocs but IRL that is not a solution since I need the code to reach into the program folder where the log files actually are and are updated.

I also tried creating symlinks with no luck as well, which seems a bit odd since it should work the same as as copying the actual file to htdocs that did work but since I know server config/htaccess has some symlinks settings as well, perhaps that could cause this (though config by default seems to support symlinks but I am not very familiar with this topic).

CHMOD and access rights for logs seem to be fine and not causing this. Also, the paths to files are real (checked times and times again) and working (for example can access via terminal using the same paths). It simply seems that XAMPP is unable to get to anything outside the htdocs folder and after hours of searching I haven't been able to find anything that could help.

XAMPP is pretty much in standard configuration, only added access to phpMyAdmin and changed the root password.

Log: /opt/program_name/var/tmp/logfile.log
htdocs: /opt/lampp/htdocs (or /Users/username/.bitnami/stackman/machines/xampp/volumes/root/htdocs as I grab the path via terminal)
And there is another folder I need to access as well with several XML and JPG files but same deal: /opt/program_name/var/jobs/foldername

I feel like slowly going mad over this and pretty sure someone can tell me what is the obvious I am missing here. Here's hoping.
nucleoest
 
Posts: 2
Joined: 22. December 2020 21:35
XAMPP version: 8.0.0
Operating System: Windows 10/MacOS

Re: Links to files outside htdocs folder

Postby Altrea » 22. December 2020 22:06

Hi,

nucleoest wrote:CHMOD and access rights for logs seem to be fine and not causing this. Also, the paths to files are real (checked times and times again) and working (for example can access via terminal using the same paths). It simply seems that XAMPP is unable to get to anything outside the htdocs folder and after hours of searching I haven't been able to find anything that could help.

PHP uses plain operating system file operations to access files. So please double check your folder and file permissions for the user Apache is running with.

P.S.: You seem to use the VM version of XAMPP on your Mac OS. A virtual machine is a capsuled system and does have limited access to files outside of this bubble.
I would switch to the installer version.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11933
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Links to files outside htdocs folder

Postby nucleoest » 22. December 2020 22:20

Altrea wrote:PHP uses plain operating system file operations to access files. So please double check your folder and file permissions for the user Apache is running with.

Thank you for the reply!

Checked file info for all folders and files: all lines (including "everyone") have "read & write".
Checked CHMOD via terminal: all files and folders are 777.

For whatever reason anything outside htdocs folder regardless of permissions being OK and (absolute) paths also being correct I cannot reach the files.

Edit:
Altrea wrote:P.S.: You seem to use the VM version of XAMPP on your Mac OS. A virtual machine is a capsuled system and does have limited access to files outside of this bubble.
I would switch to the installer version.

Oh, wow, so that is what I've been missing! Simply downloaded off the website and did not even know there were another option before I searched specifically for it. I'll give it a try and see how it goes. Does seem logical though, that a VM could cause such issues.

Edit 2:
Yup, after getting the installer version everything works just fine. Too bad the VM version is offered as the default download and I lost so many hours over it but at least now I can move on. Thank you! :)
nucleoest
 
Posts: 2
Joined: 22. December 2020 21:35
XAMPP version: 8.0.0
Operating System: Windows 10/MacOS


Return to XAMPP for macOS

Who is online

Users browsing this forum: No registered users and 53 guests