mac osx下配置apache

ios 交流群:264706196

欢迎访问riverli的个人博客

<br />

基础

常见命令

//查看apache版本号
 apachectl -v
//检查apache配置文件是否正确
 apachectl -t

环境

OSX yosemite 10.10.4
apache Apache/2.4.10 (Unix)

安装步骤

第一步

sudo vim /etc/apache2/httpd.conf

将前面的#去掉

#LoadModule deflate_module libexec/apache2/mod_deflate.so
#LoadModule userdir_module libexec/apache2/mod_userdir.so
#LoadModule rewrite_module libexec/apache2/mod_rewrite.so
#LoadModule php5_module libexec/apache2/libphp5.so
#Include /private/etc/apache2/extra/httpd-userdir.conf
#Include /private/etc/apache2/extra/httpd-vhosts.conf

第二步

创建根目录

mkdir  ~/Sites

将默认根目录下面的index.html拷贝到根目录下

cp /Library/WebServer/Documents/index.html.en ~/Sites/

第三步

修改Root文件位置

sudo vim /etc/apache2/httpd.conf

修改如下,将“/Library/WebServer/Documents”改为你的文件根目录(Mac是用户名)

#DocumentRoot "/Library/WebServer/Documents"
#<Directory "/Library/WebServer/Documents">
DocumentRoot "/Users/Mac/Sites"
<Directory "/Users/Mac/Sites">

第四步

执行

apachectl -t

如果出现错误

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using Mac.local. Set the 'ServerName' directive globally to suppress this message

则将httpd.conf中的

#ServerName www.example.com:80

改为

ServerName localhost:80
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容