Step by step guide on how to install PHP on Windows for the purpose of PHP Development.
I’ve found myself switching computers and installing new operating systems lately. With each computer change or OS install, I must install a fresh copy of PHP. It happens every couple years so I forget all the steps… A couple months back when I found myself installing it again I made sure to make a couple notes. Here is how to install PHP on Windows.
Please note this is just PHP, not a full server setup. I use PHP locally for development tasks and utilizing PHP-based dev tools like Composer, PHPUnit, PHPCS, etc. To run a PHP site you would also have to install a web server such as Apache and MySQL would also be handy.
Here we go:
- Download a non-thread safe version of PHP for windows from windows.php.net.
- Unzip it and put it somewhere on your computer. For example at C:/php/.
- Setup the .ini file by doing the following:
- Rename one of the .ini files to ‘php.ini’. I generally use the development one: ‘php.ini-development’.
- Uncomment and change the ‘extension_dir’ to match the ‘ext’ directory of your install (e.g.: C:\php\ext)
- Uncomment the following Windows Extensions. Others may need to be uncommented depending on what you are running.
- Setup PHP in your ‘Path’ Environment so you can run PHP globally by adding the path of your PHP install to the end of the Path variable (e.g. add ‘;C:\php’).
Now PHP is ready to go. You can test by opening a Command Prompt window and typing the PHP info commad:
php -i. Once PHP is installed, I’d suggest installing a couple other things: PEAR and Composer.
You can install PEAR by downloading the ‘go-pear.phar’ file from pear.php.net/manual/en/installation.getting.php and running it in PHP:
php go-pear.phar. Follow prompts, defaults are fine. Once the install is complete, run the registry update by double clicking the ‘PEAR_ENV.reg’ file that is generated.
To install Composer, download the PEAR file from getcomposer.org/download/. Run it with PHP to finish the install:
Good luck! Please comment if you noticed anything I forgot to add.