IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Mac PHP 环境下新增虚拟主机

    forecho (caizhenghai@gmail.com)发表于 2015-01-16 22:30:17
    love 0

    注:这里只是新增,如果是第一次开启虚拟主机,请参考这篇文章。

    1、运行sudo vim /etc/apache2/extra/httpd-vhosts.conf,就打开了配置虚拟主机文件httpd-vhost.conf,配置虚拟主机了。增加虚拟主机代码如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    
    
        DocumentRoot "/Users/[用户名]/Sites/site"
        ServerName www.site.com
        ErrorLog "/private/var/log/apache2/sites-error_log"
        CustomLog "/private/var/log/apache2/sites-access_log" common
        
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride All
                    Order deny,allow
                    Allow from all
        
    

    2、保存退出,并重启Apache。

    1
    
    sudo apachectl restart
    

    3、运行sudo vim /etc/hosts,打开hosts配置文件,加入「127.0.0.1 www.site.com」, 这样就可以配置完成sites虚拟主机了,访问「http://www.site.com」就相当于访问/Users/[用户名]/Sites/site文件下面的项目了。

    补充:Mac默认PHP配置文件在 /private/etc/php.ini



沪ICP备19023445号-2号
友情链接