To run PHP on your own computer, you need a local server. The easiest route is to install an all-in-one package that bundles the web server, PHP and a MySQL database.
Common tools
- XAMPP — cross-platform (Windows, macOS, Linux).
- WAMP — for Windows.
- MAMP — for macOS.
- Laragon — lightweight and popular on Windows.
The steps
- Download and install the tool of your choice.
- Start the Apache (web server) and MySQL services.
- Put your files in the htdocs folder (or www).
- Open http://localhost in your browser.
If the page loads, everything works! Any .php file you drop into that folder will now be interpreted by PHP.
Key point: a local server (XAMPP, Laragon and so on) lets you test PHP without publishing your site online.