美文网首页环境的搭建与安装
MAMP的安装与Yaf的环境配置(附VirtualHost的创建

MAMP的安装与Yaf的环境配置(附VirtualHost的创建

作者: RuiL | 来源:发表于2015-11-11 19:41 被阅读790次

    MAMP的环境配置

    • 从MAMP官网(https://www.mamp.info/en/downloads/)下载MAMP安装包;
    • 安装MAMP之后,在打开MAMP(而不是MAMP PRO)的设置,选择Ports为Set Web & MySQL ports to 80 & 3306,PHP版本选择5.5.26;
    • 安装MAMP之后,从php官网(http://php.net/releases/)下载对应的php安装包,因Yaf的开发环境需在5.5.26下进行,故下载、解压;
    • 将解压出的源码放至目录 /Applications/MAMP/bin/php/php5.5.26/include/php下,
      (/include/php不存在,需自己创建)
    • 到此源码目录下运行./configure
    (如果出现Please specify the install prefix of iconv with --with-iconv=<DIR>错误)需要先下载Brew(去http://brew.sh/index_zh-cn.html安装)
    然后使用`./configure --with-iconv=/usr/local/Cellar/libiconv/1.14/`编译
    

    Yaf的安装

    • 下载Yaf源码(http://pecl.php.net/package/yaf
    • 运行安装/Applications/MAMP/bin/php/php5.5.26/bin/phpize(如果提示没有安装autoconf的话先试用brew install autoconf安装)
    • 编译./configure -—with-php-config=/Applications/MAMP/bin/php/php5.5.26/bin/php-config
    • make
    • make install
    • /Applications/MAMP/bin/php/php5.5.26/conf/php.ini文件的540行Extensions模块附近加入extension=yaf.so开启Yaf扩展

    memcache的安装

    • 运行安装/Applications/MAMP/bin/php/php5.5.26/bin/phpize
    • ./configure -—with-php-config=/Applications/MAMP/bin/php/php5.5.26/bin/php-config
      (如果遇到错误memcache support requires ZLIB,则使用brew install ZLIB安装ZLIB,然后再使用./configure --with-php-config=/Applications/MAMP/bin/php/php5.5.26/bin/php-config --with-zlib-dir=/usr/local/opt/zlib安装)
    • make
    • make install
    • /Applications/MAMP/bin/php/php5.5.26/conf/php.ini文件的540行Extensions模块附近加入extension=memcache.so开启memcache扩展
    • 重启MAMP,在phpinfo中查看这两个扩展是否安装成功。

    配置VirtualHost

    • /Applications/MAMP/conf/apache/httpd.conf打开虚拟网址配置
    # Virtual hosts
    Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf(去掉本句前的#)
    
    • /Applications/MAMP/conf/apache/extra/httpd-vhost.conf配置虚拟网址
    <VirtualHost *:80>
        ServerAdmin example@host.com    //主机地址
        DocumentRoot /Users/UserName/Documents/Project/admin  //工程目录
        ServerName  local.example.com   //虚拟的域名
        ErrorLog "logs/a.ifenxi.com-error.log"    //运行时的错误日志存放地址
        CustomLog "logs/a.ifenxi.com_cus.log" combined 
        <Directory "/Users/UserName/Documents/Project/admin">
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            allow from all
        </Directory>
    </VirtualHost>
    

    配置完成之后保存

    • 运行sudo vi /etc/hosts配置host文件,在IP列表中添加一行
    127.0.0.1           local.example.com(刚才配置的域名)
    

    wq保存退出

    • 重启MAMP,配置成功,将工程拷贝至刚才配置的文件目录,在浏览器中打开配置的域名,查看效果即可

    相关文章

      网友评论

      • 南方小金豆:配置vhost后,测试本地连接,总是The requested URL /index.php was not found on this server.。 你有遇到这样的问题吗?

      本文标题:MAMP的安装与Yaf的环境配置(附VirtualHost的创建

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