mac攻略(1) -- 简单配置php开发环境

[http://www.cnblogs.com/redirect/p/6112154.html]
 
最简单直接的方式还是使用 Mac 上自带的 Apache 和 PHP。
 
1.启动 Apache
1>启动apache $sudo apachectl start;
2>启动后,在浏览器中输入 localhost ,可以看到页面上显示 It works。(/Library/WebServer/Documents/ 下的 index.html.en 文件)
3>Apache 的默认根目录是 /Library/WebServer/Documents/
 
2.添加apache对php的支持
1>打开 http.conf 配置文件:
sudo vim /etc/apache2/httpd.conf
2>找到以下代码并去掉注释(去掉前面的‘#’号), wq 保存退出。 LoadModule php5_module libexec/apache2/ libphp5.so
 
3.重启 Apache,进行php类型文件的调试
重启: sudo apachectl restart
在 Apache 的根目录 /Library/WebServer/Documents/ 下新建project文件夹并写一个php文件输出'hello world'。此时,在浏览器打开 http://localhost/project/test.php 就可以正常看到hello world 了~(如果有权限问题, sudo chown yourname:staff project 其中yourname是你自己的名字)
 
4.使用homebrew安装mysql
安装homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装mysql
brew install mysql
启动mysql
mysql.server start
 
 
 
Apache 常用命令
//启动 Apache 服务
sudo apachectl start
// 重新启动 Apache 服务
sudo apachectl restart
// 关闭 Apache 服务
sudo apachectl stop
// 查看 Apache 版本
httpd -v
原文地址:https://www.cnblogs.com/rxbook/p/7676828.html