mac上运行zanphp的demo

mac上运行zanphp的demo

初入PHP的深坑,需要配置下zanphp的环境来运行下zanphp的demo。

安装php

需要安装些基本的软件,通过brew安装安装php,这里版本选了5.6

brew tap homebrew /homebrew-php
brew  install  php56 --with-fpm
 

安装扩展,工作中使用非必须

brew  install  --build-from- source  php56-mcrypt                                   
brew  install  php56-redis                                                  
brew  install  php56-xdebug             
brew  install  php56-apcu
有可能brew下载失败,有ss代理的话需要启动代理,并在terminal里配置
export ALL_PROXY=socks5://localhost:1086

安装 composer

brew install composer

安装zanphp

zanphp的git主页地址

https://github.com/youzan/zan
 

安装zanphp插件

git clone https://github.com/youzan/zan.git
cd zan-extension
phpize
./configure --enable-sockets --enable-async-redis  --enable-openssl
make 
make install
 

遇到的问题:

  • configure阶段,报错
configure: error: libcurl not installed 


解决办法:brew info curl查看curl是否安装以及路径,如

/usr/local/Cellar/curl/7.54.1 (392 files, 2.8MB)

,然后修改config.m4,将curl路径修改为当前路径

for i in /usr /usr/local /usr/local/Cellar/curl/7.54.1; do
 
  • make阶段,报错
./php_swoole.h:127:2: error: "Enable openssl support, require openssl library."

解决办法:

brew info openssl
 

获得openssl库的路径:

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include
 

然后修改config.m4,找到LDFLAGS,增加相应路径

LDFLAGS="$LDFLAGS -lpthread -L/usr/local/opt/openssl/lib"
 

安装composor

安装composer(curl -sS https://getcomposer.org/installer | php)
在根目录下执行

composer update
 

配置php.ini

配置php.ini

zanphp.RUN_MODE = test
zanphp.DEBUG = true

配置文件一般在/usr/local/etc/php/5.6/php.ini

启动demo

启动http server

php bin/httpd
 

访问127.0.0.1:8030,可以看到欢迎页

原文地址:https://www.cnblogs.com/opama/p/7103987.html