How to Install PHP in Windows 10/11

How to Install PHP in Windows 10/11

13 June 2023 1 By Harshvardhan Mishra

PHP

PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft’s ASP.

PHP is an acronym for “PHP: Hypertext Preprocessor”. It is a widely-used, open source scripting language. PHP scripts are executed on the server. It is free to download and use.

PHP is an amazing and popular language. It is powerful enough to be at the core of the biggest blogging system on the web (WordPress). It is deep enough to run large social networks. It is also easy enough to be a beginner’s first server side language.

PHP Installation in Windows

Download PHP 8 – Similarly, depending on your system build download the Thread Safe version of PHP.

Install PHP in Windows

 

Note- Please Download and install latest 14.31.31103.0 Visual C++ Redistributable Visual Studio 2015-2022 : vc_redist_x64 or vc_redist_x86 software.

Now we install PHP 8. To do that, similarly, move the downloaded and extracted PHP 8 binary files to the C drive. In my case, I renamed php-8.2.4 to php folder.

Now Copy the PHP 8 home path i.e C:\php and set it into your machine environment variable just like above “apache setup”.

PHP Commands

Open the command prompt and type php -v to check whether the path is set correctly or not. If the PHP path is set correctly, it will print the PHP version.

PHP Windows Shell

Go to the PHP home directory C:\php, and you will find two configuration files php.ini-development and php.ini-production. Create a copy of php.ini-development and rename it to php.ini

Install PHP in Windows

How to run PHP Code via inbuilt PHP server

PHP provides a built-in web server, which you can launch by navigating to a folder and running the PHP executable with an -S parameter to set the localhost port. For example:

cd myproject //folder name where your php files stored
php -S localhost:8000

You can then view PHP pages in a browser at http://localhost:8000.

This may be adequate for quick tests, but your live server will use Apache or similar web server software. Emulating that environment as closely as possible permits more advanced customization and should prevent development errors.

Use PHP Interactive Shell

Just type php -a on your command prompt.

PHP Windows Shell

Method 3 – Set up Web Server on your own PC (Manually)

If you want install and configure manually, Please visit this article : How to install Apache 2.4 and PHP 8 on a Windows