Steps to set up a PHP environment on a local machine.
There are two main ways to set up PHP on a local machine:
- Using just one package (XAMPP & amp; WAMPP) ... (recommended)
- Manually install all required packages (MySQL, PHP and Apache) and configure them.
We will cover a simple
and almost error-free
method to install PHP on a local machine that uses everything in one package called XAMPP
.Steps to install XAMPP:
- Download XAMPP:You can download XAMPP software from the official site here with latest Windows and latest PHP.
- Open the downloaded .exe file.After opening the downloaded file, you will see pop-up from the window, click "Yesand continue.
- Click Next:you will see the XAMPP welcome window as shown below, click Next ”.
- Select components:Select the components you want to install. Please select the MySQLand phpMyAdmincomponents, all other components are optional for this tutorial.
- Select an installation location:select a location whereyou want to install XAMPP, the default is C: / xampp .
- Click Next.After clicking Next, it will start installation.
- Open the XAMPP control panel.After successfully installing XAMPP on your local On your computer, open Control Panel by searching the Windows search bar "XAMPP Control Panel" or by navigating to the XAMPP installation directory. You will see a window as shown below.
- Configuring Apache *:This step is not required,i. e. If you have problemswith Windows 10 related to a blocked port .
Open the config file for Apache as shown in the picture below.
CTRL + F and find
LISTEN 80. Replace port 80with something like 81and save the file and restart the control panel.
- Start the Apache server.Start the Apache server by clicking startupand you will see the port number right before the Apache column. You can stop the service at any time and start any service by simply clicking the Start button.
- Verifying installation:go to your browser and type localhost: 81(or just localhost,if you haven’t changed the port). You will see a page as shown below.
- Verifying PHP installation:create php in the
htdocs folder in your installation folder. (
C: / XAMPP / htdocs) and add the following code to it.
Save the file as demo.php and go to your browser and enter
localhost: 81 / demo.php (or just localhost / demo.php,if you haven’t changed the port).
If the installation went well, you should see the result as shown below.If all of the above went well, congratulations! You have successfully set up your PHP development environment on your local machine.