After the mac operating system was upgraded to 10.11.2 (OS Neither could be successfully installed; I was troubled for a long time. When installing after compilation, it always prompts
<span class="line">1</span> Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login |
<span class="line">[cp: /usr/lib/php/extensions/no-debug-non-zts-20121212/#INST@17000#: Operation not permitted]</span> Copy after login |
Finally found the problem
When you enter the /usr/lib/php/extensions/ directory, you will find that the directory cannot be operated at all (manual copying and moving), and you do not have permission to use root in the terminal; but is it impossible? I am already a root user, why is it not allowed? It turns out that OSX 10.11 El Capitan has added a new security mechanism called System Integrity Protection (SIP), so for the directory
Only for system use, other users or programs cannot use it directly, and our /usr/lib/php/extensions/ happens to be within the protected scope
So the solution is to disable the SIP protection mechanism. The steps are:
After disabling SIP, you can install it smoothly. Of course, you can re-enable SIP after installation. The method is the same as above, but the command is csrutil enable
<span class="line">1</span> Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login |
<span class="line">cd ~ ; mkdir mcrypt ; cd mcrypt</span> Copy after login |
Download
libmcrypt2.5.8 and the php version of your system to the mcrypt directory
Unzip
<span class="line">1</span> Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login |
<span class="line">tar -zxvf libmcrypt-2.5.8.tar.gz tar -zxvf php-5.5.27.tar.gz rm *.gz</span> Copy after login |
Install libmcrypt
<span class="line">1</span> Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login |
<span class="line">cd libmcrypt-2.5.8 ./configure make sudo make install</span> Copy after login |
Install autoconf
<span class="line">1</span> Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login |
<span class="line">cd ~/mcrypt curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz tar xvfz autoconf-latest.tar.gz cd autoconf-2.69/ ./configure make sudo make install</span> Copy after login |
Compile mcrypt php extension
<span class="line">1</span> Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login |
<span class="line">cd ../php-5.5.27/ext/mcrypt/ /usr/bin/phpize</span> Copy after login |
The above will output:
<span class="line">1</span> Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login |
<span class="line">Configuring for: PHP Api Version: 20121113 Zend Module Api No: 20121212 Zend Extension Api No: 220121212</span> Copy after login |
Then compile:
<span class="line">1</span> Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login |
<span class="line">./configure make sudo make install</span> Copy after login |
The above will output:
<span class="line">1</span> Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login |
<span class="line">Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20121212/</span> Copy after login |
If there is an error (that I encountered):
<span class="line">1</span> Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login |
<span class="line">cp: /usr/lib/php/extensions/no-debug-non-zts-20121212/#INST@17000#: Operation not permitted</span> Copy after login |
It means you need to disable SIP first (see above for how to disable SIP)
Modify /etc/php.ini and add extension=mcrypt.so
Restart apache
<span class="line">1</span> Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login Copy after login |
<span class="line">sudo apachectl restart</span> Copy after login |
Look at your phpinfo(); mcrypt information will appear;
(My blog original text: http://www.jmolboy.com/2015/12/01/mcrypt-extension-on-EI-Capitan/)