How to Install PHP in IIS Windows 10

How to Install PHP in IIS Windows 10

In this article, we are going to learn about How to Install PHP on IIS. We are going to Install PHP7 on our Windows 10 machine. If you want to know How to Install IIS on Windows 10 Check this article. Also, we need to install CGI.

Following are the installation of PHP7 on Windows Server 2016.

  • First, download latest available version of PHP. Visit http://windows.php.net/download#php-7.2. For this article, we are installing VC15 x64 Non Thread Safe (2018-Jan-04 07:06:49). Note for this version of PHP we need to download and install Visual C++ Redistributable for Visual Studio 2015. Download it from https://www.microsoft.com/en-in/download/details.aspx?id=48145
  • Once the download is complete, extract zip file. We are extracting the zip file in C drive. You may select a different drive or location. Our extracted files are available in C:/php7
  • Now we are going to add permission for IIS on PHP7 folder.
    • For this open php7 folder properties.
    • Security Tab → Advanced → Edit → Add → Advanced → FInd Now → Scroll and IIS_IUSRS → Click on OK to Add.
    • Gave all permissions for IIS_IUSRS. Finally, click on OK to close all open dialogs.
  • Before moving to IIS Setup, we need to first modify the php.ini file. Open C:\php7 (Path may be varied based on your PHP file location). In php7 folder look for php.ini_production. Rename it to php.ini.
  • Open php.ini file in your favorite text editor. Search for ; extension_dir = "./" and replace it with extension_dir = "C:/php7/ext".  Note extension path may vary based on your extracted file locations.
  • Modify or un-comment following properties in php.ini file.
    • fastcgi.impersonate = 1
    • cgi.fix_pathinfo=0
    • cgi.force_redirect = 0
      • Note: Windows Users: When using IIS with this option must be turned off. For OmniHTTPD or Xitami the same applies.

    • error_log = C:\php7\error.log

  • Now we are going to enable following extensions. Remove “;” in the fronts of the extension, you want to enable.
    • extension=curl
    • extension=gd2
    • extension=mbstring
    • extension=mysqli
    • extension=pdo_mysql
    • extension=xmlrpc
  • Add PHP in environment path.
    • Open Control Panel (Windows + R → Control Panel → System and Security → System → Advance System Settings → Environment Variables → System Variables → Path → Add C:\php7. 
    • Close all the open dialog by clicking on OK
    • To check the above changes. Open Command Prompt and type PHP -version. If everything is fine you are able to see the version of PHP. In this article, we Installed PHP version 7.2.1. The output for use is

PHP 7.2.1 (cli) (built: Jan  4 2018 04:00:18) ( NTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies

  • Next, we need to open IIS. I prefer shortcuts so, I am going to open Run and then type INETMGR followed by Enter. It is going to open IIS.
  • Click on Handler Mappings
    • Click on Add Module Mapping. In the new dialog for Add Module Mapping
      • Request path: *.php
      • Module: FastCgiModule
      • Executable(optional): C:\php7\php-cgi.exe
      • Name: FastCGI
      • Click on OK. For confirmation dialog box, click on OK
    • Go Back or Click on your server name
  • Click on Default Documents and index.php
  • Now we are going to create a PHP file to display hello, vLemonn! Text. For this run notepad as an administrator. Add “<?php echo “Hello, vLemonn”; ?>” In your new file. Save the file with name hello extension PHP.
  • Test your site by visiting http://localhost/hello.php 
0 Comments
Leave A Comment

Please login to post your valuable comments.

Join the newsletter

Get the latest vLemonn news first

share