Mac10.11.2 Apache 服务配置

系统默认是隐藏apache安装目录的,但我们可以通过“命令行”或者“文件夹前往”的方式找到它。它是安装在系统的私有目录下,也就是/private/etc下面,因为它是隐藏的,所以我们无法通过界面找到它

1、启动:

sudo apachectl start

 

2、重启/停止

sudo apachectl restart

 sudo apachectl stop

 

3、创建个人站点目录

cd ~/

mkdir Sites

echo "hello" >> index.html

sudo apachectl restart

4、启用虚拟主机

默认情况下,apache的虚拟主机功能是关闭的,在“/etc/apache2/httpd.conf”中找到下面这行:

#Include /private/etc/apache2/extra/httpd-vhosts.conf

将前面的#去掉,然后再打开“/etc/apache2/extra/httpd-vhosts.conf”,内容修改成类似下面的样子:

<VirtualHost *:8081>
    DocumentRoot "/Users/huhmf/Sites"
    ServerName www.huhmf.com
    ErrorLog "/Users/huhmf/Sites/log/error.log"
    CustomLog "/Users/huhmf/Sites/log/access.log" common
    <Directory />
	  Options Indexes FollowSymLinks MultiViews
	  AllowOverride None
	  Require all granted
	</Directory>
</VirtualHost>

 5、修改apache默认端口

同样是在httpd.conf下面,找到Listen 80 那一行,修改成你想要的端口即可。

6、修改host,使用命令:sudo vi /etc/hosts

127.0.0.1    www.huhmf.com

 

访问服务器:

转自:http://www.cnblogs.com/yjmyzz/p/3920361.html

 

posted on 2015-12-29 20:23  二狗你变了  阅读(260)  评论(0编辑  收藏  举报

导航