MAC安装hyperf
Hpertf ,是基于swoole开发,只能安装在类Linux 环境下,windows ⽤docker.
1.环境安装时,判断PHP环境要⼤于php7.2
  php -v
  PHP 7.4.11 (cli) (built: Oct 1 2020 18:41:10) ( NTS )
php -v
PHP 7.4.11 (cli) (built: Oct 1 2020 18:41:10) ( NTS )
2.判断是否安装swoole
php --ri swoole
Extension 'swoole' not present.
  安装swoole
  2.1 去GitHub 获取到最新的swoole release 地址
wget github/swoole/swoole-src/archive/refs/tags/v4.6.
tar -xzvf v4.6.  ###解压
cd swoole-src-4.6.6    ###进⼊swoole扩展包
phpize              ###编译
swoole扩展
./configure --enable-http2 --enable-openssl --with-openssl-dir=/usr/local/opt/openssl@1.1
###打开http2,openssl,指定openssl安装地址。如果不知道openssl安装地址使⽤ brew info openssl
make -j12     ####测试⼀下,看是否以后错误
make install    ####安装
  2.2 安装到完后,把swoole加载到PHP中
####php.ini⽬录在哪
qutao@MacBook-Pro# php -i | grep ini
Configuration File (php.ini) Path => /usr/local/etc/php/7.4
Loaded Configuration File => /usr/local/etc/php/7.4/php.ini
2.3进⼊到/usr/local/etc/php/7.4/php.ini
####添加以下两⾏
extension="swoole.so"
swoole.use_shortname = 'Off'
 2.4查看swoole 安装信息
####查看swoole 安装信息
php --ri swoole
  2.5进⼊到项⽬⽬录后,使⽤composer 创建项⽬,安装hyperf注意 ,⼀路按n 不要同意安装任何扩展
composer create-project hyperf/hyperf-skeleton
2.5 启动hyperf服务
#启动
php bin/hyperf.php start
>启动后会有以下提⽰
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.  [DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.  [INFO] Worker#6 started.
[INFO] Worker#7 started.
2.6 打开新窗⼝看是否启动成功,  端⼝是9501
curl 127.0.0.1:9501
{"method":"GET","message":"Hello Hyperf."}%

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。

发表评论