Saturday, July 2, 2022

[FIXED] How to run PHP files on XAMMP on A Mac

Issue

I have saved a PHP file to my Applications/XAMMP/htdocs directory and I want to run it in a browser.

I have used all sorts of url combinations including: http://localhost/xammp/htdocs/HelloWord.php http://localhost/xammp/HelloWord.php

amongst others and I cannot find the right url.

I am using XAMPP on a Mac Majove.


Solution

If you installed the XAMPP VM version, then you can probably access it via http://192.168.64.2/HelloWord.php (check the General tab in the XAMPP app for the IP address)

If you installed the native version, then I guess it is http://localhost/HelloWord.php

The htdocs/ folder is the document root. Its content is served under the server address. Neither the xampp nor the htdocs folder will be part of the URL. The paths are relative to the document root, and you shouldn't be able to access parent directories above htdocs/ (although server-side code such as PHP has access to the file system and may work with files outside of the document root).



Answered By - CodeManX
Answer Checked By - Candace Johnson (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.