我如何在 Mac OS X Lion 上安装 php 5.4?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9534451/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 07:02:20  来源:igfitidea点击:

how do i install php 5.4 on Mac OS X Lion?

phpmacos

提问by Mohamed Hassan

I have downloaded php 5.4.0 from php.netand i want to upgrade it on mac os X lion.

我已经从php.net下载了 php 5.4.0 ,我想在 mac os X lion 上升级它。

I also want to ask if anyone knows how to upgrade apache.

我也想问有没有人知道如何升级apache。

Thanks in advance.

提前致谢。



hi i have installed it but i don't know how to configure it with httpd.conf

嗨,我已经安装了它,但我不知道如何使用 httpd.conf 配置它

 /usr/local/bin/php -v
PHP 5.4.0 (cli) (built: Mar  3 2012 02:41:24) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

i tried to add this to httpd.conf

我试图将其添加到 httpd.conf

as it said but the web server doesn't want to start

正如它所说,但网络服务器不想启动

LoadModule php5_module libexec/libphp5.so

采纳答案by memoryleak

I've blogged about how to upgrade your local PHP installation to 5.4.

我已经在博客中介绍了如何将本地 PHP 安装升级到 5.4。

Archiving content incase of external site failure:

在外部站点出现故障的情况下归档内容:

Now let's upgrade PHP in a few steps:

1. Download and unpack the PHP source archive
2. Install following packages using brew: libjpeg and pcre
3. Change directory to the source archive of PHP
4. Use the configure command to prepare the compilation process:

./configure  \
--prefix=/usr  \
--mandir=/usr/share/man  \
--infodir=/usr/share/info  \
--sysconfdir=/private/etc  \
--with-apxs2=/usr/sbin/apxs  \
--enable-cli  \
--with-config-file-path=/etc  \
--with-libxml-dir=/usr  \
--with-openssl=/usr  \
--with-kerberos=/usr  \
--with-zlib=/usr  \
--enable-bcmath  \
--with-bz2=/usr  \
--enable-calendar  \
--with-curl=/usr  \
--enable-dba  \
--enable-exif  \
--enable-ftp  \
--with-gd  \
--enable-gd-native-ttf  \
--with-icu-dir=/usr  \
--with-iodbc=/usr  \
--with-ldap=/usr  \
--with-ldap-sasl=/usr  \
--with-libedit=/usr  \
--enable-mbstring  \
--enable-mbregex  \
--with-mysql=mysqlnd  \
--with-mysqli=mysqlnd  \
--without-pear  \
--with-pdo-mysql=mysqlnd  \
--with-mysql-sock=/var/mysql/mysql.sock  \
--with-readline=/usr  \
--enable-shmop  \
--with-snmp=/usr  \
--enable-soap  \
--enable-sockets  \
--enable-sysvmsg  \
--enable-sysvsem  \
--enable-sysvshm  \
--with-tidy  \
--enable-wddx  \
--with-xmlrpc  \
--with-iconv-dir=/usr  \
--with-xsl=/usr  \
--enable-zip  \
--with-pcre-regex  \
--with-pgsql=/usr  \
--with-pdo-pgsql=/usr \
--with-freetype-dir=/usr/X11 \
--with-jpeg-dir=/usr  \
--with-png-dir=/usr/X11     
Now let's upgrade PHP in a few steps:

1. Download and unpack the PHP source archive
2. Install following packages using brew: libjpeg and pcre
3. Change directory to the source archive of PHP
4. Use the configure command to prepare the compilation process:

./configure  \
--prefix=/usr  \
--mandir=/usr/share/man  \
--infodir=/usr/share/info  \
--sysconfdir=/private/etc  \
--with-apxs2=/usr/sbin/apxs  \
--enable-cli  \
--with-config-file-path=/etc  \
--with-libxml-dir=/usr  \
--with-openssl=/usr  \
--with-kerberos=/usr  \
--with-zlib=/usr  \
--enable-bcmath  \
--with-bz2=/usr  \
--enable-calendar  \
--with-curl=/usr  \
--enable-dba  \
--enable-exif  \
--enable-ftp  \
--with-gd  \
--enable-gd-native-ttf  \
--with-icu-dir=/usr  \
--with-iodbc=/usr  \
--with-ldap=/usr  \
--with-ldap-sasl=/usr  \
--with-libedit=/usr  \
--enable-mbstring  \
--enable-mbregex  \
--with-mysql=mysqlnd  \
--with-mysqli=mysqlnd  \
--without-pear  \
--with-pdo-mysql=mysqlnd  \
--with-mysql-sock=/var/mysql/mysql.sock  \
--with-readline=/usr  \
--enable-shmop  \
--with-snmp=/usr  \
--enable-soap  \
--enable-sockets  \
--enable-sysvmsg  \
--enable-sysvsem  \
--enable-sysvshm  \
--with-tidy  \
--enable-wddx  \
--with-xmlrpc  \
--with-iconv-dir=/usr  \
--with-xsl=/usr  \
--enable-zip  \
--with-pcre-regex  \
--with-pgsql=/usr  \
--with-pdo-pgsql=/usr \
--with-freetype-dir=/usr/X11 \
--with-jpeg-dir=/usr  \
--with-png-dir=/usr/X11     

