Cannot delete /usr/bin/php in macos
10,533
Solution 1
To delete a file in /usr/bin/, you need to disable SIP (System Integrity Protection) by following below steps:
- Turn off your Mac (Apple > Shut Down).
- Hold down Command-R and press the Power button. Keep holding Command-R until the Apple logo appears. Wait for OS X to boot into the OS X Utilities window.
- Choose Utilities > Terminal.
Enter
csrutil disable
. Enterreboot
.
To enable SIP again, repeating the above steps (2 first steps), enter csrutil enable
and reboot your Mac OS.
Solution 2
Had the same issue, try this if the php version you need is already installed.
brew link --overwrite [email protected]
Solution 3
It's system php file. You shouldn't delete it. Better install another php version with homebrew
Solution 4
something like sudo brew unlink phpxx
, where xx
is your version number. Never delete file inside other directories then your home directory manually, unless you know what you're doing.
Related videos on Youtube
Comments
-
Bob Zheng over 1 year
I want to delete php in mac:
/private/etc/ sudo rm -rf php-fpm.conf.default php.ini php.ini.default /usr/bin/ sudo rm -rf php php-config phpdoc phpize /usr/include sudo rm -rf php /usr/lib sudo rm -rf php /usr/sbin sudo rm -rf php-fpm /usr/share sudo rm -rf php /usr/share/man/man1 sudo rm -rf php-config.1 php.1 phpize.1 /usr/share/man/man8 sudo rm -rf php-fpm.8
when i run
sudo rm -rf php php-config phpdoc phpize
happen:
rm: php: Operation not permitted rm: php-config: Operation not permitted rm: phpize: Operation not permitted
Anyone can help me? thanks a lot!
-
brombeer almost 6 yearsYou might be better off researching how to "uninstall" PHP instead of just deleting it. (Not on a Mac so I don't know how to do it). On Linux you'd just type something like
sudo apt remove php7.1
which would remove all references, man files etc in just one command. I guess Mac also has some sort of package manager that can handle this
-