码迷,mamicode.com
首页 > Web开发 > 详细

MacOS Catalina 10.15 brew 安装 PHP 和 使用 pecl 安装 Mcrypt

时间:2019-10-21 20:47:50      阅读:344      评论:0      收藏:0      [点我收藏+]

标签:compiler   err   配置   ase   exist   let   catalina   root   alternate   

使用本博客前请查看自己系统系统和PHP版本以免出错

———————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#再利用brew安装php7.2成功之后,出现如下信息
Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/7.2/

php@7.2 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have php@7.2 first in your PATH run:
  echo 'export PATH="/usr/local/opt/php@7.2/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/php@7.2/sbin:$PATH"' >> ~/.zshrc

For compilers to find php@7.2 you may need to set:
  export LDFLAGS="-L/usr/local/opt/php@7.2/lib"
  export CPPFLAGS="-I/usr/local/opt/php@7.2/include"

To have launchd start php@7.2 now and restart at login:
  brew services start php@7.2
Or, if you don't want/need a background service you can just run:
  php-fpm
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#因为Mac 自带了PHP版本,默认会使用系统的PHP版本,所以需要在根目录上新建文件,指定PHP的位置
vim ~/.bash_profile
#在文件中输入 【注意此处的路径】,请在电脑上核实是否存在此路径 ,否则需要利用which查看PHP中bin文件夹的路径

export PATH="/usr/local/opt/php@7.2/bin:$PATH
export PATH="/usr/local/opt/php@7.2/sbin:$PATH
export PATH="/usr/local/opt/php@7.2:$PATH

#或者
export PATH=/usr/local/Cellar/php@7.2/7.2.23/bin:$PATH
export PATH=/usr/local/Cellar/php@7.2/7.2.23:$PATH

#保存退出,在命令行输入
source ~/.bash_profile
#重新载入
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#安装完成PHP默认的.ini文件是空白的,可能不同时间段有所不同,如果不是空白的,可以跳过本节
vim  /usr/local/etc/php/7.2/php.ini
# 如果是空白的,那么需要复制一个默认的配置文件
cp /usr/local/etc/php/7.2/php.ini.default /usr/local/etc/php/7.2/php.ini

#至此PHP的配置文件安装完成,在环境中运行可以利用phpinfo();查看PHP配置信息
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#接下来利用pecl安装mcrypt
#查看是否安装了pecl版本,默认是安装完成(brew会自带pecl)在终端使用
pecl version
#出现如下信息表明安装成功

PEAR Version: 1.10.9
PHP Version: 7.2.23
Zend Engine Version: 3.2.0
Running on: Darwin appledeMacBook-Pro-4.local 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64 x86_64

#在终端使用命令安装mcrypt,使用sudo命令
sudo pecl install mcrypt
#中间会出现一次询问,输入y继续即可
libmcrypt prefix? [autodetect] : y
#最后在命令终端出现

Build process completed successfully
Installing '/usr/local/Cellar/php@7.2/7.2.23/pecl/20170718/mcrypt.so'
install ok: channel://pecl.php.net/mcrypt-1.0.3
Extension mcrypt enabled in php.ini

#表明扩展安装成功
#重启PHP后再网页中打开
brew services restart php@7.2
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#Mac OS中建议使用PECL安装PHP 扩展。brew在更新了最后版本之后很多之前的命令和扩展都不能再使用了。
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#问题1:
Warning: mkdir(): File exists in System.php on line 294

Warning: mkdir(): File exists in /usr/local/Cellar/php@7.2/7.2.23/share/php@7.2/pear/System.php on line 294
ERROR: failed to mkdir /usr/local/Cellar/php@7.2/7.2.23/pecl/20170718

#本人是直接在卸载PHP重装了,之前是因为安装PHP的路径非常混乱。如果有知道了phper可以评论,感激不尽!

MacOS Catalina 10.15 brew 安装 PHP 和 使用 pecl 安装 Mcrypt

标签:compiler   err   配置   ase   exist   let   catalina   root   alternate   

原文地址:https://www.cnblogs.com/ikai/p/11715788.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!