mac apache 配置虚拟域名

 配置HOSTS


 #vim /private/etc/hosts


  添加↓:


   127.0.0.1       tp.zhy.cn


 配置虚拟主机

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


 添加↓:


    ServerAdmin xxx@qq.com

    DocumentRoot "/Users/zhy/Sites/xxxx_5/public/"

    ServerName tp.zhy.cn

    ErrorLog "/private/var/log/apache2/xx.cn-error_log"

    CustomLog "/private/var/log/apache2/xx.cn-access_log" common




最后重启 apache ↓



重启Mac上的Apache服务

这个命令很早以前就查过了,但是每次使用的时候还是要在网上查:

停止服务:sudo /usr/sbin/apachectl stop

开启服务:sudo /usr/sbin/apachectl start

重启服务:sudo /usr/sbin/apachectl restart




步骤:

1.打开相关配置;

2.对vhost配置文件进行参数配置,复制即可

3.重启apache

1. sudo vim /etc/apache2/httpd.conf

开启php模块,去掉前边的分号

2。打开引入vhost文件.

sudo vi /etc/apache2/extra/httpd-vhosts.conf

输入下面代码:

    ServerName www.mall.com  [此处需修改成你的]

    DocumentRoot "/Library/WebServer/Documents/mall"[此处需修改成你的]

[此处需修改成你的]

        Options FollowSymLinks IncludesNOEXEC Indexes

        DirectoryIndex index.html index.htm index.php

        AllowOverride all

        Order Deny,Allow

        Allow from all

        Require all granted

    ServerName localhost

    DocumentRoot "/Library/WebServer/Documents"[此处需修改成你的]

[此处需修改成你的]

        Options FollowSymLinks IncludesNOEXEC Indexes

        DirectoryIndex index.html index.htm index.php

        AllowOverride all

        Order Deny,Allow

        Allow from all

        Require all granted

3.重启apache

sudo apachectl restart

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容