FrankFan / blog

blog
2 stars 0 forks source link

Mac OS 配置Apache服务器 #2

Open FrankFan opened 7 years ago

FrankFan commented 7 years ago

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

image

2)增加Directory

# add
<Directory "/Users/fanyong/Sites">
    AllowOverride None
    Options None
    Require all granted
</Directory>

image

高级配置

默认情况下,APACHE禁止用户浏览目录内容,有时候为了方便可以这样开启: 1) 列出(禁止列出)网站目录: 修改Directory配置

# Options Indexes FollowSymLinks # 可以列出
# Options FollowSymLinks # 禁止列出
FrankFan commented 7 years ago

Forbidden You don't have permission to access /site/tmp/cmd.jpg on this server.

sudo chmod -R 755 /your/dirs/