当前位置: 首页 > news >正文

Mac M2芯片配置PHP环境

Mac M2芯片配置PHP环境

  • 1. XAMPP
  • 2. PHPBrew(PHP版本管理)
    • 安装php7.4.33版本
  • 3. 直接使用homebrew 安装php环境
  • 参考

1. XAMPP

官网地址 https://www.apachefriends.org/

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

安装
在这里插入图片描述
安装完成
在这里插入图片描述

web server打开后,在打开localhost 成功!
在这里插入图片描述

在这里插入图片描述

2. PHPBrew(PHP版本管理)

官方文档 https://github.com/phpbrew/phpbrew/blob/master/README.cn.md
HomeBrew关于 PHPBrew的文档 https://formulae.brew.sh/formula/phpbrew

安装
这里我们通过homebrew安装

brew install phpbrew

在这里插入图片描述
在这里插入图片描述

init
在这里插入图片描述

Using root: /Users/fanzhen/.phpbrew
Initialization successfully finished!
<=====================================================>
Phpbrew environment is initialized, required directories are created under/Users/fanzhen/.phpbrewPaste the following line(s) to the end of your ~/.bashrc and start a
new shell, phpbrew should be up and fully functional from there:source /Users/fanzhen/.phpbrew/bashrcTo enable PHP version info in your shell prompt, please set PHPBREW_SET_PROMPT=1
in your `~/.bashrc` before you source `~/.phpbrew/bashrc`export PHPBREW_SET_PROMPT=1To enable .phpbrewrc file searching, please export the following variable:export PHPBREW_RC_ENABLE=1For further instructions, simply run `phpbrew` to see the help message.Enjoy phpbrew at $HOME!!<=====================================================>

在这里插入图片描述

# phpbrew
source /Users/fanzhen/.phpbrew/bashrc
export PHPBREW_SET_PROMPT=1
export PHPBREW_RC_ENABLE=1

之后就可以正常使用了
在这里插入图片描述

安装php7.4.33版本

phpbrew install 7.4.33 +default

在这里插入图片描述
但是这里下载的速度太慢了需要解决!!!

3. 直接使用homebrew 安装php环境

1、查看 php 版本

php -v

此时发现没有php环境的话,就全新安装

2、brew tap加速,使用github库
homebrew默认使用官方的库,但这个源很慢,一般我们会使用第三方tap

brew tap shivammathur/php

3、安装php7.4

brew install shivammathur/php/php@7.4

4、创建link,这样可以在全局环境里访问

brew link --overwrite --force php@74

在这里插入图片描述
在这里插入图片描述

==> Summary
🍺  /opt/homebrew/Cellar/php@7.4/7.4.33_5: 499 files, 72.9MB
==> Running `brew cleanup php@7.4`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> php@7.4
To enable PHP in Apache add the following to httpd.conf and restart Apache:LoadModule php7_module /opt/homebrew/opt/php@7.4/lib/httpd/modules/libphp7.so<FilesMatch \.php$>SetHandler application/x-httpd-php</FilesMatch>Finally, check DirectoryIndex includes index.phpDirectoryIndex index.php index.htmlThe php.ini and php-fpm.ini file can be found in:/opt/homebrew/etc/php/7.4/php@7.4 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.If you need to have php@7.4 first in your PATH, run:echo 'export PATH="/opt/homebrew/opt/php@7.4/bin:$PATH"' >> ~/.zshrcecho 'export PATH="/opt/homebrew/opt/php@7.4/sbin:$PATH"' >> ~/.zshrcFor compilers to find php@7.4 you may need to set:export LDFLAGS="-L/opt/homebrew/opt/php@7.4/lib"export CPPFLAGS="-I/opt/homebrew/opt/php@7.4/include"To start shivammathur/php/php@7.4 now and restart at login:brew services start shivammathur/php/php@7.4
Or, if you don't want/need a background service you can just run:/opt/homebrew/opt/php@7.4/sbin/php-fpm --nodaemonize

在这里插入图片描述

# php7.4
export PATH="/opt/homebrew/opt/php@7.4/bin:$PATH"
export PATH="/opt/homebrew/opt/php@7.4/sbin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/php@7.4/lib"
export CPPFLAGS="-I/opt/homebrew/opt/php@7.4/include"

在这里插入图片描述

参考

  1. PHPBrew 使用指南 https://www.jianshu.com/p/d5b0d40e56ee
  2. phpbrew set mirror(加速)https://minbaby.github.io/post/2018-11/phpbrew-set-mirror/
http://www.lryc.cn/news/304122.html

相关文章:

  • [嵌入式系统-25]:RT-Thread -12- 内核组件编程接口 - 网络组件 - HTTP编程
  • 一个服务器实现本机服务互联网化
  • django配置视图并与模版进行数据交互
  • Java进阶
  • ⭐北邮复试刷题106. 从中序与后序遍历序列构造二叉树__递归分治 (力扣每日一题)
  • K8S更新部署docker的两种方法举例
  • Java高并发编程基础之Thread构造函数大有内涵
  • 2023年12月 Python(六级)真题解析#中国电子学会#全国青少年软件编程等级考试
  • 代码随想录算法训练营第一天
  • 基于 java springboot+layui仓库管理系统
  • 电商平台商家结算
  • AIGC 实战:如何使用 Docker 在 Ollama 上离线运行大模型(LLM)
  • MII、RMII、GMII和RGMII,以太网接口中常见的几种标准接口
  • SpringCloudConfig+SpringCloudBus+Actuator+Git实现Eureka关键配置属性热更新(全程不重启服务)
  • 郑州大学2024年寒假训练 Day7:数论
  • “目标检测”任务基础认识
  • springboot+vue的宠物咖啡馆平台(前后端分离)
  • LaWGPT—基于中文法律知识的大模型
  • 一文弄明白KeyedProcessFunction函数
  • alibabacloud学习笔记06(小滴课堂)
  • Code Composer Studio (CCS) - Licensing Information
  • uniapp引入微信小程序直播组件
  • 五个简单的C#编程案例
  • Zlibrary低调官宣2024年最新网址,国内可直接访问,免费下载海量电子书籍
  • Android 开机启动
  • 二叉树相关算法需了解汇总-基础算法操作
  • 万字干货-京东零售数据资产能力升级与实践
  • 探索前端框架的世界:一场前端之旅
  • class complex
  • 数据库系统概论整理与总结