PHP language is suitable for developing huge web applications. One of the real advantages of PHP applications is it is compiled from the server and returning the output to the client or browser. This reduces the client or browser load. Here we will discuss the steps to run a PHP application on a Windows 10 system using XAMPP.
Running a PHP app on an Ubuntu system needs to complete a little bit of configuration first. But running a PHP file/application on the Windows operating system is much simpler using XAMPP. It contains an apache server, Mysql database, FTP, etc.
Here we will install XAMPP on our Windows 10 system first. Then we will run a PHP app using it.
Steps to run a PHP application on Windows 10
The main step to run a PHP app on Windows 10 is the installation of XAMPP. Using XAMPP, we can run Apache2 server, PHP, and MySQL database if needed.
1. Install XAMPP
XAMPP is the most popular PHP development environment.XAMPP is a completely free, easy to install Apache distribution containing MariaDB, PHP, and Perl. The XAMPP open source package has been set up to be incredibly easy to install and to use.
XAMPP can be easily installed using the link below.
Download the latest version from the list you see. Screenshots of the installation steps are shown below.
After starting the XAMPP setup wizard, it ask us for selecting the components to be installed. We just need Apache, PHP, phpMyAdmin and MySQL. But here, I am selecting the components that is selected as default.
Now select the installation directory.
This will start installing XAMPP on our system.
Allow access to run Apache HTTP servser.
Now start the Apache and MySQL as shown in the screenshot below.
2. Create a database(only if our PHP app needs a DB)
This is an optional step and only need if our PHP project needs a database. Creating a MySQL database can be easily done using phpMyAdmin.
- Open the link below. http://localhost/phpmyadmin
- Now Enter username and password(As a default, the username will be root password will be empty).
- Click on the New tab
- Enter a database name
It also needs to configure the database details in our PHP project.
3. Paste/clone the PHP app to “htdocs” directory
The “htdocs” is the directory that the Apache web server looks for files to serve on our domain by default. This location can be changed later to whatever value we want. But now, we have to paste/clone our PHP file or project to this directory. Default htdocs directory location is shown below.
4. Running our PHP file or project
Now its time to run our PHP file. https://localhost direct to our apache2 home page http://localhost/MyApp.php runs the MyApp.php file inside htdocs directory.
Note: As an example, I have chosen MyApp.php as a sample PHP file and MyPHPProject as a sample PHP project.
If it’s a PHP project inside a directory, change the URL path.
If our PHP project contains an index.php file in its root, It does not need to enter the file name. The below URL runs our PHP project.
So we did install XAMPP on our Windows 10 system and run a PHP application using it.