Mac os自带Apache,可以自己使用终端启动和关闭
// 启动Apache服务
sudo /usr/sbin/apachectl start
// 重新启动Apache服务
sudo /usr/sbin/apachectl restart
// 关闭Apache服务
sudo /usr/sbin/apachectl stop
// 查看Apache的版本
httpd -v
1.Apache服务默认安装路径在 /private/etc/apache2 ,属于系统私有目录。在该目录下找到并打开 httpd.conf 文件
vim http.conf
2.第一次启动时,我们可以在浏览器中输入http://localhost 或 http://127.0.0.1 网址来检查Apache服务是否启动成功。如果Apache服务启动成功,页面会显示It works!
3.Apache服务默认部署路径在 /Library/WebServer/Documents/ 因此我们的项目需要放置在该路径下。
当然我们也可以修改部署路径,可以在 /private/etc/apache2 目录下找到并打开 httpd.conf 文件,搜索 Documentroot 并修改部署路径,重启apache生效。
4. 端口号修改
Apache服务端口号默认为80,如果想要修改端口号,可以在 /private/etc/apache2 目录下找到并打开httpd.conf文件,搜索Listen 80并修改端口号。
参考文档:
1.https://www.jianshu.com/p/e6cebf50e81b