- How to Install PHP on Windows
- Prerequisites
- Possible Ways to Install PHP on Windows
- Manual Installation
- All-in-One Packages
- Using a .msi Installer
- How to Install PHP on Windows Manually
- Download and Extract the PHP Package Files
- Configure the php.ini Configuration File
- Configure the PATH Environment Variable
- Installing With an All-in-One Package
- How to Install PHP Extensions
- Learn PHP With a Free Online Course
- Как установить PHP на Windows
- Скачать PHP:
- Установка PHP:
- Тест PHP:
- Installation on Windows systems
- Table of Contents
- User Contributed Notes 12 notes
How to Install PHP on Windows
In this article, we’re going to discuss how to install PHP on Windows. There are three different ways to install and run PHP on Windows, and we’ll look at each one.
PHP is a server-side scripting language which is mostly used to build web applications—these may range from a very simple blog website to a full-fledged eCommerce store. In fact, PHP is one of the most popular server-side scripting languages for web development.
In the next section, we’ll go through the prerequisites for installing PHP on your Windows computer.
Prerequisites
Before we install PHP, let’s make sure of the following things.
The first thing to check is the Windows version. If you’re using a Windows version older than Windows 2008/Vista, you won’t be able to install PHP versions that are greater than 5.5. As per the official documentation, as of the PHP 7.2.0 version, Windows 2008 and Windows Vista are not supported.
Thus, it’s important to be sure that your Windows version aligns with the PHP version you want to install.
In the next section, we’ll discuss different ways to install PHP. If you want to install PHP manually, you should be comfortable editing a few system files since that is part of the manual installation process. On the other hand, if you just use the all-in-one package, it will be pretty straightforward, and all the configuration will happen automatically.
Today, we’re going to install the latest stable version of PHP, which is 7.4. In fact, PHP has several different versions, and if you want to install a different version of PHP and are facing any difficulties, drop me a line in the comments section and I’ll be happy to help.
With that out of the way, let’s get started installing PHP!
Possible Ways to Install PHP on Windows
In this section, I’ll briefly discuss the different ways you can install PHP on Windows.
Manual Installation
In the manual installation process, apart from downloading the PHP package, you need to go through a couple of steps to properly configure it. As I said earlier, if you prefer manual installation, you should be comfortable enough to edit a few configuration files in the text editor.
All-in-One Packages
There are a couple of popular Windows PHP distributions that come as all-in-one packages. Apart from PHP, these also install and configure the Apache web server and a MySQL database server. These packages are really useful for developers who want to set up and run the full web development stack quickly and easily.
XAMPP and WampServer are two of the most popular Windows distributions among the PHP community.
Using a .msi Installer
I would say this was one of the easiest and most preferred ways to install PHP among newbies. But it’s deprecated and not recommended anymore. To install PHP with an installer, you just need to download the .msi installer and run it to install PHP just like any other software you install on Windows.
However, as of PHP 5.4.0, you won’t find the .msi installer files on the PHP downloads page. So this is only going to be useful if you want to install an older PHP version. As it’s deprecated, we won’t discuss this installation method in detail.
How to Install PHP on Windows Manually
In this section, we’ll go through the steps that are required in order to install PHP in your Windows installation manually.
Download and Extract the PHP Package Files
The first thing you have to do is to download the PHP package file of your choice from the official PHP downloads page.
You’ll find .zip files available for both x86 and x64 systems, so make sure to download the correct one as per your Windows OS architecture. Also, you’ll have to choose either to download the non-thread-safe or thread-safe version of PHP. If you’re planning to run PHP as an Apache module, the thread-safe version is recommended. However, if you want to run PHP as a CGI module, you can choose either of them!
Next, you need to extract the .zip file in the directory where you want to install PHP. A common install location is C:\php. Create the php directory and extract the .zip file contents inside the C:\php directory.
Configure the php.ini Configuration File
In this section, we’ll discuss the necessary changes you need to make in the php.ini configuration file.
The PHP package that you’ve just downloaded already contains two different versions of the configuration file: php.ini-development and php.ini-production. The php.ini-development file is designed and configured for your local development. This has a lot of features enabled which make it easier to test and debug your code, but it makes your software run slower and is not secure for a live site. On the other hand, the php.ini-production file is designed for optimum performance and security. We’re going to use the php.ini-production file.
As PHP detects the php.ini file as its configuration file, you’ll have to copy the file which you choose for your local development, and rename it to the php.ini file. As we’re going to use the production version, copy the php.ini-production file to the C:\php\php.ini file.
Next, open the php.ini file in your favorite text editor and find the following line.
It’s the path of the PHP extensions directory, and let’s change it as shown in the following snippet.
It’s important to note that we’ve also removed the semicolon in front of the line to make sure it’s not commented. Of course, you need to adjust the above path to match your installation directory.
And with that, we’ve finished the php.ini configuration file changes.
Configure the PATH Environment Variable
In this final section, we’ll see how to add the PHP installation path to the PATH environment variable. The process of updating the PATH variable in Windows changes from version to version. I’ll show you how to change it in Windows 10, but feel free to ask me if you’re using a different version.
In the Windows search bar, just type the environment keyword and choose Edit the system environment variables in the search results. Go to the Advanced > Environment Variables section. Edit the PATH environment variable and add ;C:\php to the end. This will make it so you can run PHP just by typing php from the command prompt, no matter what folder you’re in.
Finally, reboot the system, and you’re done. You’ve successfully installed PHP in your Windows installation!
Installing With an All-in-One Package
As I mentioned earlier, XAMPP and WampServer are popular all-in-one packages that allow you to install PHP along with the other essential web development components like a web server and database server.
Irrespective of the tool you choose, the process of installing these tools is pretty straightforward. You just need to download the corresponding installer and run it to install it in your Windows installation. We won’t go into the details of this, but if you have any queries regarding this, feel free to post them.
In the next section, we’ll see how to enable specific PHP extensions in your PHP installation.
How to Install PHP Extensions
In this section, we’ll see how to enable PHP extensions.
Every time you want to enable a specific extension in PHP, you just need to find the associated entry in the php.ini configuration file and uncomment it.
For example, let’s say you want to enable the mysqli extension. Then you need to search for the extension=mysqli entry in the php.ini file and uncomment it, as shown in the following snippet.
In the same way, you can enable other extensions as well.
Learn PHP With a Free Online Course
If you want to learn PHP, check out our free online course on PHP fundamentals!
In this course, you’ll learn the fundamentals of PHP programming. You’ll start with the basics, learning how PHP works and writing simple PHP loops and functions. Then you’ll build up to coding classes for simple object-oriented programming (OOP).
Along the way, you’ll learn all the most important skills for writing apps for the web: you’ll get a chance to practice responding to GET and POST requests, parsing JSON, authenticating users, and using a MySQL database.
Как установить PHP на Windows
В этой статье вы узнаете как установить php 7.0 и выше на Windows 10, очень просто, надеюсь эта статья будет полезна для вас.
Скачать PHP:
Сначала вам надо скачать PHP 7 для Windows 10 c сайта или для Windows 7, для этого заходим по ссылки, там нажимаем на Zip.
Как можете заметить, я скачиваю тут x64 битную, но не переживаете, там также вы можете скачать x32 битную версию, для этого надо прокрутить чуть ниже и найти, где будет написано x86, если в друг у вас архитектура не x64.
Установка PHP:
После того как скачали сам PHP, пришло время его установить, для архивируем архив который скачали, и создаём папку куда положим все файлы.
Как можете заметить, я поместил все файлы в папку в документах, но это ещё не всё.
Теперь на надо добавить PHP в path, чтобы была возможность запускать PHP скрипты из командной строки, для этого заходим в «Этот компьютер» и там нажимаем правой кнопкой мыши, выбираем «Свойства».
Дальше в открывшемся окне с боку выбираем «Дополнительные параметры системы».
В открывшемся окне нажимаем на кнопку «Переменные среды…».
В открывшемся окне выбираем внизу «Path» и нажимаем кнопку изменить.
Нажимаем «Создать» и вписываем путь, куда вы архивировали ваш PHP, на этом всё и заканчивается, поздравляю вас, вы установили и подключили PHP.
Тест PHP:
Теперь не большой тест, что бы наперника проверить что мы правильно установили PHP, для этого открываем блокнот и делаем не большую PHP программу.
Installation on Windows systems
Table of Contents
Installing PHP on modern Microsoft Windows systems and recommended configuration with common web servers.
If you are looking for information about older systems, such as Windows XP, 2003, 98 or Apache 1.x, see the Legacy Info section.
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:
net start w3svc
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.
My goal is to have PHP5 as the default scripting language for .php files in my DocumentRoot (which is in my case d:/htdocs), and PHP4 for specified DocumentRoot subdirectories.
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/»
AddType application/x-httpd-php .php
Action application/x-httpd-php «/php5/php-cgi.exe»
# 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).
And finally, as you can see, I run PHP in CGI mode. This has its advantages and limitations. If you have to run PHP as Apache module, then. sorry — you have to use other solution (the best advice as always is: Google it!).
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.
We had installed two separate different PHP versions — PHP 5.1.4 followed by 5.2.5.
We configured 5.2.5 php5isapi.dll to be loaded as the .php file type extension.
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.
HTTP Error 404.3 — Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
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
There is a .ini file there that prevents some files from being served by IIS, even if they exist, instead IIS will give a 404. The urlscan logfile (same place) should give you some insight into what parameter is preventing a page from loading, if any.
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.
4. In IIS, go to each website utilizing the PHP versions. Set an ISAPI filter if needed. On the Home Directory
tab, click Configuration, and add .php, .php3, .phtml, and any other extensions needed (perhaps .html?) to
be filtered through PHP, and specify the ISAPI module version needed for each website.
You can now run two versions of PHP. This is because the order of where to look for the .ini file changed
between previous PHP versions and PHP 5.2, as documented at http://us2.php.net/ini:
* SAPI module specific location (PHPIniDir directive in Apache 2, -c command line option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH environment variable in THTTPD)
* The PHPRC environment variable. Before PHP 5.2.0 this was checked after the registry key mentioned below.
* HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath (Windows Registry location)
* Current working directory (for CLI)
* The web server’s directory (for SAPI modules), or directory of PHP (otherwise in Windows)
* Windows directory (C:\windows or C:\winnt) (for Windows), or —with-config-file-path compile time option
—————————————————-
PHP 5.2.9.2 Install on XP Pro IIS 5.1 — phpinfo( ) results incorrect
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:
if ( $inipath ) <
echo ‘Loaded php.ini: ‘ . $inipath ;
> else <
echo ‘A php.ini file is not loaded’ ;
>
?>
The second script is simply calls phpinfo( ). It is named test.php, is stored in “c:\inetpub\wwroot”, and has the following code:
( ); ?>
My Dev Environment:
1. Windows XP Pro SP3
2. IIS 5.1 / MMC 3.0
3. PHP 5.2.9.2 – phpMyAdmin not yet installed
4. (plus MySQL 5.1, etc.)
5. Install location is on my local E: drive