- 打开终端,开启Apache:
//开启apache: sudo apachectl start
//重启apache: sudo apachectl restart
//关闭apache: sudo apachectl stop
回车会提示输入密码,也就是你电脑的密码,http://127.0.0.1/ 测试一下,页面显示It work,就是本地服务器打开了。
- 点击Finder,然后Command+Shift+G,前往如下路径(mac下Apache服务器的文件路径)
/Library/WebServer/Documents
然后往里面拖你所要访问文件和图片
此时如果我在浏览器的网址框输入的是http://127.0.0.1/PoweredByMacOSX.gif, 浏览器就便会显示PoweredByMacOSXLarge.gif图片.
- 使用过后,记得关闭服务器,要不然会一直消耗你电脑内存,后果你懂的。