您的位置:首页 > 数据库 > Redis

在homestead php7的ubuntu环境中安装 php redis扩展的方法

2016-05-30 22:08 483 查看
转载:https://laracasts.com/discuss/channels/tips/tutorial-guide-installing-php-redis-on-fresh-install-homestead-with-php7

vagrant@homestead:~$ sudo apt-get update
vagrant@homestead:~$ git clone -b php7 https://github.com/phpredis/phpredis.git vagrant@homestead:~$ sudo mv phpredis/ /etc/
vagrant@homestead:~$ cd /etc/phpredis
vagrant@homestead:/etc/phpredis$  phpize
vagrant@homestead:/etc/phpredis$ ./configure
vagrant@homestead:/etc/phpredis$ make && make install

Note This is an Extension You Need to Enable to Make it Work  in Php 7
This First Command Will Allow You To Call PHPREDIS Facade in Browser

vagrant@homestead:/etc/phpredis$ sudo vim /etc/php/7.0/fpm/conf.d/redis.ini

Inside Vim Paste this
extension=/etc/phpredis/modules/redis.so

:w!     ->write/save
:q  ->exit vim

NOTE This Extension needs To be Enable in PHP ini to ENABLE it on your Command Line Interface Such As Artisan.
The Usual Problem You Will Face If You Wont do this is Get a Redis Class Not Found

vagrant@homestead:/etc/phpredis$ sudo vim /etc/php/7.0/cli/php.ini
then Look for this Word CLI Server
Type
/CLI Server

Add to the last line of extension

extension=/etc/phpredis/modules/redis.so
:w!     ->write/save
:q  ->exit vim

vagrant@homestead:/etc/phpredis$ sudo service php7.0-fpm restart

vagrant@homestead:/etc/phpredis$ sudo service nginx restart

To Test if PhpRedis Extension is Working
php -r "if (new Redis() == true){ echo \"\r\n OK \r\n\"; }"

It Should Return OK!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: