Whether you’re a seasoned developer or someone venturing into the web development realm, the synergy between PHP 8 and IIS is significant. This tutorial lays down a clear, efficient path to integrate these powerful platforms.
What is PHP 8?
PHP 8 is the latest release of the popular scripting language, boasting improved performance and new features.
What is IIS?
IIS or Internet Information Services is Microsoft’s web server platform.
Pre-requisites Before Starting
- An operational Windows Server.
- IIS already installed and configured.
Step 1: Download PHP 8
Get the PHP Zip Package
Head to the official PHP Downloads page. Pick the VC15 x64 Non Thread Safe version for the best compatibility with IIS.
Step 2: Extract and Move PHP
Extract to a Suitable Location
Once downloaded, unzip the contents into a folder, preferably C:\php
.
Update System PATH
Adding PHP to your system PATH simplifies tasks. Head to System Properties > Advanced > Environment Variables and add C:\php
to your PATH.
Step 3: Configure PHP
Rename the Configuration File
In the PHP folder, rename php.ini-development
to php.ini
.
Tweak Settings (Optional)
Open the php.ini
file. Adjust settings as desired, like memory limit and error reporting.
Step 4: Integrate PHP with IIS
Install the IIS CGI Feature
First, ensure the CGI feature is active. Go to Control Panel > Programs and Features > Turn Windows features on or off > Internet Information Services > Application Development Features and check ‘CGI’.
Configure the PHP Handler in IIS
Open IIS Manager. In the main panel, double-click on the “Handler Mappings” icon. Click “Add Module Mapping”. Fill out the following fields:
- Request path:
*.php
- Module:
FastCgiModule
- Executable:
C:\php\php-cgi.exe
- Name:
PHP_via_FastCGI
Click OK.
Set Default Document (Optional)
If you want index.php
to be a default landing page, navigate to Default Documents in IIS and add index.php
.
Step 5: Test Your Installation
Create a PHP Info Page
In your wwwroot folder (usually C:\inetpub\wwwroot
), create a new file named test.php
. Add the following:
<?php phpinfo(); ?>
Access It via Browser
Open a browser and type http://localhost/test.php
. If you see PHP details, congratulations! You’ve successfully integrated PHP 8 with IIS.
Troubleshooting Tips
- Permissions: Ensure
IUSR
andIIS_IUSRS
have read permissions on the PHP folder. - Logs: Always keep an eye on your PHP error log and IIS logs for clues in case of issues.
With PHP 8 installed on IIS, you’ve unlocked an efficient platform for dynamic web applications.