您的位置:首页 > 运维架构 > Apache

mac osx下配置apache

2015-09-15 14:33 513 查看

欢迎访问个人博客

基础

常见命令

//查看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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: