mac osx下配置apache

来源:互联网 发布:mac 终端退出 bash 编辑:程序博客网 时间:2024/05/16 19:02

欢迎访问个人博客

基础

常见命令

//查看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
0 0