mac+php7+mysql.so_Mac 下安装PHP7替换掉自带的php | 极安全-JiSec

随着PHP7实际线上使用的越来越多,据测试,效率得到大幅提升,当然我们也得紧跟步伐向前走了,首先mac 是自带了php5.5.3环境 ,我们就需要自己再安装一个php7然后替换掉原有的php就可以了.

1.安装homebrew

homebrew是mac下非常好用的包管理器,会自动安装相关的依赖包,将你从繁琐的软件依赖安装中解放出来。

安装homebrew也非常简单,只要在终端中输入:

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

homebrew的常用命令:

brew update #更新可安装包的最新信息,建议每次安装前都运行下

brew search pkg_name #搜索相关的包信息

brew install pkg_name #安装包

2.替换homebrew镜像源

由于homebrew上面的东西 很多要么被墙,要么死慢,需要替换掉原有的brew源

这里用的清华大学的源

用终端 输入以下

cd /usr/local

git remote set-url origin git://mirrors.tuna.tsinghua.edu.cn/homebrew.git

brew update

然后可以安装 nginx mysql 之类的 这里只介绍安装php

3.安装替换原有的PHP

添加brew的PHP扩展库:

brew tap homebrew/dupes

brew tap homebrew/php

brew update

brew search php   # 这里搜索的是全部php版本

brew search php7  # 安装PHP7我们就这样搜

3e20bcbc0bfddcddf8f23ec0c427cd23.png

选择一个要安装的php的版本这里选择的php7

然后执行brew install homebrew/php/php70

文章出处:https://www.jisec.com

开始安装PHP7,安装后的php-fpm.ini以及php.ini都在目录:/usr/local/etc/php/5.6/下面

这个安装完成有有提示

安装完成后有提示

songdeMacBook-Pro:w3af song$ brew install homebrew/php/php70

==> Installing php70 from homebrew/homebrew-php

==> Downloading https://homebrew.bintray.com/bottles-php/php7.0.6.el_capitan.bottle

Already downloaded: /Library/Caches/Homebrew/php7.0.6.el_capitan.bottle.3.tar.gz

==> Pouring php7.0.6.el_capitan.bottle.3.tar.gz

==> Caveats

To enable PHP in Apache add the following to httpd.conf and restart Apache:

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

The php.ini file can be found in:

/usr/local/etc/php/7.0/php.ini

✩✩✩✩ Extensions ✩✩✩✩

If you are having issues with custom extension compiling, ensure that

you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:

PATH="/usr/local/bin:$PATH"

PHP56 Extensions will always be compiled against this PHP. Please install them

using --without-homebrew-php to enable compiling against system PHP.

✩✩✩✩ PHP CLI ✩✩✩✩

If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc,

~/.zshrc, ~/.profile or your shell's equivalent configuration file:

export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"

✩✩✩✩ FPM ✩✩✩✩

To launch php-fpm on startup:

mkdir -p ~/Library/LaunchAgents

cp /usr/local/opt/php70/homebrew.mxcl.php70.plist ~/Library/LaunchAgents/

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

The control script is located at /usr/local/opt/php70/sbin/php70-fpm

OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH:

PATH="/usr/local/sbin:$PATH"

You may also need to edit the plist to use the correct "UserName".

Please note that the plist was called 'homebrew-php.josegonzalez.php70.plist' in old versions

of this formula.

To have launchd start homebrew/php/php70 at login:

ln -sfv /usr/local/opt/php56/*.plist ~/Library/LaunchAgents

Then to load homebrew/php/php70 now:

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

==> Summary

🍺 /usr/local/Cellar/php70/7.0.6: 330 files, 50M

58cf1154c4dba010e0d208f45cbc17c1.png

然后看到每个✩✩✩✩ ✩✩✩✩ 后面就是重点

大概就是说如果要替换掉自带的php就 执行以下操作

你执行下后面的命令 全部执行完后 然后 php -v 查看版本 php -m 看有哪些扩展

这样 替换php版本就完成了

brew安装的php默认是没有安全redis扩展 如果还有用上其他的扩展自行用brew下载对应版本扩展即可

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值