19

Attempting to install PHP, which requires the creation of an extensions directory within /usr/lib/php/extensions. The installation returned an error "Operation not permitted".

I have since found out, sudo is not able to create any directories under /usr/. Anyone else experienced this?

THEK
  • 740
  • 2
  • 10
  • 29
  • are you trying to run the command from PHP? – Jonathan Kuhn Oct 23 '15 at 18:28
  • 1
    It failed when running sudo make install, so I tried it manually. Didn't work that way either – THEK Oct 23 '15 at 18:29
  • 1
    My point is that it really has nothing to do with PHP unless you are running the command from PHP. The fact that you are installing PHP has nothing to do with not being able to create a directory from a terminal window. This is tagged as being a PHP problem. – Jonathan Kuhn Oct 23 '15 at 18:30
  • edited question, updated tags – THEK Oct 23 '15 at 18:34
  • A quick google came up with: http://digitizor.com/2015/10/01/fix-homebrew-permissions-osx-el-capitan/. While it deals with another program, it covers the same issue and a fix. Your decision if you want to use that or install elsewhere. – Jonathan Kuhn Oct 23 '15 at 18:37
  • This should be the reason according to this link https://superuser.com/questions/1152753/system-library-folder-on-macos-sierra-does-not-allow-permissions-modifications – nmeegama Sep 19 '17 at 21:31

1 Answers1

28

Local installations really should be installed under /usr/local, not directly under /usr. Starting in El Capitan, this is enforced by System Integrity Protection. Shouldn't be a big change, just install the extensions in /usr/local/lib/php/extensions, and edit php.ini to set extension_dir to the appropriate location.

Community
  • 1
  • 1
Gordon Davisson
  • 118,432
  • 16
  • 123
  • 151
  • And what about the same case but with installing a program? in this case, I wanted to install Trimmomatic in bin and the same error message appeared. Thank you in advance. – msimmer92 Mar 28 '18 at 17:49
  • 1
    @melunuge92 That's a java program, so it doesn't matter much where you put it as long as you run it with `java -jar /path/to/trimmomatic.jar`. [This makefile](https://github.com/timflutre/trimmomatic/blob/master/Makefile) suggests it'll normally be installed for a specific user in ~/bin/trimmomatic.jar (e.g. /Users/melunuge92/bin/trimmomatic.jar). I'm not really familiar enough with java to know the best conventions for installing java programs. – Gordon Davisson Mar 28 '18 at 19:28
  • Thank you, Gordon! It was a silly mistake, after all. I had a folder called trimmomatic in bin and inside it had the executable. I just put the executable directly on the bin folder without the "trimmomatic" intermediate folder and it worked. – msimmer92 Mar 30 '18 at 11:32