php have a easy way to run a light server:
first cd into php file directory, then

php -S 127.0.0.1:8000

then you can run php

Answer from peter zhang on Stack Overflow
Discussions

How to install php and run it?
I take it you're on a Windows system? Might try one of these all in one installers: https://www.wampserver.com/en/ (Apache, MySQL and PHP) https://www.apachefriends.org/index.html (Apache, MariaDB, PHP, & Perl) or just install things separately https://www.php.net/manual/en/install.windows.php More on reddit.com
🌐 r/PHPhelp
8
0
September 10, 2022
Can't access php files on localhost
You have to find the XAMPP folder (it's somewhere in local disk C: after you install XAMPP). Inside that there is a htdocs folder. Paste your example folder inside XAMPP/htdocs Sry for vague instructions because I have not used XAMPP for ages and this is all I remember More on reddit.com
🌐 r/PHPhelp
15
2
March 5, 2024
Testing PHP on my local machine
I am wanting to test a php page on my local computer. I have installed xampp and can get the localhost to work but the xxxxx.php file won’t display in the browser all I get is this over and over: More on forum.manjaro.org
🌐 forum.manjaro.org
1
0
November 14, 2022
php - How do I run a file on localhost? - Stack Overflow
Is there a way to have the browser point to the localhost while I am working on my html, instead of having to type in the path all the time? I am working in Dreamweaver CS3, and want to use include commands (either SSI or PHP), but not have to keep putting my files up on HostGator in order to see if they are working. What is the best way to do this (please be specific, I know nothing). ... I'm using Xampp with Apache 2.2 I want to run ... More on stackoverflow.com
🌐 stackoverflow.com
People also ask

How to run PHP files in phpMyAdmin?
Login into PHPMyAdmin, then click on the import tab.  Browse the file with a .sql extension.  Keep in mind to check and uncheck some options.  Choose SQL format and click on Go.
🌐
simplilearn.com
simplilearn.com › home › resources › software development › how to run a php file using xampp: a step by step guide
How to Run a PHP File Using XAMPP: A Step By Step Guide
How do I run my PHP file?
PHP files are saved in C:/Program Files/XAMPP/htdocs. You have to open it, click on the program, and it will automatically run on localhost.
🌐
simplilearn.com
simplilearn.com › home › resources › software development › how to run a php file using xampp: a step by step guide
How to Run a PHP File Using XAMPP: A Step By Step Guide
Can we run PHP in XAMPP?
Yes, you can run PHP in XAMPP. First, start the XAMPP server, create a program you want to and run it at http://localhost.
🌐
simplilearn.com
simplilearn.com › home › resources › software development › how to run a php file using xampp: a step by step guide
How to Run a PHP File Using XAMPP: A Step By Step Guide
🌐
PHP
php.net › manual › en › features.commandline.webserver.php
PHP: Built-in web server - Manual
On Windows you may find useful to have a phpserver.bat file in shell:sendto with the folowing: explorer http://localhost:8888 rem check if arg is file or dir if exist "%~1\" ( php -S localhost:8888 -t "%~1" ) else ( php -S localhost:8888 -t "%~dp1" ) then for fast web testing you only have to SendTo a file or folder to this bat and it will open your explorer and run the server.
🌐
Simplilearn
simplilearn.com › home › resources › software development › how to run a php file using xampp: a step by step guide
How to Run a PHP File Using XAMPP: A Step By Step Guide
July 31, 2025 - Check out the ways to run a PHP file using XAMPP. Explore what XAMPP is and how can it be installed on your system. Read on to know how to execute a PHP script!
🌐
GeeksforGeeks
geeksforgeeks.org › php › how-to-run-php-programs
How to run PHP programs ? - GeeksforGeeks
July 23, 2025 - Once set up, you can create PHP files with a .php extension and place them in the server's root directory (e.g., htdocs for XAMPP). After starting the server, you can access the PHP file in your browser using http://localhost/filename.php.
Find elsewhere
🌐
Quora
quora.com › How-do-I-use-a-PHP-server-on-a-local-host
How to use a PHP server on a local host - Quora
Answer (1 of 2): Mac - Open Terminal and navigate to your project folder - Run: --- php -S localhost:8000 --- - Open `http://localhost:8000` Windows (Standalone PHP) - Install PHP from PHP - Open Command Prompt in your project folder - Run: --- php -S localhost:8000 --- - Open `http...
🌐
Sololearn
sololearn.com › en › Discuss › 221852 › how-should-i-run-php-files-in-google-chrome-
How should i run .php files in Google Chrome?? | Sololearn: Learn to code for FREE!
save your files in root folder, ... server..type localhost in address bar, if its not working type localhost:8080, localhost:3036 etc. let us know what exactly you're facing ... you need a localhost server to run PHP on your PC try wamp if using Mac try Mamp or Lamp for Linux after installing and configuring go to Chrome and type localhost/your PHP script...
🌐
Devrims Blog
devrims.com › home › php › how to run a php file using xampp
How to Run a PHP File Using XAMPP - Devrims Blog
January 24, 2025 - Type (http://localhost/demo) in the address bar and press Enter. ... You should see “Hello, world!” displayed in your browser, indicating that your PHP script is running successfully.
🌐
Hashnode
jst.hashnode.dev › running-simple-php-file-on-localhost-xampp
Running Simple PHP File on Localhost (XAMPP)
July 30, 2022 - Save the file as file-name.php (usually index.php) and open it in your web browser by typing localhost/index.php into the address bar. You should see the words 'Hello, world!' appear on the screen.
🌐
Instructables
instructables.com › circuits › microsoft
How to Run a PHP Script With Wamp Server : 5 Steps - Instructables
November 17, 2022 - How to Run a PHP Script With Wamp Server: Let me explain today how to use the wamp server to run PHP files. You can use this method to run PHP scripts you may have obtained from somewhere and need to run with little to no knowledge of PHP. You can execute your scripts through a web server w…
🌐
Reddit
reddit.com › r/phphelp › can't access php files on localhost
r/PHPhelp on Reddit: Can't access php files on localhost
March 5, 2024 -

Hey,
I've never really worked with php before and right now im already failing to run a file.
I've downloaded XAMPP and when I start Apache and MySQL I can use the dashboard, phpMyAdmin, etc. But when I want to run a file, my browser can't seem to find it. My understanding is that if i have a file at the location C:\example\index.php , i should be able to run it on localhost/example . If i do that however I only get a 404 not found error that reads: "The requested URL was not found on this server.
Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12 Server at localhost Port 80". Im pretty much at wits end here. I have tried accessing localhost/C:/example but that just gives me a 403 forbidden. I have also tried to change the xampp config file by changing some things from require local to allow all (or whatever its called i have forgotten). If anybody knows why i cant access my files please let me know

🌐
Medium
medium.com › @collinsigeh › running-php-locally-on-windows-without-installing-xampp-or-an-additional-server-9922c438f6c
Running PHP Locally on Windows Without Installing XAMPP or an Additional Server | by Collins Igeh | Medium
April 7, 2023 - A simple Google search came in handy and I discovered that version 5 and the latter versions of PHP come with a lightweight server by default. All that’s needed to run it is to type: ... The “S” in the command has to be a capital letter. The “127.0.0.1” is the default localhost IP.
🌐
Manjaro Linux
forum.manjaro.org › support › aur
Testing PHP on my local machine - AUR - Manjaro Linux Forum
November 14, 2022 - I am wanting to test a php page on my local computer. I have installed xampp and can get the localhost to work but the xxxxx.php file won’t display in the browser all I get is this over and over:
🌐
Medium
sirolad.medium.com › six-easy-setup-for-local-php-development-beginners-cfbed13c851e
Six Easy Setups for Local PHP Development — Beginners | by Surajudeen Akande | Medium
October 31, 2019 - On a Windows machine, simply extract ... add it to your System’s Environment Variables. Once that is done on respective machines, kindly run: ... In the root of your PHP application or file. Simply start PHP web server using: ... You can easily see your pages served by visiting http://localhost:port_...
🌐
ItSolutionstuff
itsolutionstuff.com › post › how-to-quick-run-any-php-projectexample.html
How to Quick Run PHP Project on Localhost? - ItSolutionstuff.com
May 14, 2024 - 3. If your project doesn't have ... Once the server is running, you can access your PHP project by opening a web browser and navigating to http://localhost:8000....
Top answer
1 of 7
26

Ok, thanks for the more specific info, ppl may remove their downvotes now...

What you are proposing is a very common thing to do! You want to run your web application locally without uploading it to your host yet. That's totally fine and that's what your Apache is there for. Your Apache is a web server meaning its main purpose is to serve HTML, PHP, ASP, etc. files. Some like PHP; it first sends to the interpreter and then sends the rendered file to the browser. All in all: it's just serving pages to your browser (the client).

Your web server has a root directory which is wwwroot (IIS) or htdocs (apache, xampp) or something else like public_html, www or html, etc. It depends on your OS and web server.

Now if you type http://localhost into your browser, your browser will be directed to this webroot and the server will serve any index.html, index.php, etc. it can find there (in a customizable order).

If you have a project called "mytutorial" you can enter http://localhost/mytutorial and the server will show you the index-file of your tutorial, etc. If you look at the absolute path of this tutorial folder then it's just a subfolder of your webroot, which is itself located somewhere on your harddrive, but that doesn't matter for your localhost.

So the relative path is

http://localhost/mytutorial

while the absolute path may be

c:/webservices/apache/www

or

c:/xampp/htdocs

If you're working with Dreamweaver you can simplify the testing process by setting up your local server as a testing server in your project settings. Try it! It's easy. Once it's done, you can just press the browser icon with any of your files and it will open on localhost.

2 of 7
9

You can do it by running with following command.

php -S localhost:8888
🌐
GeeksforGeeks
geeksforgeeks.org › php › how-to-run-a-php-application-on-ubuntu-localhost
How to Run a PHP Application on Ubuntu Localhost? - GeeksforGeeks
July 23, 2025 - After entering the above command ... the file using ctrl+s. Step 6: Now you can run the PHP script by opening any browser and typing 'http://localhost/'...