That's it. After successful configuration use ‘make test' to check your compilation and ‘sudo make install' to actually install the new version.

就是这样。成功配置后,使用“make test”检查编译,使用“sudo make install”实际安装新版本。

回答by Chuan Ma

With MacPorts,

使用 MacPorts,

  sudo port install php54 

The above will install php54 in /opt/local/bin/php54.

以上将在/opt/local/bin/php54 中安装php54

/etc] php54 -v
PHP 5.4.8 (cli) (built: Oct 19 2012 11:30:15) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

You may install other modules you like. For example, I use both memcache and apc a lot. Do the following:

您可以安装您喜欢的其他模块。例如,我经常使用 memcache 和 apc。请执行下列操作:

  sudo port install php54-memcache php54-apc

For other php54 modules you may want to add, you can find them using:

对于您可能想要添加的其他 php54 模块,您可以使用以下方法找到它们:

  port search php54

I did the following to make it my default php

我做了以下事情,使它成为我的默认 php

  sudo port select php php54

回答by Leigh

Edit:

编辑:

Don't do it like this any more. There is a php54 port available on MacPorts now.

不要再这样了。MacPorts 现在有一个 php54 端口可用。



So just for fun I gave it a go via Macports.

所以只是为了好玩,我通过 Macports 试了一下。

Macports is still on PHP 5.3.10, so I edited the Portfile.

Macports 仍然使用 PHP 5.3.10,所以我编辑了 Portfile。

$ cd /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/lang/php5
$ sudo vi Portfile

Changed:

更改:

version -> 5.4.0
autoconf213 -> autoconf
checksums -> rmd160 7842f4f2b0aa064e10c82b5702cb8333bcb97f24

After the changes I ran:

更改后我运行:

$ sudo port install php5
...
$ php -v
...
PHP 5.4.0 (cli) (built: Mar  2 2012 15:02:14) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

It seems to have broken some of the module paths, but I'm sure its an easy fix.

它似乎破坏了一些模块路径,但我相信它很容易修复。

Edit:Broken modules were fixed by going into their respective portfiles, changing the PHP version and the checksum, and reinstalling.

编辑:通过进入各自的端口文件、更改 PHP 版本和校验和并重新安装来修复损坏的模块。

回答by Eric Herlitz

I would really like to recommend this solution http://php-osx.liip.ch/

我真的很想推荐这个解决方案http://php-osx.liip.ch/

回答by Francesc Rosas

If you use Homebrew this formula is pretty handy: https://github.com/josegonzalez/homebrew-php

如果您使用 Homebrew,这个公式非常方便:https: //github.com/josegonzalez/homebrew-php

回答by cwd

@memoryleak's blog post looks pretty good. However, I was looking for resources on how to install a LAMP stack on ML I found this guidefrom diymacserver which looks fairly extensive. A sample:

@memoryleak 的博文看起来不错。但是,我正在寻找有关如何在 ML 上安装 LAMP 堆栈的资源,我从 diymacserver 中找到了本指南该指南看起来相当广泛。一个样品:

Here are the instructions for installing, configuring and starting your MAMP stack on you Intel Mac running Lion. Please note these instructions are not intended for the server version of the OS.

以下是在运行 Lion 的 Intel Mac 上安装、配置和启动 MAMP 堆栈的说明。请注意,这些说明不适用于操作系统的服务器版本。

It covers the following things:

它涵盖以下内容:

  • Installing MySQL
  • Securing your MySQL installation
  • Starting MySQL automatically
  • Installing Apache
  • Compiling Apache
  • Configuring Apache
  • Starting Apache automatically
  • Configuring virtual hosts with Apache
  • Configuring HTTPS with virtual hosts
  • Compiling PHP
  • Adding the GD module to PHP
  • Adding the mcrypt module to PHP
  • Latest tested versions
  • Upgrading MySQL
  • 安装 MySQL
  • 保护您的 MySQL 安装
  • 自动启动 MySQL
  • 安装阿帕奇
  • 编译Apache
  • 配置 Apache
  • 自动启动Apache
  • 使用 Apache 配置虚拟主机
  • 使用虚拟主机配置 HTTPS
  • 编译 PHP
  • 将 GD 模块添加到 PHP
  • 将 mcrypt 模块添加到 PHP
  • 最新测试版本
  • 升级 MySQL

I'm excited about installing a 64 bit lamp stack on ML now.

我现在很高兴在 ML 上安装 64 位灯组。

回答by Przemek

In case if you are missing UTF-8 support in PCRE, double check if you have old 8.02 pcre lib files in your /usr/lib after you install PHP 5.4 as @memoryleak suggested. This tip would saved me few hours today.

如果您在 PCRE 中缺少 UTF-8 支持,请在按照 @memoryleak 建议安装 PHP 5.4 后仔细检查 /usr/lib 中是否有旧的 8.02 pcre lib 文件。这个技巧今天可以为我节省几个小时。