Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot delete /usr/bin/php in macos

Tags:

php

macos

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!

like image 617
Bob Zheng Avatar asked Jun 15 '18 09:06

Bob Zheng


2 Answers

To delete a file in /usr/bin/, you need to disable SIP (System Integrity Protection) by following below steps:

  1. Turn off your Mac (Apple > Shut Down).
  2. 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.
  3. Choose Utilities > Terminal. Enter csrutil disable. Enter reboot.

To enable SIP again, repeating the above steps (2 first steps), enter csrutil enable and reboot your Mac OS.

like image 74
Phong Phan Avatar answered Sep 22 '22 11:09

Phong Phan


Had the same issue, try this if the php version you need is already installed.

brew link --overwrite [email protected]
like image 41
Kervin Ramen Avatar answered Sep 22 '22 11:09

Kervin Ramen