How to install php in git bash?

How can you install php in git bash? Is there a sudo cmd for it? Just some background, I am running sudo ./file name and it requires PHP.

EDIT: I didn’t put this in #code-help because it isn’t code.

Windows and git bash, I assume?

Side note: things like git bash are just shells, they aren’t the actual environment things run in


Yup! I am running Git Bash as administrator on my Windows PC :+1:


Thank you but that won’t work because I am using bash, not CMD Prompt.

Then why not just use command prompt? Windows comes with command prompt by default.

1 Like

Because I have to do sudo and that doesn’t work there.

Try using cygwin and not using sudo (sudo is just a way to run commands as root, and cygwin can be installed without root, so root isn’t needed to install programs in cygwin)

1 Like

Yeah but there has to be a way to get PHP in Git Bash

Have you tried out sudo apt-get install php?

Also I think you should be at least using WSL because that’s more designed for linux things than git bash lol

git bash is literally just bash on windows computers, but with git autocomplete and things like that.


Why would windows have apt-get? And are running Linux, but with windows?


try this

winget install ApacheFriends.Xampp.8.2

Testing this right now! Fingers crossed that it works :crossed_fingers:! Do I need to add it to the directory thing on my PC?

@UMARismyname what should I do after it is installed?

Search for ‘environment variables for your account’ in the start menu, enter and add ;C:\xampp\php to the Path variable. Then you should be able to use php commands


Ok so I figured it out yesterday. The steps are:

  1. Open My Computer Properties
  2. Click on Advance System Setting
  3. Select Environment Variables
  4. Click on Path & Edit
  5. Click new & Add your PHP.exe path (e.g. C:\xampp\php\php.exe)
  6. Restart Console/Bash

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.