Bobcares

Install PHP on Windows – Do it with ease

by | Sep 18, 2020

Eager to know how to install PHP on Windows? Take a peek at this blog.

Here at Bobcares, we help web hosts and online service providers to install and configure programming language like PHP as part of our Server Management Services.

Today we’ll take a look at how to install PHP on windows.

 

A few facts about PHP

As we all know that PHP is the most widespread and popular server-side programming language on the web.

Installing it will allow you to create and test a web application without affecting the data or systems on your live website.

 

Options to install PHP on Windows.

There are different ways to install PHP on Windows. Those are:

1. You can simply install it manually on Windows.
2. You can also run the .msi package, i.e. windows installer for PHP.
3. Besides full installation, you can also install the PHP extensions on an already existing installation of PHP.
4. You can upgrade the PHP version to a higher one from an existing version.

 

Install PHP using the PHP Installer

This is the simplest way to install PHP on Windows. You need to just run the .msi Windows installer file and follow the installation wizard. Even though an installer is available from the php.net, it is recommended to install it manually if you already have a Web Server configured and running.

 

Manual installation

Manual installation is a long process. But it provides many benefits. They are:

  • Taking backups, re-installing, or moving the Web Server can be done in seconds.
  • You will have better control over the PHP and the Apache configuration.

Here are the steps to manually install PHP.

 

1. Download the PHP files

First, download the latest PHP zip package from www.php.net/downloads.php. Also, don’t forget to scan the file for the virus and check its MD5 checksum using a tool such as fsum.

 

2. Extract the downloaded file

Normally, we install the PHP files into the C:\php folder. For that, we create that folder and extract the contents of the ZIP file into it.

You can install PHP in any folder according to your preference. But you will need to change the paths referenced in the following steps.

 

3. Configuring php.ini

Now we configure the php.ini file. For that, we copy C:\php\php.ini-development to C:\php\php.ini.

Now, in this file, we will change several lines in a text editor (you can use the search option to find the current setting). Where applicable, we remove the leading semicolon to uncomment these settings.

Define the extension directory:

extension_dir = “C:/php/ext”

Enable extensions. This will depend on the libraries you want to use, but the following extensions should be suitable for the majority of applications:

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

In case, if you want to send emails using the PHP mail() function, enter the details of an SMTP server (your ISP’s server):

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

; For Win32 only.
sendmail_from = my@emailaddress.com

 

4. Now, we add C:\php to the path environment variable.

We change the path environment variable so that Windows can find the PHP.

  • First, open the settings, then type ‘environment variables’ into the search field and open the result.
  • Now, select the “Advanced” tab, and click the “Environment Variables” button.
  • Scroll down the System variables list and click on “Path” and then the “Edit” button.
  • Now click “Edit text” and add ;C:\php to the end of the Variable value line (remember the semicolon).
  • Finally, click OK.

 

5. Configure PHP as an Apache module

Make sure that the Apache is not running. You can use net stop Apache2.4 from the command line. Then open its confhttpd.conf configuration file in an editor and change the below lines.

Add index.php as a default file name:

DirectoryIndex index.php index.html

At the bottom of the file, add the below lines (if necessary, change the PHP file locations ):

# PHP7 module
LoadModule php7_module “c:/php/php7apache2_4.dll”
AddType application/x-httpd-php .php
PHPIniDir “C:/php”

Finally, save the configuration file and test it from the command line (Start > Run > cmd). Run the below commands for it.

cd Apache2bin
httpd -t

 

6. Test the PHP file

Now create a index.php file in Apache’s web page root (either htdocs or D:WebPages) and add this code:

<?php
phpinfo();
?>

Now restart the Apache and open a Web Browser and enter the address http://localhost/.

If the setup is right, then the “PHP version” page should appear

 

How to Install PHP Extensions

You can enable any specific extension in PHP by uncommenting it in the php.ini file.

For instance, if you want to enable mysqli extension. Then you need to search for the extension=mysqli line in the php.ini file and uncomment it as shown below.

…
…
;extension=mbstring
;extension=exif ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c ; Use with Oracle Database 12c Instant Client
…
…

In the same way, you can enable other extensions as well.

[Need any assistance in PHP related queries? – We’ll help you]

 

Conclusion

Today, we saw how our Support Engineers install PHP on Windows.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.