XAMPP won't open PHP files in directory (Mac) - php

All the servers are running correctly in XAMPP, and I when I run http://localhost the XAMPP page comes up. However when I try to run a php through xampp by accessing the directory where the file is stored, i.e.,
http://localhost/Applications/XAMPP/xamppfiles/htdocs/gallery.php
I get error 404. I've tried loads of different paths, but here is the path to the file in finder path image
Any ideas?
Thanks!

your webserver is resolving the domain localhost to a specific directory, the so called document root. (this can be adjusted in your server config). I would assume that it points to /Applications/XAMPP/xamppfiles/htdocs. so your file should be accessible via
http://localhost/gallery.php

Related

Why does my Notepadqq editor does not recognize LAMP www folder and sub-folders?

Attempting to get LAMP working on my 32-bit Ubuntu 18.04 machine. I believe the set-up is close to correct. I have all Apache2, mysql, and PHP software installed. I have an index.php file located in folder /var/www/bookcorner directory which shows up as it should if I enter localhost/index.php in the browser address bar. This file may be edited in nano while saving the changes. However, I cannot use my editor Notepadqq (or presumably others) to edit the file.
Going through the file manager, I can select the file and open it in Notepadqq, but I cannot save it. I get the error, "folder does not exist". If I try a 'Save As' with Notepadqq, I do not see any folders past /var in the directory structure, though they obviously exist. The www folder and subfolders do not show up in Notepadqq.
There are three folders under /var/www which are
bookcorner
html
michaelsbookcorner.com
I have ownership of all of these folders
michaelsbookcorner.com is a live site at Infinityfree.net
I somehow got Apache2 to point to bookcorner for now which is fine. Eventually I would like to select between different websites but I only have one for now existing in another directory. I wish to begin utilizing LAMP rather than uploading PHP files to my hosting site all the time.
What settings/permissions/etc could I have missed here in order to get this working properly?

Why my localhost is unable to recognize my htdocs in its directory?

I have a problem with my XAMPP server after uninstalling an old version for a new one. I have a problem with executing PHP codes because when I put "localhost/file.php" it says "Object not found" or put the PHP document despite having the Apache server on.
When I access the XAMPP directory from localhost, it's completely empty despite I stored the site in the htdocs folder. And if you ask, the xampp folder's location is C:/xampp/. And I did put an .htaccess file in my file's directory.
Here's a screenshot:
xampp -> apache -> config -> apache(httpd.conf) and search DocumentRoot and Directory.
see there what link is set.
Giving localhost in the browser address bar refers to htdocs folder.
As we can see the address as localhost/xampp i.e you are refering to htdocs/xampp
if you have stored your file in htdocs root folder, then give the address as localhost

How to run PHP files on XAMMP on A Mac

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.
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).
First of all, expecting the php file to have information that can be visualized in a web browser, inside xampp if you have the .php file in the htdocs folder you should be able to visualize it like this:
http://localhost/HelloWord.php
Found it by trial and error, quite different from what I took from various instructions on line:
http://localhost/HelloWord.php
XAMPP's default root should be "htdocs" or "www". Put your PHP files into those folder and try again.
if it is not work, find the configuration of Apache and PHP in XAMPP folder.

How to resolve linux folder name vs Win7 localhost folder name

I have a text file on my Linux website and I'm trying to run my website php code on my Win7 localhost machine.
The text file on the server is located at:
/home/vault/public_html/ssfiles/mysql.txt
On my local machine I'm running Apache/PHP/MySQL and my php files are located in:
C:\wamp\www\
How do I get my php script to open the file with the first folder string and to also work locally with the second folder string?
I'm new to running php on my local machine and have always run my php scripts directly on the Linux server...so I'm not sure how to resolve this?
Is there a php.ini setting that handles this? based on what machine the script is executing on?
Thanks...
If you place the files in htdocs folder in c:\wampp\ you can directly access the file with localhost/folder_name/file_name.php from broswer

Run my php files from outside htdocs

I have my xampp installed and running sites from the htdocs folder. I want to create a website directory in a different location and run the files online from there.
I know I can do this somehow using both Virtual Host settings and changing my hosts file in System32.
I want to change my URL from localhost/websites/mysite/ to just mysite/
Can anyone offer assistance, thank you
Locate httpd.conf file on your local XAMPP install:
C:\xampp\xampp\apache\conf\httpd.conf
Edit the “DocumentRoot” line to the location of the remote \htdocs folder.
Example:
“C:/xampp/xampp/htdocs” to “C:/Users/Ann/Documents/My Dropbox/Dev/Xampp/xampp/htdocs”
Edit the “Directory” tag to the same remote location you set for DocumentRoot.
“C:/Users/Ann/Documents/My Dropbox/Dev/Xampp/xampp/htdocs”
Save the file and restart your local Apache server.
Navigate to your "localhost” in your browser and you should see the remote web site files.
You don't have to configure anything and then reconfigure ...
What I do is the following:
I have a simple PHP file in htdocs folder, named 'PHPexec.php', which accepts files from anywhere and it runs them as 'include' files. Example: Suppose you want to run "D:\PHPs\xxx.php'. You run http://localhost/PHPexec.php?f=D:\PHPs\xxx.php. PHPexec.php will receive the pathfile as a $_GET variable and run it as an 'include' file:
$file = $_GET['f']; // After checking if it is set etc.
include $file;
Simple as that. From the moment you create your 'PHPexec.php', you have just to run http://localhost/PHPexec.php?f={PHP_file}. Your PHP file will be run as if it were stored in localhost! No configurations and re-configurations ...
(You can configure your 'PHPexec.php' to also accept variables to pass to the PHP file, etc.)

Categories