Category Archives: IIS

IIS webserver

PHP Error | HTTP Error 500.0 – Internal Server Error | C:\Program Files\PHP\vX.0\php-cgi.exe – The FastCGI process exited unexpectedly

After installing PHP on your IIS,  you might be stuck with the following error :

Http Error 500.0 FastCGI process exited unexpectedly. ”

This error occurs when the Visual C++ Redistributable file to handle CGI process is not present in the system.

To resolve this issue you just need to install proper VC++ redistributable file.

So if you are facing this issue, and if the system does not have proper VC++ version, then just install the version of VC++ supported by the PHP version installed on your system to resolve this error.

List of PHP versions and the VC++ versions supported by it:

PHP version MVC version Supported VC++ version
PHP 7.0 VC 14 Build VC ++ 2015
PHP 5.6 VC 11 Build VC ++ 2012 / update4
PHP 5.5 VC 11 Build VC ++ 2012 / update4
PHP 5.3 VC 9 Build VC ++ 2008

So happy troubleshooting folks . 😉

Enabling PHP ImageMagick extension with IIS !

Prerequisites:

IIS 8.5 Installed

PHP 7.0.X ( 64 Bit) installed to C:\Program Files\PHP via WPI.

O.S :-  Windows Server 2012 / R2

We are about to  enable PHP ImageMagick extension with IIS

ImageMagick is free Open source software for displaying, editing image files in an easier way. It supports more than 200 image formats.

Step 1. Download ImageMagick

Go to http://imagemagick.org/script/binary-releases.php#windows and download ImageMagic exe file.

Step2. Installing of ImageMagick exe

Run the setup file (ImageMagick-6.9.3-7-Q16-x64-dll.exe ) .

Click I accept the agreement button & Click Next.

jo1

 

In the next window, click next and move on. You will be asked about the installation location.

 

jo2

It is recommend to change the default path ( C:\Program Files\ImageMagic x.x.x\ ) to any other folder in C drive. Otherwise it may not work properly.

Here I have created a folder call ‘IM’  in C drive &  is going to install ImageMagick into that folder.  Click Next after selecting the path.

Do not change the Options in the next window ( Select Additional Tasks). Leave it as default & click Next,

 

3

 

Click install in the next page and finish the installation.

Step 3 :- Adding proper DLL files into PHP extension folder.

Go to https://pecl.php.net/package/imagick and Download the proper DLL files forPHP.

From PHP 7.0.0, it supports 64-bit architecture. To find if your PHP is 64- bit or not, open PHP info window and search for Architecture.

Also it will be Thread safe OR Non-Thread safe. We can use phpinfo for this one too. Check for thread safety in phpinfo window, If thread safety is disabled then your PHP is Non-Thread safe.

Once you determine the correct PHP Type, download the appropriate dll files from the above mentioned link. Copy and paste it to PHP extension folder. ( In default – C:\Programfiles OR Program Files (x86) \PHP\v7.0\ext )

Once completed, restart your web server.  

After restarting, open IIS manager and look for PHP Manager in it. Double click on PHP Manager and open it. Then in right pan you can see a new window called PHP Setup.

If you are opening  PHP manager for the first time, then you will see a message. ( red circle in the following image )  . Click on that and enable all.

4

 

Then click on  ‘Enable OR Disable Extension’ tab and find for php_imagick.dll . Click on it then click Enable button in the right side panel to enable  ImageMagic Extension.

 

5

 

Once enabled, restart IIS.

Once completed, open phpinfo page. You will be able to see that imagick module is added with php.

Hiding PHP extension in IIS using URL rewrite module

We have some situations in which we need to hide the extension of a webpage to the end users. Mostly this is concerned with the server security. Here we discuss about hiding the PHP extension of a wepage deployed in an IIS server .

We can easily implement this in Linux using codes passed via .htaccess file. In the case of Windows we will use URL-rewrite module to achieve the same. By default, this module is not installed alongside IIS, so we need to install it via Microsoft Web Platform Installer (WPI).

After the installation of URL-rewrite module, we need to edit the web.conf file in the root directory.

Say for example, we have a php website ‘www.abc.com’ and its root folder is C:/inetpub/wwwroot/www.abc.com. We need to hide the php extension of the page, www.abc.com/test.php. That is, we need to rewrite this url into www.abc.com/test. Lets now edit the web.conf file located at the root folder of the site (C:/inetpub/wwwroot/www.abc.com).

Attaching a sample web.conf file to make it clear :

<?xml version=”1.0″ encoding=”utf-8″ ?>

<configuration>

<system.webServer>

   <rewrite>

     <rules>

         <rule name=”test rule” enabled=”false” stopProcessing=”true”>

              <match url=”^gif” />

               <action type=”Rewrite” url=”{R:0}.aspx” />

         </rule>  

     </rules>

     </rewrite>

</system.webServer>

</configuration>

In our case look for the <rewrite> option in the web.conf file. After finding <rewrite> tag, copy the below mentioned configuration and paste it under the <rewrite> tag.

<rule name=”PHP Hiding”>

     <match url=”(.*)” />

         <conditions logicalGrouping=”MatchAll”>

             <add input=”{REQUEST_FILENAME}” matchType=”IsFile” negate=”true” />

             <add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” negate=”true” />

         </conditions>

     <action type=”Rewrite” url=”{R:1}.php” />

</rule>

After this, the webpage will always be displayed as www.abc.com/test instead of www.abc.com/test.php