使用本博客前请查看自己系统系统和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/
[email protected] 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 [email protected] first in your PATH run:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc
For compilers to find [email protected] you may need to set:
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
To have launchd start [email protected] now and restart at login:
brew services start [email protected]
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/[email protected]/bin:$PATH
export PATH="/usr/local/opt/[email protected]/sbin:$PATH
export PATH="/usr/local/opt/[email protected]:$PATH
#或者
export PATH=/usr/local/Cellar/[email protected]/7.2.23/bin:$PATH
export PATH=/usr/local/Cellar/[email protected]/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/[email protected]/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 [email protected]
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#Mac OS中建议使用PECL安装PHP 扩展。brew在更新了最后版本之后很多之前的命令和扩展都不能再使用了。
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#问题1:
Warning: mkdir(): File exists in System.php on line 294
Warning: mkdir(): File exists in /usr/local/Cellar/[email protected]/7.2.23/share/[email protected]/pear/System.php on line 294
ERROR: failed to mkdir /usr/local/Cellar/[email protected]/7.2.23/pecl/20170718
#本人是直接在卸载PHP重装了,之前是因为安装PHP的路径非常混乱。如果有知道了phper可以评论,感激不尽!
原文地址:https://www.cnblogs.com/ikai/p/11715788.html
时间: 2024-11-06 12:47:45