Found A Problem?
SmugWimp at smugwimp dot com ¶
19 years ago
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:
iisreset /stop
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:
<?php>
phpinfo();
?>
in your page somewhere.
I wish I could remember where I read this tip; it isn't anything I came up with...
lukasz at szostak dot biz ¶
19 years ago
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.
jp at iticonsulting dot nl ¶
19 years ago
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.
Последнее обновление: 25.11.2023
Есть разные способы установки всего необходимого программного обеспечения. Мы можем устанавливать компоненты по отдельности, а можем использовать уже готовые
сборки на подобие Denwer или EasyPHP. В подобных сборках компоненты уже имеют начальную настройку и уже готовы для создания сайтов. Однако рано или поздно разработчикам
все равно приходится прибегать к установке и конфигурации отдельных компонентов, подключения других модулей. Поэтому мы будем устанавливать все компоненты по отдельности.
В качестве операционной системы будет использоваться Windows.
Что подразумевает установка PHP? Во-первых, нам нужен интерпретатор PHP. Во-вторых, необходим веб-сервер, например, Apache, с помощью которого мы сможем обращаться
к ресурсам создаваемого нами сайта.
Для установки PHP перейдем на офсайт разработчиков https://www.php.net/downloads. На странице загрузок мы можем найти различные дистрибутивы
для операционной системы Linux. Если нашей операционной системой является Windows, то нам надо загрузить один из пакетов со страницы https://windows.php.net/download.
Интерпретатор PHP имеет две версии: Non Thread Safe и Thread Safe. В чем разниц между ними?
Версия Thread Safe
позволяет задействовать многопоточность, тогда как Non Thread Safe
— однопоточная версия.
Выбрем версию Thread Safe.
Распакуем загруженный архив в папку, которую назовем php. Пусть эта папка у нас будет располагаться в корне диска C, а ее полный путь будет C:\php.
Теперь нам надо выполнить минимальную конфигурацию PHP. Для этого зайдем в распакованный архив и найдем там файл php.ini-development.
Это файл
начальной конфигурации интерпретатора. Переименуем этот файл в php.ini и затем откроем его в текстовом редакторе.
Найдем в файле строку:
;extension_dir = "ext"
Эта строка указывает на каталог с подключаемыми расширениями для PHP. Расширения позволяют задействовать нам некоторую дополнительную функциональность,
например, работу с базой данных. Все расширения находятся в распакованном каталоге ext.
Раскомментируем эту строку, убрав точку с запятой и укажем полный путь к папке расширений php:
extension_dir = "C:\php\ext"
Остальное содержимое файла оставим без изменений.
Теперь установим веб-сервер.
Last Updated :
09 Sep, 2024
PHP is a general-purpose scripting language geared towards web development. It is an open-source software (OSS), which is free to download and use. PHP stands for «Hypertext Preprocessor». PHP files are saved with an extension called .php. It supports many databases MySQL, Oracle, etc.
Installation of PHP on Windows
Follow the below steps to install PHP on Windows:
Step 1: Visit https://www.php.net/downloads 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 zip 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.
Finally, You have successfully installed PHP on your Windows 10 system.
If you’re looking to develop with PHP on a Windows system, knowing how to install PHP on Windows is essential for setting up your development environment. Installing PHP on Windows can seem a bit tricky at first, but with the right steps, it’s a straightforward process. In this guide, we’ll walk you through how to install PHP on Windows, including configuration and verification, so you can start coding in PHP smoothly and efficiently. Whether you’re a beginner or an experienced developer, these steps will help you get up and running with PHP in no time.
Prerequisites
- A Windows machine with administrative access.
- An internet connection to download PHP and related files.
1: Download PHP
- Visit the PHP Website
Go to the official PHP download page to get the latest stable version of PHP for Windows. - Choose the Thread-Safe Version
Under the Windows downloads section, select the “Thread Safe” version, as it is recommended for web server usage. Download the ZIP file (e.g.,php-8.x.x-Win32-vs16-x64.zip
).
2: Extract the PHP Files
- Locate the Downloaded File
Navigate to your downloads folder and locate the ZIP file you downloaded. - Extract PHP to a Folder
Right-click the ZIP file, select “Extract All,” and chooseC:\php
as the destination folder. This is the recommended location for easy configuration, but you can use a different path if needed.
3: Configure PHP Environment Variables
To use PHP from the command line, you’ll need to set it in your system’s PATH environment variable.
- Open Environment Variables
- Go to Start, type “Environment Variables,” and select Edit the system environment variables.
- In the System Properties window, click on Environment Variables.
- Add PHP to the Path
- Under System Variables, find the
Path
variable and click Edit. - Click New and add the path to your PHP folder (e.g.,
C:\php
). - Click OK to save and close all windows.
- Under System Variables, find the
4: Configure php.ini
The php.ini
file allows you to configure PHP’s behavior.
- Locate the
php.ini
File
In theC:\php
directory, you’ll see two files:php.ini-development
andphp.ini-production
. Choose one based on your environment:- For development, rename
php.ini-development
tophp.ini
. - For a live server, rename
php.ini-production
tophp.ini
.
- For development, rename
- Edit Key Settings
Open thephp.ini
file in a text editor (like Notepad) and set the following parameters:- Enable Extensions: Uncomment lines for any extensions you need by removing the semicolon (
;
) in front of them, e.g.,extension=mysqli
. - Set Timezone: Search for
date.timezone
and set it to your timezone (e.g.,date.timezone = "America/New_York"
).
- Enable Extensions: Uncomment lines for any extensions you need by removing the semicolon (
- Save and Close
Save the changes and close the file.
5: Verify PHP Installation
- Open Command Prompt
PressWin + R
, typecmd
, and press Enter to open the command prompt. - Check PHP Version
Typephp -v
and press Enter. If PHP is installed correctly, it will display the version and other details.
6: Run a Test PHP Script
Now, let’s ensure PHP is working by creating a simple script.
- Create a PHP File
Open a text editor and type the following PHP code:phpCopy code<?php echo "Hello, PHP is working!";
Save the file astest.php
in yourC:\php
directory or any directory of your choice. - Run the PHP Script from Command Line
In the command prompt, navigate to the directory where you savedtest.php
and run:Copy codephp test.php
You should see the output:Hello, PHP is working!
.
7: Integrate PHP with a Web Server (Optional)
If you want to run PHP scripts via a web server, you can install a local server like Apache or Nginx.
Option A: Install XAMPP or WAMP (Recommended for Beginners)
- XAMPP and WAMP are all-in-one packages that include Apache, PHP, and MySQL.
- Download and install one of these packages, and it will automatically configure PHP with Apache.
Option B: Manual Apache Configuration (Advanced Users)
Restart Apache, and PHP should be configured to work with your server.
Download and install Apache.
Open Apache’s httpd.conf
file and add the following lines to configure PHP:apacheCopy code# Add to the end of httpd.conf LoadModule php_module "C:/php/php8apache2_4.dll" AddHandler application/x-httpd-php .php PHPIniDir "C:/php"
Conclusion
And there you have it! You’re now ready to start learning PHP and build interactive web pages on your Windows machine. For more in-depth tutorials, don’t hesitate to visit Newtum. Dive deeper, experiment, and happy coding!
Edited and Compiled by
This blog was compiled and edited by Rasika Deshpande, who has over 4 years of experience in content creation. She’s passionate about helping beginners understand technical topics in a more interactive way.
About The Author
Разберемся, как установить php на компьютер с Windows, после чего можно будет написать первую программу.
Шаг 1. Заходим в раздел Downloads официального сайта и скачиваем архив с версией PHP для Windows.
Шаг 2. Создаем папку в любом удобном месте и распаковываем в неё архив.
Шаг 3. Копируем путь к папке с PHP.
Шаг 4. Нажимаем сочетание клавиш Win + R для открытия окна «Выполнить», вводим sysdm.cpl и жмем Enter.
Шаг 5. В открывшемся окне «Свойства системы» переходим на вкладку «Дополнительно» и нажимаем на кнопку «Переменные среды…»
Шаг 6. В окне «Переменные среды» в разделе «Системные переменные» выбираем Path и нажимаем кнопку «Изменить…»
Шаг 7. В окне «Изменить переменную среды» нажимаем кнопку «Создать», вставляем путь к папке, удаляем кавычки и жмем ОК.
Проверка версии PHP и возможная ошибка
После установки PHP следует проверить, все ли корректно установилось и готово к работе. Для этого в любом терминале можно набрать команду php -v.
При проверке версии PHP появилось предупреждение:
PHP Warning: ‘C:\Windows\SYSTEM32\VCRUNTIME140.dll’ 14.0 is not compatible with this PHP build linked with 14.29 in Unknown on line 0
Чтобы решить проблему, я загрузил и установил последнюю версию Microsoft Visual C++, ссылка на которую доступна на официальном сайте Microsoft.
После перезагрузки компьютера предупреждение исчезло.
После успешной установки PHP можно написать первую классическую программу, которая выводит сообщение «Hello World!».