How to Install PHP on Windows

Install PHP on your Computer allows you to create web applications without upset data on your website. In this article, we describe the PHP Configuration as a module in the windows model of Apache 2.2. Linux and Mac users will likely have to configure already.
Here we have windows distribution that contains PHP, MySQL, Apache in an (All in ONE) single file to install PHP. Like WampServer and XAMPP for creating PHP applications. It is nothing to false with using these packages even if manually configuration PHP and Apache will help you to learn much about the system.

However, PHP Installer is available on php.net. But I would like to recommend the manual configuration if you already have a web server installed and running.

Manual Configuration:

Manual Configuration offers many benefits:
Moving, Reinstalling, and Backing Up the web server can be the hook in seconds. Also, you have further control over Apache and PHP Installation.

Here we have six steps for PHP manual installation.

Download Files:

Download the latest version PHP 7.4 ZIP package from Download

Extract Files:

We configure the PHP files to C:/PHP, Create a folder then extract the contents of the ZIP file.
PHP can be configured anyplace on your computer, but you need to change the paths mentioned in these steps.

Install PHP.ini

Copy C:/php/php.ini-development to C:/php/php.ini. But some lines you need to change in a text editor. Where relevant, you need to take away the leading semicolon to uncomment these settings.

Define the extension directory:

extension_dir = “C:/php/ext”

Allows extensions. It will turn on the libraries you want to use, but the following extensions should be correct for most of the applications.

extension=curl
extension=gd2
extension=mbstring
extension=mysql
extension=pdo_mysql
extension=xmlrpc

If you need to send emails using PHP mail() function, then you need to put your SMTP server details.

[mail function]
; For Win32 only.
SMTP = mail.myisp.com
smtp_port = 25
; For Win32 only.
sendmail_from = [email protected]

Put C:/php to the path environment variable.

Make sure windows can find PHP, you need to change the path environment variable. Now Open Settings, and type there “Environment variable” into the search field and open the result. Sort Out the “Advanced” tab, and press the “Environment Variables” button.

Scroll down the System variables list and click on “Path” followed by the “Edit” button. Click “Edit text” and add; C:\php to the ending Variable value line (remember the semicolon).
Path
Alright Now press OK until you’re out. You may need to reboot at this stage.

Install PHP as an Apache module:

Make sure Apache is not running (use net stop Apache 2.2 from the command line) and open its confhttpd.conf configuration file in an editor. The mentioned lines should be changed:
On line 239, add index.php as a default file Name:

DirectoryIndex index.php index.html

At the base of the file, add the mentioned lines (change the PHP file locations if necessary):

# PHP5 module
LoadModule php5_module “c:/php/php5apache2_2.dll”
AddType application/x-httpd-php .php
PHPIniDir “C:/php”

Save the configuration file and test it from the command (Start > Run > cmd):

cd Apache2bin
httpd -t

Now create a file by name extension must be .php like ‘ index.php’, in Apache web page root (either htdocs or D:WebPages) and add this code.

<?php phpinfo(); ?>

Ensure Apache has started successfully, open an internet browser, and enter the address http://localhost/. If everything goes well, a “PHP version” page should appear showing all the configuration settings.

See Also: Learn PHP

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top