Homestead 安装 Redis

Homestead 安装 Redis

  1. 下载最新安装包

    vagrant@homestead:/usr/local/src$ sudo git clone https://github.com/phpredis/phpredis.git
    Cloning into 'phpredis'...
    remote: Enumerating objects: 41, done.
    remote: Counting objects: 100% (41/41), done.
    remote: Compressing objects: 100% (34/34), done.
    remote: Total 10462 (delta 19), reused 17 (delta 7), pack-reused 10421
    Receiving objects: 100% (10462/10462), 6.38 MiB | 31.00 KiB/s, done.
    Resolving deltas: 100% (7214/7214), done.
  2. 使用 phpize 命令完成 php 环境的检测

    vagrant@homestead:/usr/local/src$ cd phpredis/
    vagrant@homestead:/usr/local/src/phpredis$ sudo /usr/bin/phpize7.2 #不同php版本的情况下phpize版本不同
    Configuring for:
    PHP Api Version:         20170718
    Zend Module Api No:      20170718
    Zend Extension Api No:   320180731
    vagrant@homestead:/usr/local/src/phpredis$ sudo ./configure --with-php-config=/usr/bin/php-config7.2
  3. 编译安装

    vagrant@homestead:/usr/local/src/phpredis$ sudo make && make install
    Build complete.
    Don't forget to run 'make test'.
    Installing shared extensions:     /usr/lib/php/20170718/
    Makefile:87: recipe for target 'install-modules' failed
    make: *** [install-modules] Error 1
  4. 查看扩展

    vagrant@homestead:/usr/local/src/phpredis$ php -i|grep extension_dir
    extension_dir => /usr/lib/php/20170718 => /usr/lib/php/20170718
  5. redis.so 扩展模块移入 PHP 扩展目录中

    vagrant@homestead:/usr/local/src/phpredis$ sudo mv ./modules/redis.so /usr/lib/php/20170718/
  6. 添加 PHP 配置文件的 ini 文件

    创建文件
    vagrant@homestead:/usr/local/src/phpredis$ sudo touch /etc/php/7.2/fpm/conf.d/20-redis.ini
    使用vi编辑器写入如下内容:
    extension=redis.so
  7. 重启 php-fpm

    vagrant@homestead:/usr/local/src/phpredis$ sudo service php7.2-fpm restart
  8. 查看是否安装成功

    <?php
    phpinfo();
    ?>
    如果看到Redis的扩展则安装成功
  9. 终端无法连接 homesteadReids

    1)修改redis配置文件(默认路径/etc/redis/redis.conf)
    bind 127.0.0.1 修改为 bind 0.0.0.0
    2)修改完配置后重启redis
    执行命令sudo service redis restart后,使用redis-cli访问redis

⬆️

写的不错,赞助一下主机费

扫一扫,用支付宝赞赏
扫一扫,用微信赞赏

暂无评论~~