且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

优胜美地/El Capitan php-gd + mcrypt安装

更新时间:2022-06-12 08:55:39

您是正确的,优胜美地的内置PHP不支持PNG和FreeType.
El Captian的2015/10更新:借助OS X 10.11,El Capitan PNG支持返回,但FreeType仍然缺失.

You are right, Yosemite's built-in PHP comes without PNG and FreeType support.
Update 2015/10 for El Captian: With OS X 10.11 El Capitan PNG support is back, but FreeType is still missing.

解决方案

使用Homebrew软件包管理器来轻松构建和安装完整的PHP,并将其替换为Apache的配置.如果执行以下步骤,则整个过程仅需十分钟左右.

Use the Homebrew package manager to painlessly build and install a complete PHP and replace it in Apache's config. The whole process only takes about ten minutes if you follow the steps below.

快速(但完整)的演练

(注1:我在这里使用 Homebrew ,这是OS X的软件包管理系统.如果您熟悉 MacPorts –另一个软件包管理器–您可以实现相同的功能该系统的结果.也可以将我的Homebrew解决方案与计算机上现有的MacPorts安装并行使用.)
(注2:如果您想阅读有关安装过程的所有详细信息,请查看自制软件的基本安装以及 Homebrew PHP安装信息.但是,如果您遵循以下说明,则实际上并不需要它这些步骤.)

(Note 1: I use Homebrew here, a package management system for OS X. If you are acquainted with MacPorts – another package manager – you can acchieve the same results with that system. It is also possible to use my Homebrew solution in parallel to an existing MacPorts installation on your machine.)
(Note 2: If you want to read all the details about the installation process, have a look at the Homebrew basic installation and the Homebrew PHP installation information. But you really won't need that if you follow these steps.)

现在开始...

首先从App Store安装 Xcode .如果已经拥有它,请再次检查App Store,以确保您拥有最新版本!

First install Xcode from App Store. If you already have it, check App Store again, to make sure you've got the latest version!

现在,您需要安装 Xcode命令行工具.为此,请打开一个终端并输入:

Now you need to install the Xcode Command Line Tools. To do so, open a Terminal and enter:

xcode-select --install

下一条命令将安装Homebrew软件包管理器系统:

The next command will install the Homebrew package manager system:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

该脚本说明了它将执行的操作,然后在执行操作之前暂停.

The script explains what it will do and then pauses before it does it.

下一个要输入的命令是一种系统状态测试:

The next command to enter is a kind of system status test:

brew doctor

这将检查Homebrew安装的基础知识.
我收到警告您已安装MacPorts或Fink:/opt/local/bin/port ..." ,但我成功忽略了该警告. ;)

This checks the basics of the Homebrew installation.
I got a warning "You have MacPorts or Fink installed: /opt/local/bin/port ..." which I ignored successfully. ;)

现在设置具有我们所需依赖项的自酿/重复水龙头:

Now setup the homebrew/dupes tap which has dependencies we need:

brew tap homebrew/dupes

设置自制软件/版本水龙头,它也具有我们需要的依赖项:

Setup the homebrew/versions tap which also has dependencies we need:

brew tap homebrew/versions

然后运行以下命令:

brew tap homebrew/homebrew-php

现在您已经准备好最终构建PHP.有关可用配置选项的列表,您可以运行以下选项之一:

Now you are ready to finally build PHP. For a list of available configuration options you may run one of these:

brew options php55
brew options php56

但是我只使用默认值就可以了.
为此,请根据您的需要输入这两个中的 ONE :

But I was fine just using the defaults.
To do so enter ONE of these two, depending on your needs:

brew install php55
brew install php56

(这需要一段时间,请耐心等待!)

(This takes a while, please be patient!)

在优胜美地(10.10.5)上安装php56(5.6.x)时,有一个错误,请参阅此

while installing php56 (5.6.x) on Yosemite (10.10.5) there is a bug please see this issue on github. use brew install php56 --without-ldap instead.

如果遇到类型为找不到OpenSSL的" 的错误,则说明您尚未安装Xcode命令行工具. ;)继续,安装它们并重新运行最后一个命令.

If you get an error of type "Cannot find OpenSSL's " you have not installed the Xcode Command Line Tools as I told you in the beginning. ;) Go ahead, install them and re-run that last command.

PHP现在已构建,该脚本将以有关如何使用它的一些详细信息结尾:

PHP is built now and the script will end with some details about how to use it:

打开httpd.conf(应位于/private/etc/apache2/httpd.conf),并通过添加这两行中的 ONE 来启用PHP,具体取决于您刚安装的PHP版本:

Open httpd.conf (should be located at /private/etc/apache2/httpd.conf) and enable PHP by adding ONE of these two lines, depending on which PHP version you just installed:

LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so

不要忘记,注释掉优胜美地自己的PHP版本中可能存在的任何现有 LoadModule php5_module ... 行!

Don't forget to comment out any existing LoadModule php5_module... line that might be present from Yosemite's own PHP version!

重新启动Apache

Restart Apache

sudo apachectl restart

您的新php.ini文件可在以下位置找到:/usr/local/etc/php/5.5/php.ini

Your new php.ini file can be found in: /usr/local/etc/php/5.5/php.ini

享受!