Install PHP on Windows

Install PHP on Windows

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:

  1. Download a non-thread safe version of PHP for windows from windows.php.net.
  2. Unzip it and put it somewhere on your computer. For example at C:/php/.
  3. Setup the .ini file by doing the following:
    1. Rename one of the .ini  files to ‘php.ini’. I generally use the development one: ‘php.ini-development’.
    2. Uncomment and change the ‘extension_dir’ to match the ‘ext’ directory of your install (e.g.: C:\php\ext)
    3. Uncomment the following Windows Extensions.  Others may need to be uncommented depending on what you are running.
      • extension=php_curl.dll
      • extension=php_file_info.dll
      • extension=php_mbstring.dll
      • extension=php_openssl.dll
  4. 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: php composer.phar.

Good luck!  Please comment if you noticed anything I forgot to add.

Casey

Hi! I'm Casey, a web developer/programmer, my goal with this blog is to share my experience with web programming to hopefully help others. I consider myself a jack of all trades programmer. While I'm more comfortable working in the back-end code I often find myself in the UX world. I'm primary a LAMP (Linux, Apache, MySQL, PHP) developer but have done some work with .NET, ColdFusion, and Java.

Leave a Reply

Your email address will not be published. Required fields are marked *