macos 在 MAC 上升级到 PHP 5.4 并删除版本 5.3.10
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11004376/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Upgrade to PHP 5.4 on MAC and remove version 5.3.10
提问by pkberlin
I would tring to update my php version to the version 5.4.
我会尝试将我的 php 版本更新到 5.4 版。
When I'm looking via /usr/local/bin/php -v in the console I see the version 5.4.3 and with php -v it tell me there is the version 5.3.10 installed.
当我在控制台中通过 /usr/local/bin/php -v 查看时,我看到了 5.4.3 版,而 php -v 告诉我安装了 5.3.10 版。
How can I remove the older version?
如何删除旧版本?
回答by Mikulas Dite
Update: As of early 2014, you are probably better of installing from http://php-osx.liip.ch/builds as it contains most extensions. In case you really do need to compile your own, follow the original answer.
更新:截至 2014 年初,您可能最好从http://php-osx.liip.ch/builds安装,因为它包含大多数扩展。如果您确实需要自己编译,请按照原始答案进行操作。
Original answer:
原答案:
Mac comes with a preinstalled php you can easily overwrite.
Mac 预装了 php,您可以轻松覆盖。
This is a list of steps I take to update the php I have installed:
这是我更新已安装的 php 所采取的步骤列表:
Prerequisites:
先决条件:
- Xcode and it's Command line utilities (install form preferences) will give you a gcc compiler to build the php with
- libjpeg, libpng etc. if you want to build with these.
- Xcode 及其命令行实用程序(安装表单首选项)将为您提供一个 gcc 编译器来构建 php
- libjpeg、libpng 等,如果你想用这些来构建。
Building and installing php:
构建和安装php:
- Download the distribution from www.php.net/downloads.php
- Untar the archive and point your console into the location
- Now, having still the original old php installed, run
php -i | head
in the console. What you want is to configure your new php with these flags to ensure you have proper pcre support and everything works just fine. - In the php source directory you untarred, run the
./configure
script with the flags you just got - Build php by running
make
andsudo make install
afterwards. That will actually replace the original php distributed with OS X.
- 从 www.php.net/downloads.php 下载发行版
- 解压存档并将您的控制台指向该位置
- 现在,仍然安装了原始的旧 php,
php -i | head
在控制台中运行。你想要的是用这些标志配置你的新 php,以确保你有适当的 pcre 支持并且一切正常。 - 在解压后的 php 源目录中,
./configure
使用刚刚获得的标志运行脚本 - 通过运行
make
和sudo make install
之后构建 php 。这实际上将替换与 OS X 一起分发的原始 php。
And dont forget to run make test
...
并且不要忘记运行make test
...
Ex.: my workflow for building php
例如:我构建 php 的工作流程
wget http://url_to/php_source.tar.gz
tar -zxvf php_source.tar.gz
cd php_source/
php -i | head
./configure --prefix=/usr --with-snmp # ... same flags as previous build
make
sudo make install