Mac下安装php5.6/7.1

安装环境

OS X EI Capitan 10.11.4

Homebrew安装

homebrew是一个类似于ubuntu中apt-get的一个软件管理器,安装比较简单,在命令行中输入如下代码:

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

安装php7.1

Mac是预装了php,不过很多扩展都没安装,尤其时在系统更新的时候,Mac会重置你的php配置,造成了不必要的麻烦,所以最好还是自己安装php。在命令行中输入如下语句:

brew tap homebrew/dupes
brew tap homebrew/php
brew install php71 --with-apxs2  --with-apache --with-fpm --with-mysql --with-gmp --with-imap --with-tidy --with-debug

Homebrew安装php的时候会有很多版本选择,可以使用brew search php命令来查看有什么版本可以安装。

配置环境变量

php安装完成后,接下来就是配置环境变量(前面说过Mac预装了php,在终端调用php命令时,使用的是预装的php)

echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile

创建文件夹,并设置开机启动服务

mkdir -p ~/Library/LaunchAgents
ln -sfv /usr/local/opt/php71/homebrew.mxcl.php71.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php71.plist

OK,php-fpm安装完成。

要修改配置 php 或者 php-fpm 的话,可以修改 "/usr/local/etc/php/7.1/php.ini" 、 "/usr/local/etc/php/7.1/php-fpm.conf"。

转载于:https://www.cnblogs.com/rxbook/p/6587052.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装laravel的一个扩展时,提示没有ZipArchive 我根据国外的一个网站的提示进行操作,任然不成功,后重新修改了这个包才成功 首先要执行下面操作 brew update brew install php@7.3 brew link php@7.3 然后执行 Step 1: Install PEAR/PECL support cd /tmp curl -s -O https://pear.php.net/install-pear-nozlib.phar sudo php install-pear-nozlib.phar -d /usr/local/lib/php -b /usr/local/bin (credit) Step 2: Download zip extension source I tried installing zip with pecl, but that failed because the PHP header files were missing. So I downloaded the source for the zip extension from pecl. Step 3:下载我提供的包文件 然后解压 Step 4: Copy/modify phpsize and php-config In order to make phpize and php-config find the PHP header files in the location that XCode places them rather than in /usr/include/php -- a read-only location now -- I followed some tips I found elsewhere and copied and modified phpize and php-config to change the include directory in each of them. cp /usr/bin/phpize /usr/local/bin/phpize cp /usr/bin/php-config /usr/local/bin/php-config Step 5: Build the zip PHP extension With all of those changes in place, I could now build the zip extension. cd zip-1.15.5 phpize ./configure -with-php-config=/usr/local/bin/php-config make Step 6: Install zip PHP extension make install fails to install the extension, again because of the read-only file system. So instead I created an extension directory under /usr/local/php. mkdir -p /usr/local/php/extensions cp modules/zip.so /usr/local/php/extensions/zip.so Step 7: Update your PHP.ini Finally we need to tell PHP to load this extension. sudo vim /etc/php.ini Add the following line: extension=/usr/local/php/extensions/zip.so Restart apache with sudo apachectl restart and you'll see the zip extension being loaded now.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值