php installer windows installer
How to Install PHP on Windows 10 (with Apache & MySQL)
Learn PHP for free!
Make the leap into server-side programming with a comprehensive cover of PHP & MySQL.
This article explains how to install PHP 8 and Apache 2.4 on Windows 10 (64-bit).
Linux and macOS users often have Apache and PHP pre-installed or available via package managers. Windows 10 requires a little more effort. The steps below may work with other editions of Windows, PHP, and Apache, but check the documentation of each dependency for specific instructions.
Why PHP?
PHP remains the most widespread and popular server-side scripting language in web development.
It’s installed by most web hosts, and has a simple learning curve, close ties with the MySQL database, superb documentation, and an excellent collection of libraries to cut your development time.
PHP may not be perfect, but it should be considered as an option for your next web application. It’s the language of choice for Facebook, Slack, Wikipedia, MailChimp, Etsy, and WordPress — the Content Management System which powers 40% of the web.
Why Install PHP Locally?
Installing PHP on your development PC allows you to safely create and test websites and applications without affecting the data or systems on your live server.
Alternative Installation Options
Before you jump in, there may be a simpler installation options…
Use an All-in-One package
All-in-one packages are available for Windows which contain Apache, PHP, MySQL, and many other dependencies in a single installation file — such as XAMPP, WampServer and Web.Developer.
These packages are easy to use, but they may not exactly match your live server. Installing Apache and PHP manually will help you learn more about the system and configuration options.
Use a Linux Virtual Machine
Microsoft Hyper-V (provided in Windows 10 Professional) and VirtualBox are free hypervisors which emulate a PC so you can install another operating system.
You can install any version of Linux, then follow its Apache and PHP installation instructions. Alternatively, distros such as Ubuntu Server provide them as standard (although they’re rarely the latest editions).
Use Windows Subsystem for Linux 2
WSL2 is also a virtual machine, but it’s tightly integrated into Windows so activities such as file sharing and localhost resolution is seamless. You can install several Linux distros, so refer to the appropriate Apache and PHP instructions.
Use Docker
Docker creates a wrapper (known as a container) around pre-configured application dependencies such as Apache, PHP, MySQL, MongoDB, and most other web software. Containers look like full Linux Virtual Machines but are considerably more lightweight.
Docker is currently considered the best option for setting up a PHP development environment. Read our complete guide to setting up a PHP development environment with Docker.
Install Apache (optional)
If you’re still reading, the following sections describe how to install Apache and PHP directly on Windows.
PHP pages can then be viewed in a browser at http://localhost:8000.
This may be adequate for quick tests, but your live server will use Apache or similar web server software. Emulating that environment as closely as possible will prevent development errors.
To install Apache, download the latest Win64 ZIP file from https://www.apachelounge.com/download/ and extract its Apache24 folder to the root of your C: drive. You’ll also need to install the Visual C++ Redistributable for Visual Studio 2015–2019 ( vc_redist_x64 ); a link is provided on the same page.
Open a cmd command prompt (not PowerShell) and start Apache with:
You may need to accept a firewall exception before the server starts to run. Open http://localhost in a browser and an “It works!” message should appear. Note:
Also not that, if Apache won’t start, it’s likely another application is hogging port 80. (Skype is the prime candidate and the Windows 10 app won’t let you disable it!) If this occurs, edit C:\Apache24\conf\httpd.conf and change the line Listen 80 to Listen 8080 or any other free port. Restart Apache and, from that point onward, you can load web files at http://localhost:8080
How to Install PHP
Install PHP by following the steps below. Note that there are several ways to configure Apache and PHP, but this is possibly the quickest method.
Step 1: Download the PHP files
You’ll need the PHP Windows installer. There are a number of versions of PHP available. Make sure you get the latest PHP 8 x64 Thread Safe ZIP package from https://www.php.net/downloads.php.
Step 2: Extract the files
Create a new php folder in the root of your C:\ drive and extract the contents of the ZIP into it.
PHP can be installed anywhere on your system, but you’ll need to change the paths referenced below if C:\php isn’t used.
Step 3: Configure php.ini
There are several lines you may need to change in a text editor (use search to find the current value). In most cases, you’ll need to remove a leading semicolon ( ; ) to uncomment a setting.
First, enable any required extensions. This will depend on the libraries you want to use, but the following extensions should be suitable for most applications:
If you want to send emails using PHP’s mail() function, enter the details of an SMTP server in the [mail function] section (your ISP’s server should be suitable):
Step 4: Add C:\php to the path environment variable
To ensure Windows can find the PHP executable, you need to change the PATH environment variable. Click the Windows Start button and type “environment”, then click Edit the system environment variables. Select the Advanced tab, and click the Environment Variables button.
Scroll down the System variables list and click Path followed by the Edit button. Click New and add C:\php :
Note that older editions of Windows have a single text box where each path is separated by a semi-colon ( ; ).
Click OK until you’re out. You shouldn’t need to reboot, but you may need to close and restart any cmd terminals you have open.
Step 5: Configure PHP as an Apache module
Ensure Apache isn’t running and open its C:\Apache24\conf\httpd.conf configuration file in a text editor. Add the following lines to the bottom of the file to set PHP as an Apache module (change the file locations if necessary):
Optionally, change the DirectoryIndex setting to load index.php instead of index.html when it can be found. The initial setting is:
Save httpd.conf and test the updates from a cmd command line:
Syntax OK should appear … unless you have errors in your configuration.
Step 6: Test a PHP file
Create a new file named index.php in Apache’s web page root folder at C:\Apache24\htdocs and add the following PHP code:
Open a web browser and enter your server address: http://localhost/. A “PHP version” page will appear showing the various PHP and Apache configuration settings.
If you’re more comfortable with Linux, you might prefer to set up your PHP environment under Windows Subsystem for Linux 2. Check out our WSL2 guide and in-depth Windows Terminal tutorial for more.
Installation on Windows systems
Table of Contents
Installing PHP on modern Microsoft Windows systems and recommended configuration with common web servers.
The Official releases of PHP on Windows are recommended for production use. However, you are welcome to build PHP from Source. You will need a Visual Studio environment. See » Step by Step Build Instructions.
Installing PHP on Azure App Services (aka Microsoft Azure, Windows Azure, or (Windows) Azure Web Apps).
User Contributed Notes 12 notes
If you make changes to your PHP.ini file, consider the following.
(I’m running IIS5 on W2K server. I don’t know about 2K3)
PHP will not «take» the changes until the webserver is restarted, and that doesn’t mean through the MMC. Usually folks just reboot. But you can also use the following commands, for a much faster «turnaround». At a command line prompt, type:
and that will stop the webserver service. Then type:
and that will start the webserver service again. MUCH faster than a reboot, and you can check your changes faster as a result with the old:
in your page somewhere.
I wish I could remember where I read this tip; it isn’t anything I came up with.
You can have multiple versions of PHP running on the same Apache server. I have seen many different solutions pointing at achieving this, but most of them required installing additional instances of Apache, redirecting ports/hosts, etc., which was not satisfying for me.
Finally, I have come up with the simplest solution I’ve seen so far, limited to reconfiguring Apache’s httpd.conf.
Here it is (Apache’s httpd.conf contents):
—————————
# replace with your PHP4 directory
ScriptAlias /php4/ «c:/usr/php4/»
# replace with your PHP5 directory
ScriptAlias /php5/ «c:/usr/php5/»
# populate this for every directory with PHP4 code
Action application/x-httpd-php «/php4/php.exe»
# directory where your PHP4 php.ini file is located at
SetEnv PHPRC «c:/usr/php4»
# remember to put this section below the above
# directory where your PHP5 php.ini file is located at
SetEnv PHPRC «c:/usr/php5»
—————————
This solution is not limited to having only two parallel versions of PHP. You can play with httpd.conf contents to have as many PHP versions configured as you want.
You can also use multiple php.ini configuration files for the same PHP version (but for different DocumentRoot subfolders), which might be useful in some cases.
Remember to put your php.ini files in directories specified in lines «SetEnv PHPRC. «, and make sure that there’s no php.ini files in other directories (such as c:\windows in Windows).
Hope this helps someone.
If you are installing PHP on Vista just go to David Wang’s blog. http://blogs.msdn.com/david.wang/
archive/2006/06/21/HOWTO-Install-and-Run-PHP-on-IIS7-Part-2.aspx
I made the mistake of setting a ‘wildcard application map’ for PHP on a Windows 2003 / IIS 6.0 / PHP ISAPI installation.
This resulted in «No input file specified» errors whenever I tried to load the default page in my site’s directories. I don’t know why this broke things, but it did.
If anyone has the same problem, this may be the cause.
IIS setup: 403 forbidden error.
Despite this, php version 5.1.4 was being loaded. We renamed 5.1.4’s folder and then PHP was not loading at all.
There were no visible references to 5.1.4 in the IIS configuration, but in the file \webConfig.xml, there was a reference to 5.1.4’s isapi under IISFilters.
To fix this problem, we added version 5.2.5’s php5isapi.dll to the ISAPI Filter category for the web site, in the IIS control panel.
I installed by Microsoft Installer, manually, whatever I always received de same error from IIS7.
The IIS7 interface is quite diferent and are not all together like IIS6
The 5.3 version have not any of those files: php5stdll, php5isapi.dll. etc.
The installer puts others files in handlers and I decided to use them as substitutes. Nothing done!
After that, I discovered that installer do not install these files within the sites, but in the root default site configuration of IIS7.
So, I copied the root configuration to my site and them it worked (all others procedures were done e.g. copy php.ini to windows folder)
If you get 404 page not found on Windows/IIS5, have a look at C:\SYSTEM32\INETSRV\URLSCAN
Here’s how to run dual PHP instances with PHP 5.2 and any previous PHP on Windows 2003:
1. Right-click My Computer, go to Advanced tab, and click on Environment Variables.
Add the two installations and their EXT directories to the Path variable. For example, add:
c:\php;c:\php\ext;c:\TMAS\php;c:\tmas\php\ext;
Then, add the newer PHP version’s directory as a variable called PHPRC. For example:
Variable:PHPRC
Value: C:\PHP
Click OK to close the Environment Variables window, and click OK to close System Properties.
2. In registry, under HKEY_LOCAL_MACHINE>SOFTWARE>PHP, add a REG_SZ key called iniFilePath and give it a value
of the directory where the older PHP is installed. For example:
C:\TMAS\PHP
3. In IIS, go to the Web Service Extensions. Add both versions’ ISAPI module separately to the extensions
list, and allow both.
Testing Date: 05.15.09
Background:
For several days now I, as a newbie, have been unsure if I had installed PHP correctly, or not. No matter what I did phpinfo( ) reported «Configuratin File Path» as: “C:\WINDOWS”. I was left to wonder what was wrong.
To help resolve the phpinfo() “issue”, I conducted a series of tests using two scripts:
The first is “test-php-ini-loaded.php”; it is stored in c:\inetpub\wwwroot, and has the following code:
Install and Configure PHP
The fastest and easiest way to install PHP on Internet Information Services (IIS) is by using the MicrosoftВ® Web Platform Installer (Web PI). Web PI completely automates setting up IIS, FastCGI, and the latest version of PHP from the php.net Web site. With Web PI, you can navigate to the «Web Platform» tab and select «PHP» under «Framework and Runtimes» customize link. Alternately, use the instructions that follow as guidance for installing PHP with WindowsВ® Installer or using a compressed (Zip) file installation.
There are two builds for each PHP version: one is thread-safe, and one is not (referred to as the non-thread-safe [NTS] version). The thread-safe version is designed for environments where the Web server core can keep the PHP engine in memory, running multiple treads of execution for different Web requests simultaneously. The architecture of IIS and the FastCGI extension provide an isolation model that keeps requests separate, removing the need for a thread-safe version. The NTS version does not have any of the code that allows PHP to manage multiple threads. As a result, there is a performance improvement on IIS when using the NTS version when compared to the tread-safe version because the NTS version avoids unnecessary thread-safety checks (FastCGI ensures a single-threaded execution environment).
Install PHP
There are two main ways to install PHP on a WindowsВ®-based computer: download the Windows Installer or use the Windows Zip file from the PHP Web site. Either method will get PHP working, but both have some extra steps that are needed to make PHP work well.
Windows Installer
The Windows Installer version can get a complete PHP environment up and running, but the installation of extensions can be confusing. By default, no extensions are installed, and this can adversely affect the usefulness of the PHP installation. Alternately, all of the extensions can be installed; this results in an unstable system because some of the extensions can conflict with others. It is generally easier to use the Zip file installation.
Zip File Installation
To use the Zip file installation, follow the instructions in Using FastCGI to Host PHP Applications on IIS 7.0 and Above. The Zip file installation installs many of the extensions that are available for the Windows Installer version; however, none of the extensions are enabled until their entries in the Php.ini file are set up.
Download the latest non-thread-safe Zip file package with binaries of PHP. Under Windows Binaries, click on the most current PHP non-thread-safe Zip package to download the PHP files.
Unpack the files to a directory of your choice (for example, C:\PHP ) on your IIS server.
Rename the Php.ini-recommended to php.ini.
Open the Php.ini file in a text editor, then uncomment and modify settings as follows:
Set fastcgi.impersonate = 1.
FastCGI under IIS supports the ability to impersonate security tokens of the calling client. This allows IIS to define the security context that the request runs under.
Set cgi.fix_pathinfo = 0
The cgi.fix_pathinfo provides PATH_INFO/PATH_TRANSLATED support for Common Gateway Interface (CGI). Setting this to 1 will cause PHP CGI to fix its paths to conform to the specification.
Set cgi.force_redirect = 0.
Set open_basedir to point to a folder or network path where the content of the Web site(s) is located.
Set extension_dir to point to a location where PHP extensions reside. For PHP 5.2.X, this is typically extension_dir = «./ext».
Set error_log=»C:php_errors.log»
This can help with troubleshooting.
Enable the required PHP extension by un-commenting corresponding lines. More information follows in the section, Extensions.
Figure 1 Windows extensions
Click on Start, Settings, Control Panel, and then double-click on the System icon (using the class view).
Click on the Advanced system settings link in the left column.
From the System Properties window, click on the Advanced tab, and then click on the Environment Variables button at the bottom.
Select the Path variable from the System Variables section, and then click on Edit. Add: c:\php to your system path.
Figure 2: Edit System Variable
Click OK until you have exited the System Properties window.
Start IIS Manager by clicking on Start, Programs, Administrative Tools, and then Internet Information Services (IIS) Manager.
From the IIS Manager, click on the hostname of your server in the Connections panel on the left.
Double-click on the Handler Mappings icon.
Figure 3: Internet Information Services (IIS) Manager
From the Handler Mappings Actions panel, click on Add Module Mapping.
Figure 4: Handler Mappings
Type the following information into the appropriate text boxes, and then click OK.
Figure 5: Add Script Map
Click OK, and then c lick Yes.
In the left panel, click on your server’s hostname, and then double-click on the Default Document icon.
From the Actions panel on the right, click Add.
Enter index.php as the new default document name, and then click OK.
Enter default.php as the new default document name, and then click OK.
In the left panel, click on your server’s hostname.
In the Actions panel on the right, click Restart.
Create a new text document, and save it as c:\inetpub\wwwroot\phpinfo.php with the following content:
Figure 6: PHP information page
Extensions
It is important to determine which extensions are needed by the applications that will be running and then to limit the installed extensions to only those. For a typical open-source application installation, for example, the following extensions are installed:
PHP.INI File Settings
The Php.ini file provides PHP with configuration and environmental information. Below are a number of settings for the Php.ini file that help PHP work better with Windows.
Required Settings
Optional Settings
Enable PHP Session State
In WindowsВ® Explorer, create the session subdirectory in the PHP installation directory.
Right-click the session directory, and select Properties.
In the Security tab, click Edit.
Click Add, and enter IIS_IUSRS for Enter the object names to select.
Click OK.
Select the Modify permission check box, and click OK.
Figure 7: Permissions for session folder
Click OK in the Session Properties window.
Open php.ini in the PHP installation directory, and set the session.save_path setting to the session subdirectory:
Save and close the file.
Click Start, and then select Command Prompt.
Type runas /user:administrator cmd.exe to enable elevated permissions.
Type iisreset at the command prompt, and then press the ENTER key.
Figure 8: IISRESET command
Note that PHP uses file-based session state by default. You can modify a number of additional session settings, including whether cookie or URL sessions should be used, and whether sessions are created on the first request or need to be explicitly created.
Create a folder and rename it phpapp.
Create session.php in the phpapp directory.
Paste the following into it:
Save and close the file.
Figure 9: Using session state
Observe that the counter is 1.
Request http://localhost/phpapp/session.php again, or press F5.
Figure 10: Using session state
Observe that the counter is 2.
This article uses information from «Using FastCGI to Host PHP Applications on IIS 7.0 and Above» by Ruslan Yakushev, published on December 5, 2007.
PHP installation on windows
I want to install php in my system.For this I have downloaded the php-5.3.5.tar.bz2 (zip file). Now from this installation help link http://www.php.net/manual/en/install.windows.installer.msi.php It is saying «Run the MSI installer and follow the instructions provided by the installation wizard. «
But i am not getting from where I can get MSI installer?
10 Answers 10
Choose the latest PHP x.y.z (Current stable) For IIS, download the non-threadsafe zip file
Extract the downloaded zip file to c:\PHP
Download PHP-Manager for IIS 7 (that’s an IIS-controlpanel-extension, also works for IIS 8) from https://github.com/phpmanager/phpmanager/releases (make sure you choose the right bitness (32 vs. 64)
Open the IIS management console (inetmgr.exe)
Double-click PHP-Manager and click on «register new PHP installation»
(note to self: never remove the PHP directory, otherwise «rien ne va plus»)
Create a new file called hello.php in c:\inetpub\wwroot with this content
10. open cmd.exe and execute «iisreset»