美文网首页
Mac Os 上的 Apache2 的简单使用

Mac Os 上的 Apache2 的简单使用

作者: Manchangdx | 来源:发表于2018-08-18 09:58 被阅读0次

Mac 系统自带 Apache2 无需安装

  • 启动服务:sudo apachectl start
  • 重启服务:sudo apachectl restart
  • 停止服务:sudo apachectl stop
  • 查看状态:sudo apachectl status
  • 查看版本:apachectl -v
  • 查看帮助:apachectl help

配置文件

  • 主配置文件:/etc/apache2/httpd.conf
  • hosts 配置文件:/etc/hosts
  • 配置文件目录:/private/etc/apache2/extra
    • 监听端口配置文件:httpd-ssl.conf
    • 站点配置文件:httpd-vhosts.conf

使用

1、终端执行 sudo apachectl start 启动 Apache 服务
2、打开浏览器地址栏输入 “http://localhost”,可以看到内容为 “It works!” 的页面
其对应的前端文件位于 /Library/WebServer/Documents/ 下
这就是 Apache 的默认根目录

3、终端执行 sudo vim /etc/apache2/httpd.conf 打开主配置文件
找到 #Include /private/etc/apache2/extra/httpd-vhosts.conf 这行
删掉 # 号,保存并退出

4、终端执行 sudo apachectl restart 重启服务

相关文章

网友评论

      本文标题:Mac Os 上的 Apache2 的简单使用

      本文链接:https://www.haomeiwen.com/subject/begxiftx.html