PHP (Hypertext Preprocessor) is one of the most widely used server-side scripting languages for web development. If you're a developer working with PHP on Windows 11, setting up the environment correctly is crucial. This guide will walk you through the steps of installing PHP.
Prerequisites
Before installing PHP, ensure you have the following:
- A Windows 11 computer
- Administrator access
- A text editor (Notepad++, VS Code, or any preferred editor)
Step 1: Download PHP for Windows
- Open your browser and visit the official PHP download page: https://windows.php.net/download.
- Scroll down to the "Windows downloads" section.
- Choose the latest Non-Thread Safe (NTS) x64 version suitable for your system (e.g., php-8.4.5-nts-Win32-vs16-x64.zip).
- Click on the ZIP file to download it.
Step 2: Extract PHP Files
- Locate the downloaded ZIP file.
- Right-click on it and select Extract All.
- For easier reading, rename the folder to php.
- Choose a directory for extraction, preferably C:\php, and extract the files.
๐ก Tip: Avoid using directories with spaces, such as 'C:\Program Files', as this may cause issues later.
Step 3: Configure PHP
Rename php.ini
Open the extracted C:\php folder.
Locate the file named
php.ini-development
.Rename it to
php.ini
.
Enable Essential Extensions
Open php.ini in a text editor and enable necessary extensions:
Find ;extension=mysqli and remove the semi-colon (;) to enable it.
Find ;extension=mbstring and remove the semi-colon (;) to enable it.
Find ;extension=curl and remove the semi-colon (;) to enable it.
Save the changes and close the file.
Step 4: Add PHP to Windows PATH
To run PHP from any location in the command prompt, we need to add it to the system PATH.
Press Win + R, type
sysdm.cpl
, and press Enter.In the System Properties window, go to the Advanced tab.
Click Environment Variables.
Under System variables, find Path and click Edit.
Click New, then type:
C:\php
(ensure this is the path to where the php folder previously installed is located).Click OK and close all windows.
Step 5: Verify PHP Installation
Open Command Prompt (Win + R, type cmd, and press Enter).
Type the following command and press Enter:
php -v
If PHP is installed correctly, you should see output similar to:
PHP 8.4.5 (cli) (built: ...)
Copyright (c) The PHP Group
Zend Engine v8.4.5, Copyright (c) Zend Technologies
Step 6: Test PHP (Optional)
To ensure PHP is working properly, create a simple test script.
Open your text editor and create a new file named
test.php
in C:\php.Add the following code:
<?php
phpinfo();
?>
Save the file.
Open Command Prompt, navigate to
C:\php
, and run:
php test.php
- If PHP is working correctly, a list of PHP settings will be displayed.
Conclusion
Congratulations! ๐ You have successfully installed and configured PHP on Windows 11. You can now start developing PHP applications locally. If you're using PHP for web development, consider installing a web server like Apache or Nginx and a database server like MySQL.
Let me know using the contact form if you encounter any issues or have additional questions. Happy coding! ๐