PHP is known as the Hypertext Preprocessor Server-side scripting language is one of the widely used open-source web development programming language and also is an alternative to the expensive and paid web development programming languages such as Active Server Pages (ASP) from the Microsoft and the complicated yet free Java Server Pages (JSP).
PHP is mainly used to develop iterative and dynamic websites that supports database connectivity and a variety of functions and APIs that let the developers to build-up an advance dynamic multi-functional web pages very easily. In this article we will learn to install the PHP with Apache and MySQL. We are going to use XAMPP which stands for the Cross-platform Apache, MySQL, PHP (also Python and Perl) is the package of all the essential and required softwares that are used to develop a web application and the website. XAMPP also include FileZilla, Mercury, Tomcat and phpMyAdmin — which offers an iterative Graphical User Interface for the MySQL.
Here is how to install and run PHP on Microsoft Windows 7, 8 and 10:
- Download the latest XAMPP from apachefriends.org
- Install the XAMPP using the setup wizard
- After installing XAMPP go to the default directory
- In the default installation directory open the xampp-control.exe
- In the XAMPP Control Panel click on the “Start” button in front of Apache and MySQL
- After starting Apache and MySQL, go to the default directory again
- In the default directory open “htdocs” folder
- In the htdocs folder create your first PHP file with your-file-name.php
- Open the web browser and go to “http://localhost/your-file-name.php” to run your first PHP file.
1. How to download XAMPP
To download the latest XAMPP :
- Go to apachefriends.org and click on the “Download” option.
- On the Download page under XAMPP for Windows section click on the “Download (32bit)” button which is supported by Windows 36 bit as well as 64 bit.
- Once the downloading completes open the downloaded file
- It will pop with “Warning” message dialog with following message :
- Just click on the “OK” button after which the main setup wizard will open
- On the Setup welcome (first) window click on Next button
- On the Select Components window check the required options — I’ll suggest you to select only Apache (selected by default), MySQL, PHP (selected by default), phpMyAdmin and Fake Sendmail
- After selecting the desired options click on the Next button which will take you to the Installation folder selection window
- On the Installation folder selection window select the path where you would like to install. I will suggest you to install XAMPP on “D:\” or “E:\” directory and if in case you have only “C:\” you will have no option to select any other directory except “C:\”
- Once you’ve selected installation folder, click on the Next button
- After “Installation Folder” window “Bitnami for XAMPP” window will appear on which just uncheck “Learn more about Bitnami for XAMPP” option and click on the Next button to begin with the installation process.
- Once the instillation completes, follow the next step on running your first PHP program with XAMPP
2. Running first PHP Program with XAMPP
To run your first PHP program with XAMPP:
- Go to the default directory where you have installed the XAMPP
- In the default XAMPP directory open “htdocs” folder
- In the “htdocs” folder create your first PHP file using Notepad or Notepad++ and name it test.php (ensure that the extension of the file should be .php)
- To test PHP you can add the following PHP snippet to your test.php file
<?php echo "Hello! World."; ?>
To test your file i.e. — PHP :
- Open the XAMPP Control Panel and Start the Apache and MySQL (XAMPP Control can be found under All Programmes > XAMPP > XAMPP Control Panel)
- Once you have started the XAMPP open your web browser and type “http://localhost/test.php” (without quotes) to test the file that you have created
3. Troubleshooting XAMPP
With XAMPP occasionally you may face some problems in running Apache and MySQL which can be fixed by restarting your computer — With your queries and questions you may reach us on our Form