mac下配置apache以及403问题

2015-11-25阅读(6240)评论(0)牵着狗狗看MM

苏州实时公交查询

mac下是自带Apache服务器的,不需要另外安装。

开启Apache

在终端中输入以下指令即可对Apache进行相关操作

//开启apache服务 
sudo apachectl start 
//停止apache服务 
sudo apachectl stop 
//重启服务 
sudo apachectl restart 
//查看版本 
httpd -v

打开apache服务后,在浏览器输入http://localhost/即可看到提示.

修改默认路径

程序的根目录在/Library/WebServer/Documents/ 下,假设我在桌面新建了一个文件夹“web”,我要把这个“web”文件夹设为默认的程序根目录(这个桌面文件夹的路径为“/Users/你的user/Desktop/web”)。
进行如下操作:
在终端输入

sudo vi /etc/apache2/httpd.conf

找到两处/Library/WebServer/Documents/
修改为/Users/你的用户名/Desktop/web
主机配置部分如下

<Directory />
    Options Indexes MultiViews
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>

<Directory "/Users/你的user/Desktop/web">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

任何保存并退出。
然后浏览器打开http://localhost/index.html即可打开。
如果出现You don t have permission to access / on this server ,那说明没有访问权限。
打开终端输入如下指令:

sudo chmod -R 777 /Users/你的user/Desktop/web

赞(0)
转载请注明来源:Web前端(W3Cways.com) - Web前端学习之路 » mac下配置apache以及403问题
分享到: 更多 (0)