Get Apache, PHP working on macOS Sierra

本文介绍如何在macOS上启动和停止内置的Apache服务器,并指出了默认的系统级和用户级Web目录位置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文:
https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/

原来macOS上自带了apache啊,我今天才知道。

➜  ~/GitProjects/repos_js  httpd -v                                                                                               [16:00:21]
Server version: Apache/2.4.25 (Unix)
Server built:   Feb  6 2017 19:34:08
➜  ~/GitProjects/repos_js  tcp|grep httpd                                                                                         [16:00:51]
httpd     94762    root    4u  IPv6 0x4388e3befb1b0cd9      0t0  TCP *:80 (LISTEN)
httpd     94768    _www    4u  IPv6 0x4388e3befb1b0cd9      0t0  TCP *:80 (LISTEN)
httpd     94771    _www    4u  IPv6 0x4388e3befb1b0cd9      0t0  TCP *:80 (LISTEN)
httpd     94781    _www    4u  IPv6 0x4388e3befb1b0cd9      0t0  TCP *:80 (LISTEN)
httpd     95236    _www    4u  IPv6 0x4388e3befb1b0cd9      0t0  TCP *:80 (LISTEN)
httpd     95355    _www    4u  IPv6 0x4388e3befb1b0cd9      0t0  TCP *:80 (LISTEN)

使用

sudo apachectl start/stop/restart

即可。

Web目录

系统级Web目录

/Library/WebServer/Documents。所有用户都可以访问。
直接在浏览器里输入localhost即可。
这里写图片描述

  /Library/WebServer/Documents  ll                                                                                               [16:02:41]
total 72
drwxr-xr-x  6 root  wheel   204B  2 26 15:22 ./
-rw-r--r--  1 root  wheel   3.6K  8  9  2016 PoweredByMacOSX.gif
-rw-r--r--  1 root  wheel    31K  8  9  2016 PoweredByMacOSXLarge.gif
drwxr-xr-x  5 root  wheel   170B  8  9  2016 ../
-rw-r--r--  1 root  wheel    45B  6 12  2007 index.html.en
-rw-r--r--  1 root  wheel    45B  6 12  2007 index.html.en~orig
  /Library/WebServer/Documents  cat index.html.en                                                                                [16:02:46]
<html><body><h1>It works!</h1></body></html>

用户级Web目录

~/Sites
在浏览器中输入http://localhost/~caiqiqi/即可。
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值