Skip to main content

How to run PHP in IIS ?

 

I'd be glad to provide a comprehensive guide on running PHP in IIS on Windows 10, incorporating the necessary Windows features like CGI and Hyper-V:

Prerequisites:

  • Windows 10: Ensure you have Windows 10 installed with administrative privileges.
  • IIS: Enable the Internet Information Services (IIS) feature:
    • Open "Control Panel" -> "Programs" -> "Programs and Features" -> "Turn Windows Features On or Off".
    • Expand "Internet Information Services" and check the following options:
      • Web Management Tools
      • Common HTTP Features
      • Application Development Features
      • Security
      • Performance
      • Management
    • Click "OK" to install the selected features.

Installing PHP:

  1. Download PHP: Visit the official PHP website (https://www.php.net/downloads.php) and download the latest stable version for Windows (e.g., PHP 8.2).
  2. Extract the ZIP file: Extract the downloaded ZIP file to a desired location on your system (e.g., C:\php).
  3. Configure PHP:
    • Open the php.ini file located within the extracted PHP directory.
    • Make necessary configuration changes based on your requirements. Common settings include:
      • Extensions: Uncomment the extensions you want to enable (e.g., extension=php_mysqli.dll, extension=php_gd2.dll).
      • Error reporting: Adjust the error_reporting and display_errors settings to control error display.
      • Time zone: Set the date.timezone value to your appropriate time zone.
    • Save the php.ini file.

Configuring IIS:

  1. Create a virtual directory:
    • Open IIS Manager (you can search for it in the Start menu).
    • Navigate to "Sites" -> "Add Website".
    • Provide a name for the website, select a physical path (e.g., the root directory of your PHP applications), and specify the IP address and port.
    • Click "OK" to create the virtual directory.
  2. Enable PHP:
    • Right-click on the created website and select "Properties".
    • Go to the "Home Directory" tab.
    • Under "Application Mappings," click "Add."
    • In the "Executable" field, enter the path to the PHP executable (e.g., C:\php\php.exe).
    • In the "Extension" field, enter *.php.
    • Click "OK" to add the mapping.

Testing PHP:

  1. Create a PHP file: Create a new PHP file (e.g., index.php) within your virtual directory.
  2. Write PHP code: Add PHP code to the file to test its functionality. For example:PHP 
    • <?php phpinfo(); ?>
  3. Access the file: Open a web browser and navigate to the URL of your website (e.g., http://localhost:8080). You should see the PHP information page.



Running PHP with Hyper-V

If you need to run PHP in a virtual environment using Hyper-V, follow these steps:

  1. Create a virtual machine: Use Hyper-V Manager to create a new virtual machine with a suitable operating system.
  2. Install IIS and PHP: Install IIS and PHP within the virtual machine using the same steps described above.
  3. Configure networking: Set up network connectivity between the host and guest machines to access the virtual website.

By following these steps, you should be able to successfully run PHP applications in IIS on Windows 10, including using Hyper-V for virtualized environments.

source



Comments

Popular posts from this blog

How to disable mouse acceleration using PowerShell ?

  To disable mouse acceleration using PowerShell, you can use the following script.  !Changing registry settings via PowerShell script will affect all pointing devices that use those settings! This script changes registry settings to disable mouse acceleration: Open Notepad and paste the code below: New-ItemProperty -Path "HKCU:\Control Panel\Mouse" -Name "MouseSpeed" -Value "0" -PropertyType String -Force New-ItemProperty -Path "HKCU:\Control Panel\Mouse" -Name "MouseThreshold1" -Value "0" -PropertyType String -Force New-ItemProperty -Path "HKCU:\Control Panel\Mouse" -Name "MouseThreshold2" -Value "0" -PropertyType String -Force This PowerShell script does the following: Registry path  :    -Path "HKCU:\Control Panel\Mouse"   Specifies the location in the registry where the property will be added or modified. In this case, it is the registry key for the mouse s...

How to create a certificate using wampserver and openssl ?

cmd.exe the path may vary depending on your wamp installation cont/ cd C:\wamp64\bin\apache\apache2.4.54.2\bin cmd command to generate key edit key name    "certificate" openssl genrsa -out   certificate .key 2048 create folders    C:\Apache24\conf   copy the file " openssl.cnf " from the folder   C:\wamp64\bin\apache\apache2.4.54.2\bin   to the   C:\Apache24\conf  folder   cmd command to generate pre-certificate edit key and certificate name    "certificate" openssl req -new -key   certificate .key -out   certificate .csr after entering the command, complete the certificate data step by step Country Name (2 letter code): PL State or Province Name (full name): Province Locality Name (eg, city): City Organization Name (eg, company): Company Name Organizational Unit Name (eg, section): Department Common Name (eg server FQDN or YOUR name): yourdomain.pl Email Address: youremail@domain.p...

How to use NetStat cmd windows tool in PHP ?

Netstat  (Network Statistics) is a command-line tool that provides information about network connections, routing paths, interface statistics, and other aspects of the network. It is used to diagnose network problems and monitor network activity. Netstat Features Viewing active connections  : Netstat shows a list of all active TCP, UDP, and UNIX connections. Port Information  : You can get information about open ports and those that are listening. Protocol Statistics  : Netstat provides statistics for various protocols like TCP, UDP, ICMP. Routing Tables  : The tool shows the routing table, which is useful for analyzing the routes of packets in the network. Network Interfaces  : Netstat displays statistics for network interfaces, such as the number of packets sent and received. Netstat Usage Examples Displaying all connections and ports  : netstat -a Display only TCP connections  : netstat -at Display only UDP connections  : netstat -au Displ...

What is CerUtil in Windows ?

    The  CertUtil     command       is a versatile command-line tool used in Windows systems to manage certificate information. It is part of Certificate Services and allows you to perform various certificate-related tasks, such as: Making a backup:  It is always a good idea to make a backup of your current configuration before making any changes. You can use the command   certutil -backup  to make a backup. To back up Certificate Authority (CA) components using   CertUtil command  , you can use the following command: Creating a backup  : certutil -backupDB <path to backup folder> certutil -backupKey <path to backup folder> certutil -backupDB   creates a backup of the CA database. certutil -backupKey   creates a backup of CA private keys. Make sure you provide the correct path to the folder where you want to store your backups. Restoring a backup  : certutil -restoreDB <pa...

How to create a browser in codeblocks ?

Creating a full-fledged web browser is a complex task that requires advanced programming knowledge. Below, I’ll give you a general outline of how you can start building a simple program that can display the contents of a web page in an application window. Step 1:      Selecting the Graphics Library GTK+:    A popular GUI library offering a wide range of widgets and easy integration with various operating systems. Qt:    A powerful library, often used in commercial applications, but requiring more complex configuration. wxWidgets:    A cross-platform library offering native look and feel on different systems. Step 2:      Selecting a Network Support Library cURL:    A library for retrieving data from HTTP servers. libcurl:    A C++ version of cURL, offering a more object-oriented API. Step 3: Basic Program Structure Main Window:    Creates the main application window using the selected graphics lib...

How create browser extension ?

    Creating an extension for a browser like Google Chrome or Microsoft Edge is a process that can be broken down into a few steps. Here is the basic procedure: 1.  Configuring the extension folder and manifest file Create a new folder   on your computer where you will store all the files related to the extension. You can name it something like "MyFirstExtension". Add the file   manifest.json  to this folder. The manifest file contains metadata about the extension, such as name, version, description, and required permissions. Sample code for the file  manifest.json looks like this: { "manifest_version" : 3 , "name" : "My First Chrome Extension" , "version" : "1.0" , "description" : "A simple Chrome extension tutorial" , "icons" : { "48" : "icon.png" } , "permissions" : [ "tabs" , "activeTab" , "scripting...

Quickly change the owner in file details in Windows

  Quickly change the owner in file details in Windows .       The example below shows an element in a file that changes after the configuration is changed.       The item is highlighted in blue.   Below is the configuration. Right click on START in Windows. Run. In the search box type: netplwiz. And then OK. The following window should open .   Select the user and then select properties. The following window should appear.     In the username field, enter the new username, i.e. the owner of the files. Confirm, OK. OK. After everything, it will restart the computer. This is necessary.