Apache
在 Mac OS 10.10.1 中是自带Apache软件的,我们只需要启动对应的服务即可运行。
// 切到root帐号 sudo su // 启动Apache服务 sudo apachectl start // 重新启动Apache服务 sudo apachectl restart // 关闭Apache服务 sudo apachectl stop // 查看Apache的版本 $ httpd -v Server version: Apache/2.4.48 (Unix) Server built: Oct 1 2021 20:08:18
- Apache根目录 /Library/WebServer/Documents
- Apache配置目录 /etc/apache2
- Apache模块地址 /usr/libexec/apache2
备份文件 $ sudo cp httpd.conf httpd.conf.bak
恢复备份 $ sudo cp httpd.conf.bak httpd.conf
本地配置 httpd.conf:
#apache端口
listen 80
#修改Apache根目录
<Directory "/Users/chaoshen/web/www">
...
</Directory>
#开启目录浏览,Options可以有多个配置, 用空格分隔
Options Indexes FollowSymLinks Multiviews
#Indexes:浏览权限(当此目录下没有默认网页文件时,显示目录内容)
#FollowSymLinks:准许软连接到其他目录
当不清楚apache位置时,可以使用以下命令:
$ sudo find / -name httpd
/usr/sbin/httpd
/usr/share/httpd
/Library/WebServer/share/httpd
/System/Library/Templates/Data/Library/WebServer/share/httpd
/System/Volumes/Data/usr/share/httpd
$ sudo find / -name apachectl
find / -name httpd.conf
此处直接使用find可能出现权限问题,具体参考: