Mac系统下apache配置多域名

1.配置 /etc/apache2/httpd.conf

1.1开启相应的模块

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

1.2配置自己的网站根目录

DocumentRoot "/Users/你的用户名/Documents/Website"

    
    Options Indexes FollowSymLinks Multiviews
    MultiviewsMatch Any

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    Order deny,allow
    Allow from all
    #
    # Controls who can get stuff from this server.
    #
    Require all granted

 

2.配置 etc/apache2/extra/httpd-vhosts.conf 


    DocumentRoot "/Users/jimmy/Documents/Website/xxx"
    ServerName www.xxx.cn
    ErrorLog "/private/var/log/apache2/xxx-error_log"
    CustomLog "/private/var/log/apache2/xxx-access_log" common
    
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order deny,allow
        Allow from all
        Require all granted
    

 

3.重启apache服务

>>> sudo apachectl restart

 

4.配置hosts文件 ( /etc/hosts )

Mac系统下apache配置多域名_第1张图片

添加如下配置

127.0.0.1   www.xxx.cn

 

5.打开浏览器,输入 www.xxx.cn,即可看见啦!

你可能感兴趣的:(服务器)