PHP configuration in IIS &
Apache Web server
·
PHP
Configuration in IIS (Internet Information Services)
o IIS is a web server provided by Microsoft,
and configuring PHP with IIS requires the following steps:
·
Steps to
Configure PHP in IIS
o Install IIS
o Ensure IIS is installed on your Windows
system.
o Go to "Control Panel" →
"Programs" → "Turn Windows features on or off" → Enable
Internet Information Services.
·
Download
PHP
o Download the latest non-thread safe version
of PHP from the official PHP website.
o Extract the downloaded ZIP file to a
directory like C:\php.
·
Install
Web Platform Installer (WPI)1
o Download and install WPI from Microsoft to
simplify the installation of PHP.
o Open WPI and search for "PHP" to
install the desired version.
·
Configure
PHP Handler Mapping
o Open IIS Manager.
o Select your server in the Connections pane.
o Click on "Handler Mappings."
o Add a new script mapping:
§ Request Path: *.php
§ Executable: C:\php\php-cgi.exe (path to PHP
CGI executable).
§ Name: PHP via FastCGI
o Click "OK" and confirm enabling
FastCGI.
·
Verify
PHP Installation
o Create a phpinfo.php file in your web root
directory (e.g., C:\inetpub\wwwroot) with the following content:
<?php
phpinfo();
?>
o Open your browser and navigate to
http://localhost/phpinfo.php to check PHP details.
·
Configure
php.ini
o Copy php.ini-development to php.ini in the PHP
installation folder.
o Edit php.ini to set configurations like
timezone, error reporting, and extensions.
o PHP Configuration in Apache
o Apache is a widely used open-source web
server, and configuring PHP with Apache involves these steps:
o Steps to Configure PHP in Apache
o Install Apache
o Download and install Apache from Apache
Lounge.
o Install it on your desired directory, e.g.,
C:\Apache24.
o Download PHP
o Download the latest thread safe version of
PHP from the official PHP website.
o Extract the ZIP file to a directory like
C:\php.
o Edit Apache Configuration
o Open httpd.conf in the Apache conf directory
(e.g., C:\Apache24\conf\httpd.conf).
Add
the following lines at the end of the file:
#
PHP Integration
LoadModule
php_module "C:/php/php8apache2_4.dll"
AddHandler
application/x-httpd-php .php
PHPIniDir
"C:/php"
o Ensure the php8apache2_4.dll matches your PHP
version.
o Configure PHP
o Copy php.ini-development to php.ini in the
PHP installation directory.
o Edit php.ini for configurations:
§ Set extension_dir to C:\php\ext.
§ Enable required extensions (e.g.,
extension=mysqli).
o Restart Apache
o Restart Apache to apply the changes:
§ httpd -k restart
o Verify PHP Installation
§ Create a phpinfo.php file in your web root
directory (e.g., htdocs folder).
o Add the following code:
<?php
phpinfo();
?>
o Open your browser and navigate to
http://localhost/phpinfo.php to verify PHP.