美文网首页
mac apache 配置虚拟域名

mac apache 配置虚拟域名

作者: 茶饭不思 | 来源:发表于2018-04-19 23:03 被阅读0次

     配置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

    相关文章

      网友评论

          本文标题:mac apache 配置虚拟域名

          本文链接:https://www.haomeiwen.com/subject/iujehftx.html