How To Install PHP In Windows 10
To start programming with PHP is one of the parts of web development skills and installing PHP In on your Windows 10 machine considered as the first step of learning PHP skill using a local machine. Here we discuss the various method to Install PHP In Windows 10 OS.
- Install PHP in Windows OS using the PHP development environment.
- Manually install PHP by PHP official file Setup.
Install PHP in Windows 10 OS using XAMPP
According to my personal experience, on the time of beginner in PHP development, I always prefer XAMPP as my local server to run PHP files and also do project work. XAMPP stands for cross-platform, Apache, MySQL, PHP, and Perl. You also use it for installing and create the site on WordPress offline or on your local server.
Now we check how we install XAMPP in our Windows machine step by step,
First, you have to check your system configuration. To check the configuration right click on This PC or My Computer then click on properties, there you can see like below. In my case,
Step 1: Then we have to download the EXE file of the XAMPP server from the official site https://www.apachefriends.org/download.html.
Step 2: After completing the download click on the .exe setup file,
Step 3: Click NEXT and then you can see all the check ticks on all options then click on NEXT.
Step 4: Now after the above screen we can see the selected path where XAMPP can install. You can also specify the installation path according to your choice by changing the same.
Step 5: Now click next on multiple-step then installation starts automatically and after completing the installing of XAMPP, you can see the XAMPP control panel.
Now you can ready with your PHP installation on Windows 10 OS using external PHP development environment XAMPP.
Manually install PHP on Windows by PHP official File Setup
Now we see quickest steps to install PHP on Windows 10 . Noted that there are others ways available out there to install PHP Apache server.
Step 1: Download the PHP files
Get the latest version of PHP Zip package according to your system configuration from here,
https://www.php.net/downloads.php
Step 2: Extract the ZIP
Extract the PHP zip file and create a new directory named PHP and store it on you C: drive.
PHP can be installed any drive on you windows system but for future steps I suggest you to do not change the path.
Step 3: Setting up PHP configuration file php.ini
On the very first time you can not find the php.ini file. so you have to copy C:\php\php.ini-development to C:\php\php.ini
On the same config INI file you have to enable some important PHP extension by removing semi colon (;) from their start.
Open you the php.ini file in your text editor and search for below extension and enable them.
And if you want to send mail using the localhost, you can check Send Mail From Localhost in PHP Using XAMPP.
Step 4: Add PHP location on PATH environment variable
We have to set the our PHP path to environment variable, so OS can find the PHP executable.
To reach environment variable Click on Advance System Setting,
Then click on Environment Variable and click on PATH > Edit. Now you can create new variable.
Step 5: Setup Apache Module
First check Apache is not running in background then open the file C:\Apache24\conf\httpd.conf and put the below code at last line of the file.
# PHP8 module
PHPIniDir “C:/php”
LoadModule php_module “C:/php/php8apache2_4.dll”
AddType application/x-httpd-php .php
Step 6: Test PHP File
Create a new file named index.php in Apache’s root directory at C:\Apache24\htdocs and write the following PHP code which prints the information about you PHP server.
Now open your browser and write on URL bar http://localhost/index.php or any other file name to run.
Here is the complete step by step process to install PHP in Windows 10 or any the windows version.
How to install PHP in windows 10 ?
PHP is a general-purpose scripting language geared towards web development. PHP is open-source software ( OSS ). PHP is free to use and download. PHP stands for PHP Hypertext Preprocessor. PHP file have extension called .php. PHP supports many databases MySQL, Oracle, etc. PHP is free to download and use. It was created by a Danish Canadian and designed by Rasmus Lerdorf in 1994. The common websites that are used are eCommerce, Social Platforms, Email Hosting, etc.
Installing PHP on Windows:
Follow the below steps to install PHP on Windows:
Step 1: Visit https://www.php.net/ website using any web browser and click on Downloads.
Step 2: Click on the Windows “Downloads” button.
Step 3: The new webpage has different options, choose the Thread safe version, and click on the zip button and Download it.
Step 4: Now check for the executable file in downloads in your system and extract it.
Step 5: After extracting, you get the extracted folder.
Step 6: Now copy the extracted folder.
Step 7: Now paste the copy folder in your windows drive in the Program files folder.
Step 8: Now the Permission Windows appears to paste the folder in program files then click on “Continue”.
Step 9: Now after pasting the folder then copy the address of the folder in program files.
Step 10: Now click on Start Menu and search “Edit the system environment variables” and open it.
Step 11: After opening System, Variable New window appears, and click on “Environment Variables…”
Step 12: Now go to the “System variables” Path option and double click on Path.
Step 13: Next screen will open and click on the “New” button.
Step 14: After New Paste the address we copy from program files to new and click on Enter button.
Step 15: Now Click on the OK button.
Step 16: Click on the OK button.
Step 17: Click on OK for saving changes.
Step 18: Now your PHP is installed on your computer. You may check by going to the “Start” menu typing Command Prompt. Open it.
Step 19: When the Command Prompt opens, type php -v
Step 20: Now enter the command prompt to show the version of PHP installed on your computer.
Установка PHP 8 на Windows 10
Найти дистрибутив PHP можно по адресу https://windows.php.net/download#php-8.2 Выберите версию Thread Safe .
В папке c:\WebServer\WAMP\ создайте новую папку PHP и скопируйте туда содержимое архива php-8.2.5 — VS16 x64 Thread Safe (2023-Apr-12 09:19:44) .
Настройка конфигурационного файла php.ini
С помощью Notepad++ открываем php.ini-development в папке c:\WebServer\WAMP\PHP\ и сохраняем его как php.ini , и вносим в него следующие изменения .
Для этого находим строку – 768 :
И заменяем ее на :
Теперь найдите строки: Начинается со строки 920 .
И заменим их на :
Заменим строки: – начинаются со строки 950.
Указываем кодировку по умолчанию . Для этого находим строку – 720 :
Находим строку – 746:
Предварительно создадим папку includes в C:\WebServer\home\
Здесь будут хранится подключаемые файлы PHP .
Заменим строку – 970:
Сохраняем и закрываем файл php.ini .
Теперь необходимо вписать поддержку PHP в файл конфигурации сервера Apache . Открываем файл httpd.conf и в конец файла добавим строки :
Сохраняем и закрываем файл httpd.conf .
Настройка переменной среды
Далее необходимо добавить каталог с установленным интерпретатором PHP в переменную PATH операционной системы Windows 10 . Для этого нажмите кнопку Пуск на Windows 10 , начните набирать «Изменение системных переменных среды» и откройте соответствующее окно настроек.
Изменение системных переменных среды
В открывшемся окне выбираем в самом низу пункт переменные среды .
В следующем открывшемся окне :
Выберем пункт path и нажимаем изменить .
В следующем открывшемся окне :
Выбираем пункт создать и в открывшейся строке напишите C:\WebServer\WAMP\PHP\ и выбираем пункт вверх и подымаем нашу строку к вверху , и нажимаем кнопку Ok , как на рисунке ниже .
Во всех открытых окнах нажимаем Ok , все окна переменной среды path закрываем . После данных изменений следует перезагрузить компьютер .
После перезагрузки компьютера , открываем Notepad++ и набираем следующий код :
Сохраняем файл в каталоге c:\WEbServer\home\www\ с названием i.php
В адресной строке Web – браузера набираем : http://localhost/i.php , если вы увидите данные о интерпретаторе PHP , как на рисунке , то значит все настройки сделали правильно и PHP работает .
Версия PHP
Установка PHP завершена , если при выполнении примеров появляются ошибки ошибки , то проверяйте все в конфигурационные файлы , перезагружаем сервер и снова пробуем достичь желаемого результата.
И помните после каждого изменения конфигурационных файлов и исправлении ошибок , нужно чистить историю Web – браузера , может так получится вы нашли исправили ошибку , перезагрузили сервер , а Web – браузер выдает вам файлы из истории , и вы видите при загрузке опять ошибку .
Installation on Windows systems
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:
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
<Directory «d:/htdocs/some_subdir»>
Action application/x-httpd-php «/php4/php.exe»
# directory where your PHP4 php.ini file is located at
SetEnv PHPRC «c:/usr/php4»
</Directory>
# remember to put this section below the above
<Directory «d:/htdocs»>
# directory where your PHP5 php.ini file is located at
SetEnv PHPRC «c:/usr/php5»
</Directory>
—————————
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 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.
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
Still Can’t Run PHP Code?
After installing php-5.2.5-win32-installer.msi on my Windows XP2. with IIS5.1 it still didn’t run PHP files.
I eventually found the fix*:
1. Goto Control Panel>System>Advanced>Environmental Variables
2. Add a New System Variable «PHRC» and set its path as «C:\Program Files\PHP»
3. Restart
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.
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)
In order to run php scripts with php.exe CGI instead of php4isapi.dll under IIS, following steps can be followed.
i) Add a web service extension for PHP using IIS manager. Choose a web service extension name like ‘PHP’ and add your php.exe path in the ‘file location’ while adding the required file e.g. ‘C:\php\php.exe’ in the Add extension dialog box. Don’t forget to ‘Allow’ the extension file.
ii) Open php.ini file located at %systemroot%. Set the following variables to the shown values.
cgi.force_redirect = 0
cgi.redirect_status_env = ENV_VAR_NAME
iii) In your websites, add Application Mapping for ‘.php’ and set the executable path to your php.exe file path.
You can test whether PHP is running or not and other PHP settings using the following simple PHP script.
Feroz Zahid
ferozzahid [_at_] usa [_dot_] [_com_]
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
—————————————————-
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.
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:
<?php
$inipath = php_ini_loaded_file ();
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:
<?php phpinfo ( ); ?>
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