Mac Apache 配置
来源:互联网 发布:php数组按键名排序 编辑:程序博客网 时间:2024/06/05 14:37
本机默认站点目录:/Library/WebServer/Documents
在Mac OS X中可以很方便的通过开启“Web共享”启用Apache服务:
设置方法如下:
打开“系统设置偏好(System Preferences)” -> “共享(Sharing)” -> “Web共享(Web Sharing)”选中即可
启动Apache
有两种方法:
- 打开“系统设置偏好(System Preferences)” -> “共享(Sharing)” -> “Web共享(Web Sharing)”
- 打开“终端(terminal)”,然后(注意:sudo需要的密码就是系统的root帐号密码)
- 运行“
sudo apachectl start
”,再输入帐号密码,这样Apache就运行了。这样在浏览器中输入“http://localhost”,就可以看到出现一个内容为“It works!”的页面,它位于“/Library(资源库)/WebServer/Documents/”下,这是Apache的默认根目录。
注意:开启了Apache就是开启了“Web共享”,这时联网的用户就会通过“http://[本地IP]/”来访问“/Library(资源库)/WebServer/Documents/”目录,通过“http://[本地IP]/~[用户名]”来访问“/Users/[用户名]/Sites/”目录,可以通过设置“系统偏好设置”的“安全(Security)”中的“防火墙(Firewall)”来禁止这种访问。
系统默认给当前用户的访问目录是http://localhost/~username的形式,指向的是用户home目录下的Sites目录。而很多情况下我们希望直接访问根目录(http://localhost/)便可直接访问自己的Sites目录而非系统默认的目录。
做如下更改即可:
1.打开/etc/apache2/httpd.conf文件
<span style="color: rgb(194, 12, 185);"><strong>sudo</strong></span> <span style="color: rgb(194, 12, 185);"><strong>vim</strong></span> <span style="font-weight: bold;">/</span>etc<span style="font-weight: bold;">/</span>apache2<span style="font-weight: bold;">/</span>httpd.conf
2.找到
<span style="font-weight: bold;">/</span>Library<span style="font-weight: bold;">/</span>WebServer<span style="font-weight: bold;">/</span>Documents
替换成
<span style="font-weight: bold;">/</span>Users<span style="font-weight: bold;">/</span><span style="color: rgb(122, 8, 116);"><strong>{</strong></span>username<span style="color: rgb(122, 8, 116);"><strong>}</strong></span><span style="font-weight: bold;">/</span>Sites
其中{username}是你登陆用户名,如:
<span style="font-weight: bold;">/</span>Users<span style="font-weight: bold;">/</span>liangc<span style="font-weight: bold;">/</span>Sites
3.重启“Web共享(Web Sharing)” (去掉勾再重新选中即可)
或者 运行“sudo apachectl restart
”
重启成功后,无需再加上用户名,便可以使用http://localhost/直接访问自己Sites目录下的内容
原文:http://blog.csdn.net/chenlia/article/details/7695804
注:
You don't have permission to access / on this server. 错误
打开apache的配置文件httpd.conf,
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
由于配置了php后,这里的“Deny from all”已经拒绝了一切连接。把该行改成“allow from all”,修改后的代码如下,问题解决。
Options FollowSymLinks
AllowOverride None
Order deny,allow
allow from all
</Directory>
- Mac Yosemite 配置Apache
- Mac 配置 Apache 服务器
- MAC下Apache配置
- Mac下配置Apache
- mac 配置 Apache Tomcat
- Mac 配置 Apache .php
- MAC配置apache
- Mac Apache 配置
- Mac配置Apache
- mac的apache配置
- Mac系统Apache配置
- mac 上apache配置
- Mac Apache服务器配置
- mac配置apache服务器
- Mac Apache 配置二级域名
- mac下 apache cgi 配置
- mac 配置 apache+php+mysql
- Mac 配置 SVN 、Apache服务器
- iOS开发之如何跳到系统设置里的各种设置界面
- 执行篇:解析JDK 7的动态类型语言支持
- sqlite3 join
- ubuntu系统debootstrap的使用
- UDP客户端
- Mac Apache 配置
- UGUI中带参数事件的使用,itween动画注意事项以及切换场景
- 推荐两个安卓手机测试的辅助工具
- 【React Native开发】React Native控件之ListView组件讲解以及最齐全实例(19)
- hdu--4081
- linux解压
- 内核态和用户态的区别
- Supermarket
- sbt发布assembly解决jar包冲突问题 deduplicate: different file contents found in the following