Install PHP on IIS:

  • Download PHP for Windows:
    • Download the latest PHP version from the official PHP for Windows.
    • Extract the files to a directory, for example, C:\PHP.

Create directory

  • On inetpub\wwwroot create your directory

Configure PHP with IIS:

  • Open IIS Manager:
    • Open IIS Manager (you can find it by searching in the Start menu or running inetmgr).
  • Select Your Website:
    • In the left panel (Connections), select your website.
  • Configure Handler Mappings:
    • In the middle panel (Features View), double-click on Handler Mappings.
    • Click on Add Module Mapping… and configure the following:
      • Request Path: *.php
      • Module: FastCgiModule
      • Executable: Browse and select php-cgi.exe in the directory where PHP is installed (e.g., C:\PHP\php-cgi.exe).
      • Name: PHP_via_FastCGI
    • Click OK and confirm

Create a Test File:

  • Create a file named info.php in your web directory with the following content:php
<?php 
phpinfo();
?>

Access the Test File:

  • go to http://yoursite/GetComputerName/info.php

Sample php.ini

; PHP INI Configuration File

; Basic PHP Settings
[PHP]
engine = On
short_open_tag = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func = 
serialize_precision = 17
disable_functions = 
disable_classes = 
zend.enable_gc = On

; Timezone setting
date.timezone = "Europe/Paris"

; Error Handling and Logging
display_errors = On
display_startup_errors = On
log_errors = On
error_log = syslog
error_reporting = E_ALL
track_errors = Off

; File Uploads
file_uploads = On
upload_max_filesize = 10M
max_file_uploads = 20

; Data Handling
post_max_size = 10M
auto_globals_jit = On

; Paths and Directories
include_path = ".;C:\php\includes"

; Resource Limits
max_execution_time = 30
max_input_time = 60
memory_limit = 128M

; Extensions
extension_dir = "ext"

; Enable PDO and MySQL extensions
extension=pdo_mysql

; Session Settings
[Session]
session.save_handler = files
session.save_path = "C:\Windows\Temp"
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_secure = 
session.cookie_httponly =
session.cookie_samesite =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.sid_length = 26
session.trans_sid_tags = "a=href,area=href,frame=src,form="

; cgi.force_redirect is necessary to provide security running PHP as a CGI under most web servers.
; Uncomment it if you are running under CGI.
cgi.force_redirect = 1
cgi.fix_pathinfo = 1

; FastCGI settings
fastcgi.impersonate = 1
fastcgi.logging = 0

; Paths and Directories
upload_tmp_dir = "C:\Windows\Temp"
sys_temp_dir = "C:\Windows\Temp"

; Socket and Database Handling
pdo_mysql.default_socket=

; Mail settings
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
sendmail_from = me@example.com

; Xdebug configuration (if you use Xdebug)
[XDebug]
zend_extension = "C:\php\ext\php_xdebug.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_port = 9000
xdebug.remote_host = 127.0.0.1
xdebug.remote_handler = dbgp
xdebug.remote_mode = req
Categories: IISTools

0 Comments

Leave a Reply

Avatar placeholder

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.