Mac配置Apache

查看Apache版本

httpd -v

 Apache管理

sudo apachectl start
sudo apachectl stop
sudo apachectl restart

 配置用户访问目录

默认访问:/Library/WebServer/Documents/
cd /etc/apache2/users
sudo vim username.conf

 username是用户名。

<Directory "/Users/Aaron/Sites/">
	Options Indexes FollowSymLinks MultiViews
	AllowOverride All
	Order allow,deny
	Allow from all
</Directory>

 修改Apache下的httpd.conf,去掉以下前边的“#”

LoadModule php5_module libexec/apache2/libphp5.so

LoadModule authz_core_module libexec/apache2/mod_authz_core.so

LoadModule authz_host_module libexec/apache2/mod_authz_host.so

LoadModule userdir_module libexec/apache2/mod_userdir.so

Include /private/etc/apache2/extra/httpd-userdir.conf

修改/etc/apache2/extra/httpd-userdir.conf,去掉以下代码前边的“#”

Include /private/etc/apache2/users/*.conf

 访问http://localhost/~Aaron/,提示“You don‘t have permission to access /~Aaron/ on this server”,修改

/etc/apache2/httpd.conf

<Directory />

    AllowOverride none

    Require all denied

</Directory>

 为

<Directory />

    AllowOverride none

    Require all granted

</Directory>

软链接如果不展示,那是因为访问权限的问题,可以修改文件夹权限:

chmod 777 yourfolder

  

相关推荐