DEV Community

Dhimas Kirana
Dhimas Kirana

Posted on

How to Install PHP on Windows 11

Hello, dev πŸ‘‹

In this tutorial, I will share a tutorial on how to install PHP on Windows 11.

Download PHP

First of all, you need to prepare the PHP module for the Windows. You can download it at the link https://windows.php.net/download/

Then you can choose the PHP version according to your needs. There are PHP 8.3, PHP 8.2, PHP 8.1 PHP 8.0, and PHP 7.4. I recommend just using the latest one, PHP 8.3.

Then there are x64 and x86 options. If your computer is 64-bit CPU, use x64, if 32-bit CPU, use x86.

There are the Non Thread Safe and Thread Safe options. If you are confused, I suggest just downloading the Thread Safe one.

Install PHP

After the PHP that we chose earlier has been downloaded, it’s time for us to install PHP on Windows.

Create a folder called php on drive C. Then unzip or extract the contents of the php zip file that you have to C:\php.

PHP Windows 11

Make sure all php files are successfully extracted to C:\php as shown above

Set Environment Variables

After we have prepared all the necessary files in the C:\php folder, we need to set the path to the Windows environment variable.

The step is to go to System’s Properties -> click Advanced System Properties -> select the Advanced tab. Click the Environment Variables button at the bottom.

Then in the System Variables section, look for a variable with the name Path, and click edit. Then click the New button, and enter C:\php. Then click OK to save, click OK again, and continue until the window exits.

Environment Variables Windows 11

Environment Variables Windows 11

Test PHP

To check whether PHP can be used, run the php -v command to check the version of PHP we are using.

Open the Windows terminal application, run the command php -v

PS C:\Users\dhimaskirana> php -v
PHP 8.3.3 (cli) (built: Feb 13 2024 23:17:12) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.3.3, Copyright (c) Zend Technologies
PS C:\Users\dhimaskirana>
Enter fullscreen mode Exit fullscreen mode

It should appear as above, showing the PHP version that we are using.

WordPress Requirement

We need to know that the PHP that we have installed is PHP by default, so the PHP extension has not been loaded automatically.We need a little configuration if we want to use PHP for WordPress.

According to sources from WordPress.org, to run WordPress properly there are several PHP extensions that WordPress recommends activating, there are:

  • json
  • mysqli atau mysqlnd
  • curl
  • dom
  • exif
  • fileinfo
  • hash
  • imagick
  • mbstring
  • openssl
  • pcre
  • xml
  • zip
  • memcached
  • opcache
  • redis

For example, we want to activate the MySQL extension so that PHP can communicate with the MySQL server.

Reopen C:\php where your PHP files are located. Look for a file with the name php.ini-development. Duplicate the file, then change the name of the duplicated file to php.ini.

Open the php.ini file using a text editor such as Notepad or VS Code.

PHP.ini WordPress Windows

Then uncomment or remove ; (semicolon) in front of some of the extensions that you need. Don’t forget to save the php.ini file again

Good luck 🍻

Top comments (0)