mac 部署 apache
2015-10-11 12:21
519 查看
创建个人站点目录
cd ~/ mkdir Sites
创建成功后再在 用户/[你的用户名]/Sites 目录下创建log目录和index.html文件
请检查”/etc/apache2/users”目录下,是否有名为“maomao.conf”的配置文件(同样:maomao需换成你的mac用户名),如果没有,手动创建一个,内容参考下面:(Directory的maomao替换掉)
<Directory "/Users/maomao/Sites/"> Options FollowSymLinks Indexes MultiViews AllowOverride All Order allow,deny Allow from all </Directory>
sudo vi /etc/hosts 以管理员身份打开hosts文件,追加一行
127.0.0.1 www.maomao.com
启用虚拟主机
默认情况下,apache的虚拟主机功能是关闭的,在“/etc/apache2/httpd.conf”中找到下面这行:
#Include /private/etc/apache2/extra/httpd-vhosts.conf
将前面的#去掉,然后再打开“/etc/apache2/extra/httpd-vhosts.conf”,内容修改成类似下面的样子:(maomao改成你的mac用户名)
# Virtual Hosts # # Required modules: mod_log_config # If you want to maintain multiple domains/hostnames on your # machine you can setup VirtualHost containers for them. Most configurations # use only name-based virtual hosts so the server doesn't need to worry about # IP addresses. This is indicated by the asterisks in the directives below. # # Please see the documentation at # <URL:http://httpd.apache.org/docs/2.4/vhosts/> # for further details before you try to setup virtual hosts. # # You may use the command line option '-S' to verify your virtual host # configuration. # # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for all requests that do not # match a ServerName or ServerAlias in any <VirtualHost> block. # #<VirtualHost *:80> # ServerAdmin webmaster@dummy-host.example.com # DocumentRoot "/usr/docs/dummy-host.example.com" # ServerName dummy-host.example.com # ServerAlias www.dummy-host.example.com # ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log" # CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common #</VirtualHost> #<VirtualHost *:80> # ServerAdmin webmaster@dummy-host2.example.com # DocumentRoot "/usr/docs/dummy-host2.example.com" # ServerName dummy-host2.example.com # ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log" # CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common #</VirtualHost> <VirtualHost *:80> DocumentRoot "/Library/WebServer/Documents" ServerName localhost ErrorLog "/private/var/log/apache2/localhost-error_log" CustomLog "/private/var/log/apache2/localhost-access_log" common </VirtualHost> <VirtualHost *:80> DocumentRoot "/Users/maomao/Sites" ServerName www.maomao.com ErrorLog "/Users/maomao/Sites/log/error.log" CustomLog "/Users/maomao/Sites/log/access.log" common <Directory /> Options Indexes FollowSymLinks MultiViews AllowOverride None Order deny,allow Allow from all </Directory> </VirtualHost>
修改private/ect/apache2/http.conf
(这一步很重要,否则会报权限错误)
<Directory /> AllowOverride none #Require all denied allow from All </Directory>
启动服务器
udo apachectl start
访问www.maomao.com即可
相关文章推荐
- MAC OS上搭建Apache、PHP、MySQL的Web服务器
- 什么是伪静态,以及ubuntu + apache 如何实现伪静态
- Apache Maven 入门
- 修改Apache Benchmark源码实现请求数据随机的压力测试
- 【手把手教你全文检索】Apache Lucene初探
- 使用Python + Apache POI提取Excel中的图片
- Web-Service之LAMP安装部署,MySql+Apache+PHP
- apache2.4 windows764 python cgi
- Ubuntu下lamp(PHP+Mysql+Apache)搭建+完全卸载卸载方法
- Ubuntu 麒麟版下安装:Apache+php5+mysql+phpmyadmin.
- sql异常:nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object
- hive执行查询出现:org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row
- Mac OS X中配置Apache
- yum简单安装apache
- yum简单安装apache
- 如何使用Apache的ab工具进行网站性能测试
- apache各种常用的配置
- 几个开源协议的简介
- Apache服务安装相关问题
- Apache学习