• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Mac-M1Pro-安装-PHP-开发环境

php 搞代码 3年前 (2022-02-28) 7次浏览 已收录 0个评论

装置

brew install [email protected] nginx

配置环境变量

vim ~/.zshrc

# PHP
export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"
export PATH="/opt/homebrew/opt/[email protected]/sbin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"

配置完环境变量运行一下 source ~/.zshrc

如果放心错过什么提醒能够运行 brew info [email protected]

配置文件夹开启 git 治理

cd /opt/homebrew/etc/php/7.4

# 用 git 治理 php 配置, 不然容易搞乱
git init && git add .
git commit -m "feat: initial commit"

cd /opt/homebrew/etc/nginx

# 用 git 治理一下 nginx 配置, 不然容易搞乱
git init && git add .
git commit -m "feat: initial commit"

创立 index.php

vim /opt/homebrew/var/www/index.php

<?php
    phpinfo();

批改 nginx 配置

vim /opt/homebrew/etc/nginx/nginx.conf

        location / {
            root   html;
            index  index.html index.htm index.php;
        }

        location ~ \.php$ {
           root           html;
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
           include        fastcgi_params;
        }

批改阐明
1、index 行增加 index.php
2、勾销 php 相干的正文, 把默认的 /scripts$fastcgi_script_name 批改为 $document_root$fastcgi_script_name

重启服务

brew services restart [email protected]
brew services restart nginx

拜访 http://localhost:8080/index.php 就能看到 phpinfo 信息页

php 扩大

能够用 pecl 装置扩大, 不必手动去 php.ini 中开启

pecl install xdebug

idea 配置 xdebug

文件夹地位

nginx 门路:/opt/homebrew/var/www
nginx 配置文件:/opt/homebrew/etc/nginx/nginx.conf
nginx 默认端口是 8080 (80端口须要sudo)

php 配置文件:/opt/homebrew/etc/php/7.4/
php-fpm 默认监听 9000 端口


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Mac-M1Pro-安装-PHP-开发环境

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址