Installing PHP on Windows 10
I recently had to install the PHP executable on my laptop for my local Laravel dev. I had some issues, pulled out some hair so I wanted to post what happened when I tried installing PHP on Windows 10.
Just installed the local php.exe for Windows 10 on my laptop, had some issues and thought I would log for them for others and myself. I always seem to forget these things.
First thing, get yourself the PHP for Windows files, http://windows.php.net/. Get the version depending on whether you have 32bit or 64bit system. That said if you’re on Windows 10, you should not need to answer that; it should be 64bit.
The next question you will need to answer is TS or NTS, Thread Safe or Not Thread Safe. TS is primarily for PHP modules or Webserver like IIS. This install is for PHP CLI for Laravel development so go for the NTS version.
You can place the files anywhere you like, but I find it simpler to have it as close to the root as possible, c:\php. Create a PHP folder where ever you like and unzip your files there. The contents of c:\php should look like this.
Now it’s time to get your php.ini file configured for your environment. The first item is to update the extension_dir directive. This will need to point to your extension DLL’s folder. Mine is “C:\php\ext”. Now activate required extensions, here is a list of items I have activated.
To enable an extension, just remove the leading; from the start of the line.
; Windows Extensions ; Note that ODBC support is built in, so no dll is needed for it. ; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5) ; extension folders as well as the separate PECL DLL download (PHP 5). ; Be sure to appropriately set the extension_dir directive. ; ;extension=php_bz2.dll extension=php_curl.dll extension=php_fileinfo.dll extension=php_gd2.dll ;extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_intl.dll ;extension=php_imap.dll ;extension=php_interbase.dll ;extension=php_ldap.dll extension=php_mbstring.dll ;extension=php_exif.dll ; Must be after mbstring as it depends on it ;extension=php_mysql.dll ;extension=php_mysqli.dll ;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client extension=php_openssl.dll ;extension=php_pdo_firebird.dll extension=php_pdo_mysql.dll ;extension=php_pdo_oci.dll extension=php_pdo_odbc.dll ;extension=php_pdo_pgsql.dll extension=php_pdo_sqlite.dll ;extension=php_pgsql.dll ;extension=php_shmop.dll
Everything should be working at this point but to make things simple and allow you to use PHP instead of c:\php\php.exe when referencing you need to update your path files. On Windows 8 or 10 you can right-click the Start icon, select System from the list then click Advanced system settings (1). Now open the environment variables (2) and from here you can update your path. You should only need to update path (3) user variable, but I update in system variables as well (4), as I am the only user on my machine.
Now you should be able to open Powershell or CMD and enter
php -v will return the PHP version info similar to this.
PHP 5.6.20 (cli) (built: Mar 31 2016 14:55:55) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
Mine did not go this well, and when trying this command in Powershell, nothing would return. If this happens, you can get some more info on trying in the older cmd.exe. Hit your Windows Key, type cmd and press enter. You will now have cmd running, and you can try
php -v On my laptop, would get the following error.
--------------------------- php.exe - System Error --------------------------- The program can't start because MSVCR110.dll is missing from your computer. Try reinstalling the program to fix this problem. --------------------------- OK ---------------------------
Found installing Visual C++ Redistributable for Visual Studio 2012 Update 4, both the 32 and 64bit version did the trick. Now running php -v returned the version info and everything was Happy Happy, Joy Joy.
Hope this info has helped.
Leave a Reply