macOS下自带Apache和PHP相关配置

in 技术文档 with 0 commentand 15 read

macOS对于开发者还是比较友好的,在系统中内置了Apache和PHP程序,我们简单配置一下就可以用。

Apache服务器相关配置

参考 https://www.jianshu.com/p/b975c1d7c7cc

PHP相关配置

三件套

macOS中已经内置了PHP和Apache,组成三件套还需要MySQL,安装方法也特别简单,去 https://dev.mysql.com/downloads/mysql/ 下载dmg镜像,然后进行可视化安装,最后在系统偏好设置中就可以控制MySQL的关闭和开启。

文件夹写入配置

更改网站路径为 /Users/xxx/Sites 之后运行 php 程序你会发现 php 没有写入权限或者报错,这个时候你需要在终端中输入
sudo chmod -R 777 /Users/xxx/Sites/
即可让 php 拥有写文件权限

PHP:Cannot modify header information - headers already sent by 问题

macOS的php在安装某些程序(如Typecho)会报错 PHP:Cannot modify header information - headers already sent by ,解决方法是修改 php.ini 中 output_buffering = On ,重启电脑即可解决。

Comments are closed.