Open FrankFan opened 7 years ago
Mac OS 自带 Apache 服务器。
查看版本: sudo apachectl -v 启动: sudo apachectl start 关闭: sudo apachectl stop 重启: sudo apachectl restart 检测语法: apachectl -t 配置文件路径: /etc/apache2/httpd.conf
sudo apachectl -v
sudo apachectl start
sudo apachectl stop
sudo apachectl restart
apachectl -t
修改Apache配置文件,
0) 修改DocumentRoot DocumentRoot "/path/to/Sites"
DocumentRoot "/path/to/Sites"
1) 增加alias配置 Alias /site /Users/fanyong/Sites
Alias /site /Users/fanyong/Sites
2)增加Directory
# add <Directory "/Users/fanyong/Sites"> AllowOverride None Options None Require all granted </Directory>
默认情况下,APACHE禁止用户浏览目录内容,有时候为了方便可以这样开启: 1) 列出(禁止列出)网站目录: 修改Directory配置
# Options Indexes FollowSymLinks # 可以列出 # Options FollowSymLinks # 禁止列出
Forbidden You don't have permission to access /site/tmp/cmd.jpg on this server.
sudo chmod -R 755 /your/dirs/
Mac OS 配置Apache服务器
Mac OS 自带 Apache 服务器。
基本配置
查看版本:
sudo apachectl -v
启动:sudo apachectl start
关闭:sudo apachectl stop
重启:sudo apachectl restart
检测语法:apachectl -t
配置文件路径: /etc/apache2/httpd.conf修改Apache配置文件,
0) 修改DocumentRoot
DocumentRoot "/path/to/Sites"
1) 增加alias配置
Alias /site /Users/fanyong/Sites
2)增加Directory
高级配置
默认情况下,APACHE禁止用户浏览目录内容,有时候为了方便可以这样开启: 1) 列出(禁止列出)网站目录: 修改Directory配置