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:

  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.

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.

Share:
10,533

Related videos on Youtube

Bob Zheng
Author by

Bob Zheng

Here and Now is Happiness!

Updated on September 16, 2022

Comments

  • Bob Zheng
    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
      brombeer almost 6 years
      You 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