To install PHP on Windows Server 2022, follow these steps:
Step 1: Download PHP
- Go to the PHP for Windows website.
- Download the latest version of PHP. Choose the “Non-thread safe” version for IIS.
Step 2: Extract PHP
- Extract the downloaded ZIP file to a directory, e.g.,
C:\php
.
Step 3: Configure PHP
- Rename
php.ini-development
tophp.ini
. - Open
php.ini
in a text editor and configure the necessary settings:- Set the
extension_dir
directive to point to theext
directory within your PHP installation, e.g.,extension_dir = "C:\php\ext"
. - Enable required extensions by uncommenting lines (remove the
;
at the start of the line) for extensions you need, such as:iniCopyextension=mysqli
extension=gd
extension=mbstring
- Set the
Step 4: Add PHP to System Path
- Right-click on “This PC” and select “Properties.”
- Click on “Advanced system settings.”
- Click on the “Environment Variables” button.
- Under “System variables,” find and select the
Path
variable, then click “Edit.” - Add the path to your PHP installation (e.g.,
C:\php
) and click “OK.”
Step 5: Install IIS (if not already installed)
- Open Server Manager.
- Click on “Add roles and features.”
- Follow the wizard to install the Web Server (IIS) role.
Step 6: Configure IIS to Use PHP
- Open IIS Manager.
- Select your server in the left panel.
- In the middle panel, double-click on “Handler Mappings.”
- Click on “Add Module Mapping” in the right panel.
- Request path:
*.php
- Module:
FastCgiModule
- Executable:
C:\php\php-cgi.exe
- Name:
PHP_via_FastCGI
- Request path:
- Click “OK” and confirm any prompts.
Step 7: Test PHP Installation
- Create a new file named
info.php
in your web server’s root directory (e.g.,C:\inetpub\wwwroot\info.php
). - Add the following code to
info.php
:phpCopyphpinfo();
- Open a web browser and navigate to
http://localhost/info.php
. You should see the PHP information page.
Step 8: Restart IIS
- Open Command Prompt as Administrator.
- Run the command:
bashCopy
iisreset
Conclusion
You have successfully installed PHP on Windows Server 2022. You can now start developing and hosting PHP applications. In the next article I will show an easier way to install PHP.
Hope you find this helpful. Comment are welcome.
Installing PHP on Windows Server 2022 – Manual Way