Table of Contents
Install PHP on Windows using Command Prompt or PowerShell
Install Chocolatey Choco Package Manager
After downloading and installing PHP, confirm that it is configured correctly on Windows 10 or 11, we can run
Check for another version of PHP on Windows 11 or 10 One way is to use a single line of code that
Home Common Problem How to install PHP on Windows 10 using Command Prompt

How to install PHP on Windows 10 using Command Prompt

May 08, 2023 pm 05:13 PM
php programming language command prompt install

Install PHP on Windows using Command Prompt or PowerShell

Install Chocolatey Choco Package Manager

I tried the Windows default package managerWinget but it didn't work Install PHP through it. So, the other best option left is to use the popular Chocolatey package manager.

But unlike Winget, Choco does not exist in our Windows system by default, so we need to install it manually on our system.

Go to your Windows 10 or 11 search box and type CMD, select "Run as administrator"## when it appears

#Copy and paste the given command on our

prompt to install Chocolatey package manager.

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey .org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Copy after login

Restart the system to allow the package manager to integrate correctly.

Commands to set up PHP on Windows 10/11

Now that we have the package manager, the next task is to use it to download and install PHP on Windows. This is the command to type:

choco install php
Copy after login

For the ThreadSafe version, if you plan to use PHP with Apache

choco install php --package-parameters='"/ThreadSafe ""/InstallDir:C:\PHP"""'。
Copy after login

Press

A and press Enter button and let Choco install all the packages needed to set up PHP.

The above command will install the latest version of PHP on Windows, however, those interested in some earlier versions can use the given syntax:

For example get php7.4

choco install php --version=7.4
Copy after login

Well, those who want to downgrade the latest version

to some previous version or plan on Windows 10 For those who have multiple versions of PHP installed on 11 or 11, you need to define a parameter using the Choco command.

For example:

Downgrade the latest version to some older version.

Assuming you already have 8.2 but now want to install the 7.4 version of PHP, the command parameters to add will be --allow-downgrade.<div class="code" style="position:relative; padding:0px; margin:0px;"><pre class='brush:php;toolbar:false;'>choco install php --version=7.4 --allow-downgrade</pre><div class="contentsignin">Copy after login</div></div>

To install multiple versions of PHP side by side:

If you don't want to remove the current latest version from your PC, but also want to install some older versions, use this

- -side-by-side

parameter. <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class='brush:php;toolbar:false;'>choco install php --version=7.4 --side-by-side</pre><div class="contentsignin">Copy after login</div></div>Check PHP version Windows command

After downloading and installing PHP, confirm that it is configured correctly on Windows 10 or 11, we can run

php -v

to check its version and other details. <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class='brush:php;toolbar:false;'>php -v</pre><div class="contentsignin">Copy after login</div></div>To check for available or installed PHP extensions, use:

php -m
Copy after login

Php Information Page in Windows

Check for another version of PHP on Windows 11 or 10 One way is to use a single line of code that

phpinfo();

will display all the necessary information, including the extension and its version.

To do this, on your command prompt or terminal type:

notepad info.php
Copy after login
After that

paste

the following code and save and close the file.

Copy after login

如何在 Windows 10 上安装 PHP | 11 使用命令提示符Now, if you may not know, PHP comes with its own web server that we can use to test our PHP based applications. So, in the same
directory where you created info.php

run:

php -S localhost:8000
Copy after login

如何在 Windows 10 上安装 PHP | 11 使用命令提示符You will see PHP's built-in The web server will
start at your current Windows command prompt.

Now, open your browser and type :

http://localhost:8000/info.php
Copy after login
You will see details about the installed PHP

version.

The above is the detailed content of How to install PHP on Windows 10 using Command Prompt. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

Demystifying JavaScript: What It Does and Why It Matters Demystifying JavaScript: What It Does and Why It Matters Apr 09, 2025 am 12:07 AM

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

Explain the match expression (PHP 8 ) and how it differs from switch. Explain the match expression (PHP 8 ) and how it differs from switch. Apr 06, 2025 am 12:03 AM

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

What is Cross-Site Request Forgery (CSRF) and how do you implement CSRF protection in PHP? What is Cross-Site Request Forgery (CSRF) and how do you implement CSRF protection in PHP? Apr 07, 2025 am 12:02 AM

In PHP, you can effectively prevent CSRF attacks by using unpredictable tokens. Specific methods include: 1. Generate and embed CSRF tokens in the form; 2. Verify the validity of the token when processing the request.

PHP's Purpose: Building Dynamic Websites PHP's Purpose: Building Dynamic Websites Apr 15, 2025 am 12:18 AM

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.