How to Install PHP 8 On Windows: Without XAMPP
PHP is a popular scripting language widely used for web development. Traditionally, most of us would use an all-in-one package like XAMPP or WAMP, which includes Apache, MySQL, PHP, and several other software to run a complete web server on their machines.
However, there might be situations where you want to install PHP standalone, separate from other software. One such reason might be to have a different version of PHP than what’s bundled in your current XAMPP or WAMP. The advantage is that you get a lighter installation with only the components you need.
In this tutorial, we will go through the process of installing PHP 8.x and above on Windows without using XAMPP.
Requirements
- Windows 10 and above.
- Administrator access on your computer
Method 1 - Using Scoop
The first and the method that we recommended of installing PHP on Windows is by using the scoop package manager.
If you do not have scoop installed, you can check the tutorial below:
https://www.geekbits.io/how-to-install-scoop-on-windows/
Once installed, run the command below to install PHP on your Windows machine:
scoop install php
This should download the latest available version of PHP and install it on your machine. You can use the command below to check the installed version:
php --version
Output:
PHP 8.2.7 (cli) (built: Jun 7 2023 10:25:38) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
In this case, we have PHP version 8.2.7
installed.
Method 2 - Using Chocolatey Package Manager
The second method you can use to install PHP as a standalone unit in Windows is using the chocolatey package manager.
If you do not have Chocolatey installed, you can check the resource below:
https://www.geekbits.io/how-to-install-chocolatey-on-windows-11/
Once installed, run the command below to install PHP:
choco install php
Similarly, the command above should grab the latest available PHP version and install it on your machine.
Method 3 - Manual Install
You can also manually download the PHP archive and configure it on your machine.
Download PHP 8
Go to the PHP for Windows download page at https://windows.php.net/download.
Under the VC16 x64 Non Thread Safe
or VC16 x86 Non Thread Safe
(depending on whether your Windows is 64-bit or 32-bit) of the PHP 8 section, click on the Zip
link to download the PHP 8.0 zip package. If you are unsure, it is likely you are using a 64-bit version of Windows.
Extract the PHP 8 Zip Package
After the download completes, navigate to your downloads directory, right-click on the PHP zip package, and select Extract All...
Choose where you want to extract PHP. A common location would be C:\php
, so the PHP binaries would be in C:\php
. Make sure the path does not contain any spaces.
Click Extract
Rename php.ini File
Navigate to the directory where you extracted PHP (e.g., C:\php
).
3.2. Find a file named php.ini-development
and rename it to php.ini
.
Edit System Environment Variables
Open the Environment Variables
by searching env
in the Windows Start Menu.
Under ‘Startup and Recovery’ , choose the ‘Environment variables’ option.
Under ‘System variables’, scroll down and find the ‘Path’ variable, then click on ‘Edit…’.
In the ‘Edit Environment Variable’ window, click ‘New’ and then add the path to your PHP installation (e.g., C:\php
).
Click ‘OK’ to close all windows.
Step 5: Verify the PHP Installation
Open a new command prompt window (to make sure it gets the new environment variable you just added).
Enter the commandphp -v
and hit ‘Enter’. You should see a message showing the PHP version number.
Conclusion
In this post, you discovered the various methods you can use to install and configure PHP as a standalone unit on Windows systems.