php: command not found
The “php: command not found” error means your shell cannot locate the PHP binary. This usually happens when PHP is not installed or its directory is not in your system’s PATH variable.
What It Means
When you type php in your terminal, the shell searches through the directories listed in your PATH environment variable. If no directory contains a php executable, you get “command not found.” On Windows, the message may appear as “php is not recognized as an internal or external command.”
Why It Happens
- PHP is not installed on your system.
- PHP is installed but the binary’s directory (e.g.,
/usr/local/binorC:\php) is not in your PATH. - You installed PHP via a package manager but forgot to add it to the environment variables.
- The installed PHP version is incompatible with your OS architecture.
- You are using a shared hosting environment where PHP is available only through a different command like
php81orphp8.2.
How to Fix It
1. Install PHP via your package manager
Ubuntu / Debian:
sudo apt update && sudo apt install phpmacOS (Homebrew):
brew install phpWindows: Download the PHP ZIP package from windows.php.net and extract it to C:\php.
2. Add PHP to your PATH
Linux / macOS: Add this to your ~/.bashrc or ~/.zshrc:
export PATH="$PATH:/usr/local/bin"Then reload with source ~/.bashrc.
Windows: Go to System Properties → Environment Variables and add C:\php to the Path variable.
3. Verify the installation
php -vYou should see output like PHP 8.3.x with version details.
4. Use the full path as a workaround
If you cannot modify PATH, run PHP with its full path:
/usr/bin/php script.phpBuilt by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro