PHP Installation on localhost

Installation of PHP is quite easy. Let’s see how we can install it on Windows 10 OS. PHP installation includes the installation of XAMPP, which is an open-source web server package.

What you need for installation

For installing PHP, we need the following,

  • XAMPP: Cross-platform web server package
  • Web Server: Apache

For all of the above, we will be using a free and open-source cross-platform web server package known as XAMPP, which includes the following,

  • Apache Server
  • MySQL Database
  • PHP

Now, we will learn how to run our PHP program,

PHP Installation – XAMPP

Step 1: Go to the XAMPP website and download XAMPP for Windows OS.

Download XAMPP

Step 2: Let’s say you install it in C: drive. Now, go to the htdocs folder,

PHP XAMPP htdocs folder

Step 3: Open htdocs and create a new folder myphp for your project. All our project files will get
stored here.

Step 4: Open the folder myphp and add a file with the extension .php.

We’re adding a file, index.php

Create new php file in myphp folder

Now the directory looks like the following,

PHP XAMPP Directory structure

Step 5: Open new.php and add the following code,

Before moving further let’s understand the above code.

  • Our PHP code gets embedded into HTML,
  • <?php & ?> are opening and closing PHP tags respectively,
  • echo is an output statement, which is used to output values to the screen.

Step 6: Now, go to start and type XAMPP Control Panel.

Open XAMPP Control Panel

Step 7: Click on it and you can see the following XAMPP Control Panel dialog box,

XAMPP Control Panel

Step 8: Click on Start for Apache. This will start the Apache server,

Start Apache Server

Step 9: Now, go to the web browser and type, localhost. After pressing enter, you can see the following. The installation is successful if you see what is shown in the following screenshot,

starting localhost

Step 10: Now type your project folder name myphp and press enter. On pressing enter, your project directory will be visible,

http://localhost/myphp/

PHP Installation complete - myphp Project directory visible

Step 12: As shown above, click new.php. Our first PHP program web page is visible. We created a sample program above and the following is the output,

PHP file output

PHP Introduction
PHP First Program
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading