Apologies in advance for the potential n00b questions, I am trying to install the mcrypt extension for PHP on my OSX Mountain Lion machine.
为潜在的n00b问题提前道歉,我正试着在我的OSX Mountain Lion机器上安装PHP的mcrypt扩展。
The following steps in terminal is what I have done so far to achieve my PHP install
下面的步骤是我迄今为止为实现我的PHP安装所做的工作。
cd /path/to/downloaded/php-5.3.21/ext/mcrypt/
/usr/bin/phpize
./configure
cd /path/to/downloaded/php-5.3.21
./configure --with-config-file-path=/private/etc/php.ini --with-apxs2=/usr/sbin/apxs
make
sudo make install
Which seems to work well and installs PHP 5.3.21 fine. I have then done
这似乎很有效,并且安装了PHP 5.3.21。我那么做了
sudo nano /private/etc/php.ini
And included
,包括
extension=mcrypt.so
Along with an Apache restart, phpinfo() doesn't show that the mcrypt extension is loaded.
随着Apache重启,phpinfo()并没有显示mcrypt扩展被加载。
I then tried to specify the extension_dir inside php.ini, again with no luck.
然后,我尝试在php中指定extension_dir。伊尼,再没有运气了。
I have done
我做了
locate mcrypt.so
/opt/local/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so
/usr/local/Cellar/php53-mcrypt/5.3.18/mcrypt.so
And tried both directories as the extension_dir, with no luck.
并且尝试了两个目录作为extension_dir,没有运气。
I have also tried the following, after much Googling
我也试过下面的方法,在谷歌搜索之后。
./configure --with-config-file-path=/private/etc/php.ini --with-apxs2=/usr/sbin/apxs --with-mcrypt
Which seems to work OK, but then upon "make", it returns
这似乎可行,但在“make”之后,它会返回?
ext/mcrypt/mcrypt.o: No such file or directory
ext/mcrypt/mcrypt_filter.o: No such file or directory
Again, no success.
再一次,没有成功。
What am I doing wrong? It seems like the physical compile of mcrypt.so is not happening, or is compiling incorrectly as I would suspect there to be another mcrypt.so found under locate?
我做错了什么?似乎是mcrypt的物理编译。所以不会发生,或者编译错误,因为我怀疑会有另一个mcrypt。所以找到定位下吗?
Anyone please help? I've gone through pages upon pages of Google searches with no luck!
有人请帮助吗?我在谷歌的搜索页面上翻了几页,没有任何运气!
14 个解决方案
#1
75
I tend to use Homebrew on Mac. It will install and configure all the stuff for you.
http://mxcl.github.com/homebrew/
我倾向于在Mac上使用Homebrew,它会为你安装和配置所有的东西。http://mxcl.github.com/homebrew/
Then you should be able to install it with brew install mcrypt php53-mcrypt
and it'll Just Work (tm).
然后,您应该能够安装它与brew安装mcrypt php53-mcrypt,它将只工作(tm)。
You can replace the 53
with whatever version of PHP you're using, such as php56-mcrypt
or php70-mcrypt
. If you're not sure, use brew search php
.
您可以用您正在使用的任何版本的PHP来替换53,比如php56-mcrypt或php70-mcrypt。如果不确定,可以使用brew搜索php。
Do also remember that if you are using the built in Mac PHP it's installed into /usr/bin
you can see which php you are using with which php
at the terminal and it'll return the path.
也要记住,如果你使用的是Mac PHP内置的PHP,你可以看到你使用哪个PHP在终端,它会返回路径。
#2
48
I just went through this on Mountain Lion. Homebrew blocked on libiconv which it thought was missing but was actually up to date. After an hour of trying to get it to recognize libiconv, I gave up and installed it the old fashion way, which took all of five minutes...
我刚在美洲狮身上经历过。在libiconv上,它被认为是缺失的,但实际上是最新的。经过一个小时的努力让它认出了libiconv,我放弃了,用旧的方式安装了它,用了整整五分钟……
(download your php version)
$ wget http://www.php.net/get/php-5.3.21.tar.gz/from/a/mirror
$ tar -xvzf php-5.3.21.tar.gz
$ cd php-5.3.21/ext/mcrypt
$ phpize
$ ./configure
$ make
$ make test
$ sudo make install
mcrypt.so is now in your PHP ext dir (/usr/lib/php/extensions/no-debug-non-zts-20090626/
in my case), now you need to add to php.ini as a module
mcrypt。现在,您的PHP ext dir (/usr/lib/ PHP /extensions/无调试-不调试-20090626/在我的情况下),现在您需要添加到PHP。ini作为一个模块
$ vi /etc/php.ini
$ (insert) extension=mcrypt.so
$ sudo apachectl restart
Done - no brew necessary. HTH someone.
完成-无需冲泡。HTH某人。
#3
38
Installing php-mcrypt
without the use of port
or brew
Note: these instructions are long because they intend to be thorough. The process is actually fairly straight-forward. If you're an optimist, you can skip down to the building the mcrypt extension section, but you may very well see the errors I did, telling me to install
autoconf
andlibmcrypt
first.注意:这些指令很长,因为它们想要彻底。这个过程实际上相当简单。如果您是一个乐观的人,您可以跳到构建mcrypt扩展部分,但是您很可能会看到我所犯的错误,告诉我首先安装autoconf和libmcrypt。
I have just gone through this on a fresh install of OSX 10.9. The solution which worked for me was very close to that of ckm - I am including their steps as well as my own in full, for completeness. My main goal (other than "having mcrypt
") was to perform the installation in a way which left the least impact on the system as a whole. That means doing things manually (no port
, no brew
)
我刚刚在osx10.9的新安装上完成了这个操作。为我工作的解决方案与ckm的解决方案非常接近——我包括他们的步骤和我自己的全部,为了完整性。我的主要目标(除了“拥有mcrypt”之外)就是以一种对整个系统影响最小的方式来执行安装。这意味着手工操作(没有端口,没有brew)
To do things manually, you will first need a couple of dependencies: one for building PHP modules, and another for mcrypt
specifically. These are autoconf
and libmcrypt
, either of which you might have already, but neither of which you will have on a fresh install of OSX 10.9.
要手动完成任务,首先需要几个依赖项:一个用于构建PHP模块,另一个用于专门用于mcrypt。这些都是autoconf和libmcrypt,您可能已经使用过,但这两种都不会在osx10.9的新安装中使用。
autoconf
Autoconf (for lack of a better description) is used to tell not-quite-disparate, but still very different, systems how to compile things. It allows you to use the same set of basic commands to build modules on Linux as you would on OSX, for example, despite their different file-system hierarchies, etc. I used the method described by Ares on *, which I will reproduce here for completeness. This one is very straight-forward:
Autoconf(因为缺少更好的描述)被用来告诉不完全不同的,但仍然非常不同的系统如何编译东西。它允许您使用相同的基本命令来在Linux上构建模块,比如在OSX上,尽管它们的文件系统层次结构不同,等等。我使用了Ares在*上描述的方法,我将在这里复制它以完成完整。这个很简单:
$ mkdir -p ~/mcrypt/dependencies/autoconf
$ cd ~/mcrypt/dependencies/autoconf
$ curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
$ tar xzf autoconf-latest.tar.gz
$ cd autoconf-*/
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
Next, verify the installation by running:
接下来,通过运行验证安装:
$ which autoconf
which should return /usr/local/bin/autoconf
它应该返回/usr/local/bin/autoconf
libmcrypt
Next, you will need libmcrypt
, used to provide the guts of the mcrypt
extension (the extension itself being a provision of a PHP interface into this library). The method I used was based on the one described here, but I have attempted to simplify things as best I can:
接下来,您将需要libmcrypt,用于提供mcrypt扩展的核心(扩展本身就是为这个库提供PHP接口)。我使用的方法是基于这里所描述的,但是我已经尽量简化了,我可以:
First, download the libmcrypt
source, available from SourceForge, and available as of the time of this writing, specifically, at:
首先,从SourceForge中下载libmcrypt源代码,并在撰写本文时提供,具体地说:
http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2/download
http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2/download
You'll need to jump through the standard SourceForge hoops to get at the real download link, but once you have it, you can pass it in to something like this:
你需要通过标准的SourceForge hoops来获得真正的下载链接,但是一旦你有了它,你就可以把它传递给类似的东西:
$ mkdir -p ~/mcrypt/dependencies/libmcrypt
$ cd ~/mcrypt/dependencies/libmcrypt
$ curl -L -o libmcrypt.tar.bz2 '<SourceForge direct link URL>'
$ tar xjf libmcrypt.tar.bz2
$ cd libmcrypt-*/
$ ./configure
$ make
$ sudo make install
The only way I know of to verify that this has worked is via the ./configure
step for the mcrypt
extension itself (below)
我所知道的验证这一点的唯一方法是通过/配置mcrypt扩展本身的步骤(如下所示)
building the mcrypt extension
This is our actual goal. Hopefully the brief stint into dependency hell is over now.
这是我们的实际目标。希望这个短暂的依赖地狱现在结束了。
First, we're going to need to get the source code for the mcrypt
extension. This is most-readily available buried within the source code for all of PHP. So: determine what version of the PHP source code you need.
首先,我们需要获取mcrypt扩展的源代码。这是所有PHP的源代码中最容易找到的。因此:确定您需要的PHP源代码的版本。
$ php --version # to get your PHP version
now, if you're lucky, your current version will be available for download from the main mirrors. If it is, you can type something like:
现在,如果你幸运的话,你的当前版本将可以从主镜像下载。如果是,你可以输入类似的东西:
$ mkdir -p ~/mcrypt/php
$ cd ~/mcrypt/php
$ curl -L -o php-5.4.17.tar.bz2 http://www.php.net/get/php-5.4.17.tar.bz2/from/a/mirror
Unfortunately, my current version (5.4.17, in this case) was not available, so I needed to use the alternative/historical links at http://downloads.php.net/stas/ (also an official PHP download site). For these, you can use something like:
不幸的是,我的当前版本(在本例中是5.4.17)是不可用的,所以我需要在http://downloads.php.net/stas/(也是一个官方的PHP下载站点)中使用替代/历史链接。对于这些,你可以使用如下的东西:
$ mkdir -p ~/mcrypt/php
$ cd ~/mcrypt/php
$ curl -LO http://downloads.php.net/stas/php-5.4.17.tar.bz2
Again, based on your current version.
同样,基于你当前的版本。
Once you have it, (and all the dependencies, from above), you can get to the main process of actually building/installing the module.
一旦您拥有了它(以及所有依赖项),您就可以进入实际构建/安装模块的主要过程。
$ cd ~/mcrypt/php
$ tar xjf php-*.tar.bz2
$ cd php-*/ext/mcrypt
$ phpize
$ ./configure # this is the step which fails without the above dependencies
$ make
$ make test
$ sudo make install
In theory, mcrypt.so
is now in your PHP extension directory. Next, we need to tell PHP about it.
理论上,mcrypt。现在在PHP扩展目录中。接下来,我们需要告诉PHP。
configuring the mcrypt extension
Your php.ini
file needs to be told to load mcrypt
. By default in OSX 10.9, it actually has mcrypt
-specific configuration information, but it doesn't actually activate mcrypt
unless you tell it to.
您的php。需要告诉ini文件装入mcrypt。在osx10.9中默认情况下,它实际上有特定于mcrypt的配置信息,但它实际上并没有激活mcrypt,除非您告诉它。
The php.ini
file does not, by default, exist. Instead, the file /private/etc/php.ini.default
lists the default configuration, and can be used as a good template for creating the "true" php.ini
, if it does not already exist.
php。默认情况下,ini文件不存在。缺省情况下,文件/私有/etc/php. default列出了默认的配置,并且可以作为创建“true”php的良好模板。如果它还不存在的话。
To determine whether php.ini
already exists, run:
确定php。ini已经存在,运行:
$ ls /private/etc/php.ini
If there is a result, it already exists, and you should skip the next command.
如果有结果,它已经存在,并且您应该跳过下一个命令。
To create the php.ini
file, run:
创建php。ini文件,运行:
$ sudo cp /private/etc/php.ini.default /private/etc/php.ini
Next, you need to add the line:
接下来,您需要添加一行:
extension=mcrypt.so
Somewhere in the file. I would recommend searching the file for ;extension=
, and adding it immediately prior to the first occurrence.
在该文件。我建议搜索该文件;扩展=,并在第一次出现之前添加它。
Once this is done, the installation and configuration is complete. You can verify that this has worked by running:
一旦完成,安装和配置就完成了。您可以通过运行来验证这是否有效:
php -m | grep mcrypt
Which should output "mcrypt
", and nothing else.
它应该输出“mcrypt”,而不是其他。
If your use of PHP relies on Apache's httpd
, you will need to restart it before you will notice the changes on the web. You can do so via:
如果您使用的PHP依赖于Apache的httpd,那么在您注意到web上的变化之前,您需要重新启动它。你可以这样做:
$ sudo apachectl restart
And you're done.
你就完成了。
#4
10
Why You're Getting This Error
PHP complains if one of the files like mcrypt.so
is included using the syntax extension="mcrypt.so"
but the file is not in the extension_dir
path ( use <?php phpinfo(); ?>
or php -i
to check that).
PHP会抱怨像mcrypt这样的文件。因此,包括使用语法扩展=“mcrypt”。因此,“但是文件不在extension_dir路径中(使用 或php -我来检查一下。
It will also tell you which php.ini
config file is being loaded so you will know where the settings are coming from. Most likely it will be something like /usr/local/etc/php/5.4/php.ini
if you are using the homebrew version.
它还会告诉你哪个php。ini配置文件正在加载,这样您就可以知道设置是从哪里来的。很可能是/usr/local/etc/php/5.4/php。如果你使用的是自制版本。
Take note of the part under it that says something like "Scan this dir for additional .ini files" because what that means is it gives you a place to put your own file, like tweaks.ini
that is loaded after the main configuration file so that you can make changes and keep up with them easily. Also remember that all the files in this directory get loaded in alphabetical order, so if you have one called adjustments.ini
that contains mcrypt
directives, and there is a mcrypt.ini
, most likely your settings will be overridden.
注意它下面的部分,上面写着“扫描这个目录以获取额外的。ini文件”,因为这意味着它给了你一个放置你自己文件的地方,比如调整。在主配置文件之后加载的ini文件,这样您就可以轻松地进行更改并与它们保持同步。还要记住,这个目录中的所有文件都是按字母顺序加载的,所以如果您有一个称为调整的文件。包含mcrypt指令的ini,还有一个mcrypt。ini,您的设置很可能会被重写。
One alternative to specifying extension="mcrypt.so"
is to specify the full path to the mcrypt.so
file. The other option is to edit the extension_dir
setting.
指定扩展="mcrypt "的另一种选择。所以“是指定mcrypt的完整路径。所以文件。另一个选项是编辑extension_dir设置。
What worked for me
On Mavericks I didn't have to do either. I did a fresh install of homebrew
and then added the josegonzalez tap using:
在小牛队,我也不需要这样做。我重新安装了homebrew,然后添加了josegonzalez tap:
brew tap josegonzalez/homebrew-php
(My other laptop was running Mountain Lion and was also using homebrew in this setup.)
(我的另一台笔记本电脑是“Mountain Lion”(Mountain Lion),在这个设置中也使用了homebrew。)
After you've tapped that awesome repo you can install php
and mcrypt
using something like:
在你点击了这个很棒的repo之后,你可以使用如下的东西来安装php和mcrypt:
brew install php54 php54-mcrypt
What if this doesn't work (and why should I use homebrew anyway?)
I would highly advise trying this route before downloading and building it from source. It's not hard to build from source - but I don't want to have to maintain that. It's one of the reasons to use homebrew
in the first place - it's a package manager (with a HUGE community).
我建议在下载之前尝试这条路线,并从源代码构建它。从源代码中构建并不困难,但我不想要维护它。这是第一个使用homebrew的原因之一——它是一个包管理器(拥有一个庞大的社区)。
There is a lot of development on the homebrew
project and - if you have problems I'd suggest checking out their issues page
在homebrew项目上有很多开发项目,如果你有问题,我建议你看看他们的问题页面。
So yes you can build it from source and that might seem like a good option right now if you just want mcrypt to work but you may hate yourself for doing this later...
所以,是的,你可以从源代码构建它,这看起来是一个不错的选择,如果你只是想要mcrypt工作,但是你可能会讨厌自己以后做这个…
If you don't want to be using php54
there is also the php53
branch. They have some instructions at the repo about how to use both of them / switch between them.
如果你不想使用php54,也有php53分支。他们有一些关于如何使用这两种方法的说明。
If you're new to homebrew you should know that you check out what else is available using brew search php54
, which gives something like:
如果你是家里的新手,你应该知道你可以用brew search php54查看其他的东西。
php54 php54-lzf php54-snappy
php54-amqp php54-mailparse php54-solr
php54-apc php54-mcrypt php54-ssh2
php54-apcu php54-memcache php54-stats
php54-boxwood php54-memcached php54-svm
php54-chdb php54-midgard2 php54-tidy
php54-couchbase php54-mongo php54-timezonedb
php54-dbase php54-msgpack php54-tokyotyrant
php54-ev php54-mysqlnd_ms php54-twig
php54-gearman php54-oauth php54-uploadprogress
php54-geoip php54-opcache php54-uuid
php54-gmagick php54-parsekit php54-varnish
php54-graphdat php54-pcntl php54-wbxml
php54-http php54-pdflib php54-xcache
php54-igbinary php54-phalcon php54-xdebug
php54-imagick php54-proctitle php54-xhgui
php54-inclued php54-pspell php54-xhp
php54-intl php54-pthreads php54-xhprof
php54-ioncubeloader php54-raphf php54-xmldiff
php54-jsmin php54-redis php54-yac
php54-judy php54-riak php54-yaf
php54-leveldb php54-runkit php54-yaml
php54-libevent php54-scrypt php54-yaz
php54-libvirt
TLDR
- You should use
homebrew
to installmcrypt
if at all possible - 如果可能的话,您应该使用homebrew来安装mcrypt。
- If you're getting errors it's probably because your configuration file(s) are messed up. Check the
extension_dir
path and figure out where themcrypt.so
file is and see if there is a discrepancy (or specify the full path) - 如果您有错误,可能是因为您的配置文件混乱了。检查extension_dir路径并找出mcrypt的位置。因此,文件是并查看是否存在差异(或指定完整路径)
#5
8
For me, on Yosemite
对我来说,在约塞米蒂国家公园
$ brew install mcrypt php56-mcrypt
restart computer
重新启动计算机
did the trick.
起了作用。
#6
5
Solution with brew worked only after the following: in your php.ini
解决方案只有在以下步骤:在您的php.ini中。
nano /private/etc/php.ini
add this line:
添加这一行:
extension="/usr/local/Cellar/php53-mcrypt/5.3.26/mcrypt.so"
Warning! Set the correct PHP version.
警告!设置正确的PHP版本。
#7
4
I would recommend installing everything via homebrew if you have the option. I went in circles for a while, but installing php 5.x via brew and then the neccessary modules worked a treat. I was working with php 5.4 and used this to get going initially:
如果你有这个选择的话,我建议你通过自制程序来安装。我转了一会儿,但是安装了php 5。x通过brew,然后必要的模块进行处理。我使用的是php 5.4,开始使用它:
https://github.com/josegonzalez/homebrew-php
https://github.com/josegonzalez/homebrew-php
and then installed the additional modules with:
然后安装额外的模块:
brew install php54-redis
brew install php54-xdebug
brew install php54-mcrypt
...
…
#8
3
Another possibility for those who want to keep OS X as clean as possible, is to use vagrant [1] to define a php development environment. Vagrant can use VirtualBox [2] in headless mode (~3% of CPU on my 13-inch, Mid 2009 MacBook Pro) to run a virtual machine with the webserver and php and all.
对于那些希望保持OS X尽可能干净的人来说,另一种可能是使用流浪[1]来定义一个php开发环境。Vagrant可以在headless模式下使用VirtualBox[2](在我的13英寸,2009年中期的MacBook Pro中,3%的CPU)运行一个带有webserver和php的虚拟机。
To easily create the vagrant environment you can use this great tool https://puphpet.com/
为了方便地创建一个流浪的环境,您可以使用这个伟大的工具https://puphpet.com/。
- http://www.vagrantup.com/
- http://www.vagrantup.com/
- https://www.virtualbox.org/
- https://www.virtualbox.org/
#9
2
I'd create a shell script to install mcrypt module for PHP 5.3 without homebrew.
我将创建一个shell脚本,为PHP 5.3安装mcrypt模块,而不需要自制程序。
The scripts install php autoconf if needed and compile module for your php version.
如果需要,脚本将安装php autoconf,并为php版本编译模块。
The link is here: https://gist.github.com/lucasgameiro/8730619
链接在这里:https://gist.github.com/lucasgameiro/8730619。
Thanks
谢谢
#10
1
Nothing worked and finally got it working using resource @Here and Here; Just remember for OSX Mavericks (10.9) should use PHP 5.4.17 or Stable PHP 5.4.22 source to compile mcrypt. Php Source 5.4.22 here
没有任何工作,最终使用资源@这里和这里;请记住,OSX Mavericks(10.9)应该使用PHP 5.4.17或稳定的PHP 5.4.22源代码编译mcrypt。Php源5.4.22这里
#11
1
Brew base solution worked for me
Brew基础解决方案为我工作。
-
Install these packages
安装这些包
$brew install brew install mcrypt php54-mcrypt
$brew安装brew安装mcrypt php54-mcrypt。
-
Copy default php.ini.default to php.ini
复制默认的php.ini。
$sudo cp /private/etc/php.ini.default /private/etc/php.ini
$ sudo cp /私人/ etc / php.ini.default /私人/ etc / php . ini
-
Add this line to php.ini file extension section - please verify extension path with install location in your machine
将这一行添加到php中。ini文件扩展部分——请在您的机器上安装位置验证扩展路径。
extension="/usr/local/Cellar/php54-mcrypt/5.3.26/mcrypt.so"
扩展= " / usr /地方/地窖/ php54-mcrypt / 5.3.26 / mcrypt.so”
-
Restart your apache server
重新启动apache服务器
$apache restart
重新启动apache美元
#12
1
This is what I did:
这就是我所做的:
$ wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
$ tar xzvf libmcrypt-2.5.8.tar.gz
$ ./configure
$ make
$ sudo make install
$ brew install autoconf
$ wget file:///Users/rmatikolai/Downloads/php-5.4.24.tar.bz2
$ tar xjvf php-5.4.24.tar.bz2
$ cd php-5.4.24/ext/mcrypt
$ phpize
$ ./configure # this is the step which fails without the above dependencies
$ make
$ make test
$ sudo make install
$ sudo cp /private/etc/php.ini.default /private/etc/php.ini
$ sudo vi /private/etc/php.ini
Next, you need to add the line:
接下来,您需要添加一行:
extension=mcrypt.so
$ sudo apachectl restart
#13
0
mycrypt.o and mcrypt_filter.o are in the ext/.libs of your php downloaded directory. Just copy the files to ext/mcrypt, then run make && make install again.
mycrypt。o和mcrypt_filter。o在ext/。下载您的php下载目录。将文件复制到ext/mcrypt,然后运行make &&重新安装。
#14
-4
sudo apt-get install php5-mcrypt
sudo apt-get安装php5-mcrypt
ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/fpm/conf.d/mcrypt.ini
ln - s /etc/php5/mods-available / mcrypt。ini /etc/php5/fpm/conf.d/mcrypt.ini
service php5-fpm restart
服务php5-fpm重启
service nginx restart
nginx重启服务
#1
75
I tend to use Homebrew on Mac. It will install and configure all the stuff for you.
http://mxcl.github.com/homebrew/
我倾向于在Mac上使用Homebrew,它会为你安装和配置所有的东西。http://mxcl.github.com/homebrew/
Then you should be able to install it with brew install mcrypt php53-mcrypt
and it'll Just Work (tm).
然后,您应该能够安装它与brew安装mcrypt php53-mcrypt,它将只工作(tm)。
You can replace the 53
with whatever version of PHP you're using, such as php56-mcrypt
or php70-mcrypt
. If you're not sure, use brew search php
.
您可以用您正在使用的任何版本的PHP来替换53,比如php56-mcrypt或php70-mcrypt。如果不确定,可以使用brew搜索php。
Do also remember that if you are using the built in Mac PHP it's installed into /usr/bin
you can see which php you are using with which php
at the terminal and it'll return the path.
也要记住,如果你使用的是Mac PHP内置的PHP,你可以看到你使用哪个PHP在终端,它会返回路径。
#2
48
I just went through this on Mountain Lion. Homebrew blocked on libiconv which it thought was missing but was actually up to date. After an hour of trying to get it to recognize libiconv, I gave up and installed it the old fashion way, which took all of five minutes...
我刚在美洲狮身上经历过。在libiconv上,它被认为是缺失的,但实际上是最新的。经过一个小时的努力让它认出了libiconv,我放弃了,用旧的方式安装了它,用了整整五分钟……
(download your php version)
$ wget http://www.php.net/get/php-5.3.21.tar.gz/from/a/mirror
$ tar -xvzf php-5.3.21.tar.gz
$ cd php-5.3.21/ext/mcrypt
$ phpize
$ ./configure
$ make
$ make test
$ sudo make install
mcrypt.so is now in your PHP ext dir (/usr/lib/php/extensions/no-debug-non-zts-20090626/
in my case), now you need to add to php.ini as a module
mcrypt。现在,您的PHP ext dir (/usr/lib/ PHP /extensions/无调试-不调试-20090626/在我的情况下),现在您需要添加到PHP。ini作为一个模块
$ vi /etc/php.ini
$ (insert) extension=mcrypt.so
$ sudo apachectl restart
Done - no brew necessary. HTH someone.
完成-无需冲泡。HTH某人。
#3
38
Installing php-mcrypt
without the use of port
or brew
Note: these instructions are long because they intend to be thorough. The process is actually fairly straight-forward. If you're an optimist, you can skip down to the building the mcrypt extension section, but you may very well see the errors I did, telling me to install
autoconf
andlibmcrypt
first.注意:这些指令很长,因为它们想要彻底。这个过程实际上相当简单。如果您是一个乐观的人,您可以跳到构建mcrypt扩展部分,但是您很可能会看到我所犯的错误,告诉我首先安装autoconf和libmcrypt。
I have just gone through this on a fresh install of OSX 10.9. The solution which worked for me was very close to that of ckm - I am including their steps as well as my own in full, for completeness. My main goal (other than "having mcrypt
") was to perform the installation in a way which left the least impact on the system as a whole. That means doing things manually (no port
, no brew
)
我刚刚在osx10.9的新安装上完成了这个操作。为我工作的解决方案与ckm的解决方案非常接近——我包括他们的步骤和我自己的全部,为了完整性。我的主要目标(除了“拥有mcrypt”之外)就是以一种对整个系统影响最小的方式来执行安装。这意味着手工操作(没有端口,没有brew)
To do things manually, you will first need a couple of dependencies: one for building PHP modules, and another for mcrypt
specifically. These are autoconf
and libmcrypt
, either of which you might have already, but neither of which you will have on a fresh install of OSX 10.9.
要手动完成任务,首先需要几个依赖项:一个用于构建PHP模块,另一个用于专门用于mcrypt。这些都是autoconf和libmcrypt,您可能已经使用过,但这两种都不会在osx10.9的新安装中使用。
autoconf
Autoconf (for lack of a better description) is used to tell not-quite-disparate, but still very different, systems how to compile things. It allows you to use the same set of basic commands to build modules on Linux as you would on OSX, for example, despite their different file-system hierarchies, etc. I used the method described by Ares on *, which I will reproduce here for completeness. This one is very straight-forward:
Autoconf(因为缺少更好的描述)被用来告诉不完全不同的,但仍然非常不同的系统如何编译东西。它允许您使用相同的基本命令来在Linux上构建模块,比如在OSX上,尽管它们的文件系统层次结构不同,等等。我使用了Ares在*上描述的方法,我将在这里复制它以完成完整。这个很简单:
$ mkdir -p ~/mcrypt/dependencies/autoconf
$ cd ~/mcrypt/dependencies/autoconf
$ curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
$ tar xzf autoconf-latest.tar.gz
$ cd autoconf-*/
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
Next, verify the installation by running:
接下来,通过运行验证安装:
$ which autoconf
which should return /usr/local/bin/autoconf
它应该返回/usr/local/bin/autoconf
libmcrypt
Next, you will need libmcrypt
, used to provide the guts of the mcrypt
extension (the extension itself being a provision of a PHP interface into this library). The method I used was based on the one described here, but I have attempted to simplify things as best I can:
接下来,您将需要libmcrypt,用于提供mcrypt扩展的核心(扩展本身就是为这个库提供PHP接口)。我使用的方法是基于这里所描述的,但是我已经尽量简化了,我可以:
First, download the libmcrypt
source, available from SourceForge, and available as of the time of this writing, specifically, at:
首先,从SourceForge中下载libmcrypt源代码,并在撰写本文时提供,具体地说:
http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2/download
http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2/download
You'll need to jump through the standard SourceForge hoops to get at the real download link, but once you have it, you can pass it in to something like this:
你需要通过标准的SourceForge hoops来获得真正的下载链接,但是一旦你有了它,你就可以把它传递给类似的东西:
$ mkdir -p ~/mcrypt/dependencies/libmcrypt
$ cd ~/mcrypt/dependencies/libmcrypt
$ curl -L -o libmcrypt.tar.bz2 '<SourceForge direct link URL>'
$ tar xjf libmcrypt.tar.bz2
$ cd libmcrypt-*/
$ ./configure
$ make
$ sudo make install
The only way I know of to verify that this has worked is via the ./configure
step for the mcrypt
extension itself (below)
我所知道的验证这一点的唯一方法是通过/配置mcrypt扩展本身的步骤(如下所示)
building the mcrypt extension
This is our actual goal. Hopefully the brief stint into dependency hell is over now.
这是我们的实际目标。希望这个短暂的依赖地狱现在结束了。
First, we're going to need to get the source code for the mcrypt
extension. This is most-readily available buried within the source code for all of PHP. So: determine what version of the PHP source code you need.
首先,我们需要获取mcrypt扩展的源代码。这是所有PHP的源代码中最容易找到的。因此:确定您需要的PHP源代码的版本。
$ php --version # to get your PHP version
now, if you're lucky, your current version will be available for download from the main mirrors. If it is, you can type something like:
现在,如果你幸运的话,你的当前版本将可以从主镜像下载。如果是,你可以输入类似的东西:
$ mkdir -p ~/mcrypt/php
$ cd ~/mcrypt/php
$ curl -L -o php-5.4.17.tar.bz2 http://www.php.net/get/php-5.4.17.tar.bz2/from/a/mirror
Unfortunately, my current version (5.4.17, in this case) was not available, so I needed to use the alternative/historical links at http://downloads.php.net/stas/ (also an official PHP download site). For these, you can use something like:
不幸的是,我的当前版本(在本例中是5.4.17)是不可用的,所以我需要在http://downloads.php.net/stas/(也是一个官方的PHP下载站点)中使用替代/历史链接。对于这些,你可以使用如下的东西:
$ mkdir -p ~/mcrypt/php
$ cd ~/mcrypt/php
$ curl -LO http://downloads.php.net/stas/php-5.4.17.tar.bz2
Again, based on your current version.
同样,基于你当前的版本。
Once you have it, (and all the dependencies, from above), you can get to the main process of actually building/installing the module.
一旦您拥有了它(以及所有依赖项),您就可以进入实际构建/安装模块的主要过程。
$ cd ~/mcrypt/php
$ tar xjf php-*.tar.bz2
$ cd php-*/ext/mcrypt
$ phpize
$ ./configure # this is the step which fails without the above dependencies
$ make
$ make test
$ sudo make install
In theory, mcrypt.so
is now in your PHP extension directory. Next, we need to tell PHP about it.
理论上,mcrypt。现在在PHP扩展目录中。接下来,我们需要告诉PHP。
configuring the mcrypt extension
Your php.ini
file needs to be told to load mcrypt
. By default in OSX 10.9, it actually has mcrypt
-specific configuration information, but it doesn't actually activate mcrypt
unless you tell it to.
您的php。需要告诉ini文件装入mcrypt。在osx10.9中默认情况下,它实际上有特定于mcrypt的配置信息,但它实际上并没有激活mcrypt,除非您告诉它。
The php.ini
file does not, by default, exist. Instead, the file /private/etc/php.ini.default
lists the default configuration, and can be used as a good template for creating the "true" php.ini
, if it does not already exist.
php。默认情况下,ini文件不存在。缺省情况下,文件/私有/etc/php. default列出了默认的配置,并且可以作为创建“true”php的良好模板。如果它还不存在的话。
To determine whether php.ini
already exists, run:
确定php。ini已经存在,运行:
$ ls /private/etc/php.ini
If there is a result, it already exists, and you should skip the next command.
如果有结果,它已经存在,并且您应该跳过下一个命令。
To create the php.ini
file, run:
创建php。ini文件,运行:
$ sudo cp /private/etc/php.ini.default /private/etc/php.ini
Next, you need to add the line:
接下来,您需要添加一行:
extension=mcrypt.so
Somewhere in the file. I would recommend searching the file for ;extension=
, and adding it immediately prior to the first occurrence.
在该文件。我建议搜索该文件;扩展=,并在第一次出现之前添加它。
Once this is done, the installation and configuration is complete. You can verify that this has worked by running:
一旦完成,安装和配置就完成了。您可以通过运行来验证这是否有效:
php -m | grep mcrypt
Which should output "mcrypt
", and nothing else.
它应该输出“mcrypt”,而不是其他。
If your use of PHP relies on Apache's httpd
, you will need to restart it before you will notice the changes on the web. You can do so via:
如果您使用的PHP依赖于Apache的httpd,那么在您注意到web上的变化之前,您需要重新启动它。你可以这样做:
$ sudo apachectl restart
And you're done.
你就完成了。
#4
10
Why You're Getting This Error
PHP complains if one of the files like mcrypt.so
is included using the syntax extension="mcrypt.so"
but the file is not in the extension_dir
path ( use <?php phpinfo(); ?>
or php -i
to check that).
PHP会抱怨像mcrypt这样的文件。因此,包括使用语法扩展=“mcrypt”。因此,“但是文件不在extension_dir路径中(使用 或php -我来检查一下。
It will also tell you which php.ini
config file is being loaded so you will know where the settings are coming from. Most likely it will be something like /usr/local/etc/php/5.4/php.ini
if you are using the homebrew version.
它还会告诉你哪个php。ini配置文件正在加载,这样您就可以知道设置是从哪里来的。很可能是/usr/local/etc/php/5.4/php。如果你使用的是自制版本。
Take note of the part under it that says something like "Scan this dir for additional .ini files" because what that means is it gives you a place to put your own file, like tweaks.ini
that is loaded after the main configuration file so that you can make changes and keep up with them easily. Also remember that all the files in this directory get loaded in alphabetical order, so if you have one called adjustments.ini
that contains mcrypt
directives, and there is a mcrypt.ini
, most likely your settings will be overridden.
注意它下面的部分,上面写着“扫描这个目录以获取额外的。ini文件”,因为这意味着它给了你一个放置你自己文件的地方,比如调整。在主配置文件之后加载的ini文件,这样您就可以轻松地进行更改并与它们保持同步。还要记住,这个目录中的所有文件都是按字母顺序加载的,所以如果您有一个称为调整的文件。包含mcrypt指令的ini,还有一个mcrypt。ini,您的设置很可能会被重写。
One alternative to specifying extension="mcrypt.so"
is to specify the full path to the mcrypt.so
file. The other option is to edit the extension_dir
setting.
指定扩展="mcrypt "的另一种选择。所以“是指定mcrypt的完整路径。所以文件。另一个选项是编辑extension_dir设置。
What worked for me
On Mavericks I didn't have to do either. I did a fresh install of homebrew
and then added the josegonzalez tap using:
在小牛队,我也不需要这样做。我重新安装了homebrew,然后添加了josegonzalez tap:
brew tap josegonzalez/homebrew-php
(My other laptop was running Mountain Lion and was also using homebrew in this setup.)
(我的另一台笔记本电脑是“Mountain Lion”(Mountain Lion),在这个设置中也使用了homebrew。)
After you've tapped that awesome repo you can install php
and mcrypt
using something like:
在你点击了这个很棒的repo之后,你可以使用如下的东西来安装php和mcrypt:
brew install php54 php54-mcrypt
What if this doesn't work (and why should I use homebrew anyway?)
I would highly advise trying this route before downloading and building it from source. It's not hard to build from source - but I don't want to have to maintain that. It's one of the reasons to use homebrew
in the first place - it's a package manager (with a HUGE community).
我建议在下载之前尝试这条路线,并从源代码构建它。从源代码中构建并不困难,但我不想要维护它。这是第一个使用homebrew的原因之一——它是一个包管理器(拥有一个庞大的社区)。
There is a lot of development on the homebrew
project and - if you have problems I'd suggest checking out their issues page
在homebrew项目上有很多开发项目,如果你有问题,我建议你看看他们的问题页面。
So yes you can build it from source and that might seem like a good option right now if you just want mcrypt to work but you may hate yourself for doing this later...
所以,是的,你可以从源代码构建它,这看起来是一个不错的选择,如果你只是想要mcrypt工作,但是你可能会讨厌自己以后做这个…
If you don't want to be using php54
there is also the php53
branch. They have some instructions at the repo about how to use both of them / switch between them.
如果你不想使用php54,也有php53分支。他们有一些关于如何使用这两种方法的说明。
If you're new to homebrew you should know that you check out what else is available using brew search php54
, which gives something like:
如果你是家里的新手,你应该知道你可以用brew search php54查看其他的东西。
php54 php54-lzf php54-snappy
php54-amqp php54-mailparse php54-solr
php54-apc php54-mcrypt php54-ssh2
php54-apcu php54-memcache php54-stats
php54-boxwood php54-memcached php54-svm
php54-chdb php54-midgard2 php54-tidy
php54-couchbase php54-mongo php54-timezonedb
php54-dbase php54-msgpack php54-tokyotyrant
php54-ev php54-mysqlnd_ms php54-twig
php54-gearman php54-oauth php54-uploadprogress
php54-geoip php54-opcache php54-uuid
php54-gmagick php54-parsekit php54-varnish
php54-graphdat php54-pcntl php54-wbxml
php54-http php54-pdflib php54-xcache
php54-igbinary php54-phalcon php54-xdebug
php54-imagick php54-proctitle php54-xhgui
php54-inclued php54-pspell php54-xhp
php54-intl php54-pthreads php54-xhprof
php54-ioncubeloader php54-raphf php54-xmldiff
php54-jsmin php54-redis php54-yac
php54-judy php54-riak php54-yaf
php54-leveldb php54-runkit php54-yaml
php54-libevent php54-scrypt php54-yaz
php54-libvirt
TLDR
- You should use
homebrew
to installmcrypt
if at all possible - 如果可能的话,您应该使用homebrew来安装mcrypt。
- If you're getting errors it's probably because your configuration file(s) are messed up. Check the
extension_dir
path and figure out where themcrypt.so
file is and see if there is a discrepancy (or specify the full path) - 如果您有错误,可能是因为您的配置文件混乱了。检查extension_dir路径并找出mcrypt的位置。因此,文件是并查看是否存在差异(或指定完整路径)
#5
8
For me, on Yosemite
对我来说,在约塞米蒂国家公园
$ brew install mcrypt php56-mcrypt
restart computer
重新启动计算机
did the trick.
起了作用。
#6
5
Solution with brew worked only after the following: in your php.ini
解决方案只有在以下步骤:在您的php.ini中。
nano /private/etc/php.ini
add this line:
添加这一行:
extension="/usr/local/Cellar/php53-mcrypt/5.3.26/mcrypt.so"
Warning! Set the correct PHP version.
警告!设置正确的PHP版本。
#7
4
I would recommend installing everything via homebrew if you have the option. I went in circles for a while, but installing php 5.x via brew and then the neccessary modules worked a treat. I was working with php 5.4 and used this to get going initially:
如果你有这个选择的话,我建议你通过自制程序来安装。我转了一会儿,但是安装了php 5。x通过brew,然后必要的模块进行处理。我使用的是php 5.4,开始使用它:
https://github.com/josegonzalez/homebrew-php
https://github.com/josegonzalez/homebrew-php
and then installed the additional modules with:
然后安装额外的模块:
brew install php54-redis
brew install php54-xdebug
brew install php54-mcrypt
...
…
#8
3
Another possibility for those who want to keep OS X as clean as possible, is to use vagrant [1] to define a php development environment. Vagrant can use VirtualBox [2] in headless mode (~3% of CPU on my 13-inch, Mid 2009 MacBook Pro) to run a virtual machine with the webserver and php and all.
对于那些希望保持OS X尽可能干净的人来说,另一种可能是使用流浪[1]来定义一个php开发环境。Vagrant可以在headless模式下使用VirtualBox[2](在我的13英寸,2009年中期的MacBook Pro中,3%的CPU)运行一个带有webserver和php的虚拟机。
To easily create the vagrant environment you can use this great tool https://puphpet.com/
为了方便地创建一个流浪的环境,您可以使用这个伟大的工具https://puphpet.com/。
- http://www.vagrantup.com/
- http://www.vagrantup.com/
- https://www.virtualbox.org/
- https://www.virtualbox.org/
#9
2
I'd create a shell script to install mcrypt module for PHP 5.3 without homebrew.
我将创建一个shell脚本,为PHP 5.3安装mcrypt模块,而不需要自制程序。
The scripts install php autoconf if needed and compile module for your php version.
如果需要,脚本将安装php autoconf,并为php版本编译模块。
The link is here: https://gist.github.com/lucasgameiro/8730619
链接在这里:https://gist.github.com/lucasgameiro/8730619。
Thanks
谢谢
#10
1
Nothing worked and finally got it working using resource @Here and Here; Just remember for OSX Mavericks (10.9) should use PHP 5.4.17 or Stable PHP 5.4.22 source to compile mcrypt. Php Source 5.4.22 here
没有任何工作,最终使用资源@这里和这里;请记住,OSX Mavericks(10.9)应该使用PHP 5.4.17或稳定的PHP 5.4.22源代码编译mcrypt。Php源5.4.22这里
#11
1
Brew base solution worked for me
Brew基础解决方案为我工作。
-
Install these packages
安装这些包
$brew install brew install mcrypt php54-mcrypt
$brew安装brew安装mcrypt php54-mcrypt。
-
Copy default php.ini.default to php.ini
复制默认的php.ini。
$sudo cp /private/etc/php.ini.default /private/etc/php.ini
$ sudo cp /私人/ etc / php.ini.default /私人/ etc / php . ini
-
Add this line to php.ini file extension section - please verify extension path with install location in your machine
将这一行添加到php中。ini文件扩展部分——请在您的机器上安装位置验证扩展路径。
extension="/usr/local/Cellar/php54-mcrypt/5.3.26/mcrypt.so"
扩展= " / usr /地方/地窖/ php54-mcrypt / 5.3.26 / mcrypt.so”
-
Restart your apache server
重新启动apache服务器
$apache restart
重新启动apache美元
#12
1
This is what I did:
这就是我所做的:
$ wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
$ tar xzvf libmcrypt-2.5.8.tar.gz
$ ./configure
$ make
$ sudo make install
$ brew install autoconf
$ wget file:///Users/rmatikolai/Downloads/php-5.4.24.tar.bz2
$ tar xjvf php-5.4.24.tar.bz2
$ cd php-5.4.24/ext/mcrypt
$ phpize
$ ./configure # this is the step which fails without the above dependencies
$ make
$ make test
$ sudo make install
$ sudo cp /private/etc/php.ini.default /private/etc/php.ini
$ sudo vi /private/etc/php.ini
Next, you need to add the line:
接下来,您需要添加一行:
extension=mcrypt.so
$ sudo apachectl restart
#13
0
mycrypt.o and mcrypt_filter.o are in the ext/.libs of your php downloaded directory. Just copy the files to ext/mcrypt, then run make && make install again.
mycrypt。o和mcrypt_filter。o在ext/。下载您的php下载目录。将文件复制到ext/mcrypt,然后运行make &&重新安装。
#14
-4
sudo apt-get install php5-mcrypt
sudo apt-get安装php5-mcrypt
ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/fpm/conf.d/mcrypt.ini
ln - s /etc/php5/mods-available / mcrypt。ini /etc/php5/fpm/conf.d/mcrypt.ini
service php5-fpm restart
服务php5-fpm重启
service nginx restart
nginx重启服务