无法使用Ubuntu 14.04在PHP7上安装PHPREDIS

时间:2016-09-22 05:29:28

标签: ubuntu-14.04 php-7 phpredis

我在ubuntu 14.04上使用PHP7。这是来自终端的PHP版本信息(使用命令PHP -v)。

PHP 7.0.11-1+deb.sury.org~trusty+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.11-1+deb.sury.org~trusty+1, Copyright (c) 1999-2016, by Zend Technologies

我从php7分支机构下载了phpredis(https://github.com/phpredis/phpredis/tree/php7)&按照以下命令进行安装,如自述文件中所述。

phpize
./configure
make && make install

但是,我在执行命令make && make install

后立即收到错误
/bin/bash /home/justdial/Downloads/phpredis-php7/libtool --mode=compile cc  -I. -I/home/justdial/Downloads/phpredis-php7 -DPHP_ATOM_INC -I/home/justdial/Downloads/phpredis-php7/include -I/home/justdial/Downloads/phpredis-php7/main -I/home/justdial/Downloads/phpredis-php7 -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /home/justdial/Downloads/phpredis-php7/redis.c -o redis.lo 
libtool: compile:  cc -I. -I/home/justdial/Downloads/phpredis-php7 -DPHP_ATOM_INC -I/home/justdial/Downloads/phpredis-php7/include -I/home/justdial/Downloads/phpredis-php7/main -I/home/justdial/Downloads/phpredis-php7 -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /home/justdial/Downloads/phpredis-php7/redis.c  -fPIC -DPIC -o .libs/redis.o
In file included from /home/justdial/Downloads/phpredis-php7/redis.c:32:0:
/home/justdial/Downloads/phpredis-php7/redis_array.h:11:35: error: unknown type name 'zend_resource'
 void redis_destructor_redis_array(zend_resource *rsrc TSRMLS_DC);
                               ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'redis_get_exception_base':
/home/justdial/Downloads/phpredis-php7/redis.c:380:13: warning: assignment makes pointer from integer without a cast [enabled by default]
    if ((pce = zend_hash_str_find_ptr(CG(class_table), "runtimeexception", sizeof("RuntimeException") - 1))) {
         ^
/home/justdial/Downloads/phpredis-php7/redis.c:389:9: error: 'zend_ce_exception' undeclared (first use in this function)
  return zend_ce_exception;
     ^
/home/justdial/Downloads/phpredis-php7/redis.c:389:9: note: each undeclared identifier is reported only once for each function it appears in
/home/justdial/Downloads/phpredis-php7/redis.c: At top level:
/home/justdial/Downloads/phpredis-php7/redis.c:423:41: error: unknown type name 'zend_resource'
 static void redis_destructor_redis_sock(zend_resource * rsrc TSRMLS_DC)
                                     ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'redis_sock_get':
/home/justdial/Downloads/phpredis-php7/redis.c:439:46: warning: assignment makes pointer from integer without a cast [enabled by default]
     if (Z_TYPE_P(id) != IS_OBJECT || (socket = zend_hash_str_find(Z_OBJPROP_P(id), "socket",
                                          ^
/home/justdial/Downloads/phpredis-php7/redis.c:440:71: warning: comparison between pointer and integer [enabled by default]
                 sizeof("socket") - 1)) == NULL || Z_RES_P(socket) == NULL) {
                                                                   ^
/home/justdial/Downloads/phpredis-php7/redis.c:449:47: error: invalid type argument of '->' (have 'int')
     *redis_sock = (RedisSock *)Z_RES_P(socket)->ptr;
                                           ^
/home/justdial/Downloads/phpredis-php7/redis.c:451:40: error: invalid type argument of '->' (have 'int')
     if (!*redis_sock || Z_RES_P(socket)->type != le_redis_sock) {
                                    ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zm_startup_redis':
/home/justdial/Downloads/phpredis-php7/redis.c:575:37: warning: assignment from incompatible pointer type [enabled by default]
     redis_cluster_ce->create_object = create_cluster_context;
                                 ^
/home/justdial/Downloads/phpredis-php7/redis.c:578:9: error: 'redis_destructor_redis_array' undeclared (first use in this function)
     redis_destructor_redis_array,
     ^
/home/justdial/Downloads/phpredis-php7/redis.c:588:5: error: too few arguments to function 'zend_register_internal_class_ex'
     );
     ^
In file included from /usr/include/php5/main/php.h:39:0,
             from /home/justdial/Downloads/phpredis-php7/common.h:1,
             from /home/justdial/Downloads/phpredis-php7/redis.c:27:
/usr/include/php5/Zend/zend_API.h:277:28: note: declared here
 ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce, char *parent_name TSRMLS_DC);
                        ^
/home/justdial/Downloads/phpredis-php7/redis.c:596:5: error: too few arguments to function 'zend_register_internal_class_ex'
     );
     ^
In file included from /usr/include/php5/main/php.h:39:0,
             from /home/justdial/Downloads/phpredis-php7/common.h:1,
             from /home/justdial/Downloads/phpredis-php7/redis.c:27:
/usr/include/php5/Zend/zend_API.h:277:28: note: declared here
 ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce, char *parent_name TSRMLS_DC);
                        ^
/home/justdial/Downloads/phpredis-php7/redis.c:599:9: error: 'redis_destructor_redis_sock' undeclared (first use in this function)
     redis_destructor_redis_sock,
     ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'redis_connect':
/home/justdial/Downloads/phpredis-php7/redis.c:719:5: error: unknown type name 'zend_long'
     zend_long port = -1, retry_interval = 0;
     ^
/home/justdial/Downloads/phpredis-php7/redis.c:764:21: warning: assignment makes pointer from integer without a cast [enabled by default]
     if ((socket = zend_hash_str_find(Z_OBJPROP_P(object), "socket", sizeof("socket") -1)) == NULL)
                 ^
/home/justdial/Downloads/phpredis-php7/redis.c:781:8: warning: assignment makes pointer from integer without a cast [enabled by default]
     id = zend_list_insert(redis_sock, le_redis_sock TSRMLS_CC);
    ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zim_Redis_getMultiple':
/home/justdial/Downloads/phpredis-php7/redis.c:984:9: error: unknown type name 'zend_string'
     zend_string *key_zstr;
     ^
/home/justdial/Downloads/phpredis-php7/redis.c:987:18: warning: assignment makes pointer from integer without a cast [enabled by default]
     key_zstr = zval_get_string(z_ele);
              ^
/home/justdial/Downloads/phpredis-php7/redis.c:988:13: warning: assignment makes pointer from integer without a cast [enabled by default]
     key = ZSTR_VAL(key_zstr);
         ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'generic_sort_cmd':
/home/justdial/Downloads/phpredis-php7/redis.c:1398:5: error: unknown type name 'zend_long'
     zend_long sort_start = -1, sort_count = -1;
     ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zim_Redis_select':
/home/justdial/Downloads/phpredis-php7/redis.c:1757:5: error: unknown type name 'zend_long'
     zend_long dbNumber;
     ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'generic_mset':
/home/justdial/Downloads/phpredis-php7/redis.c:1832:13: error: unknown type name 'zend_string'
         zend_string *key_zstr;
         ^
/home/justdial/Downloads/phpredis-php7/redis.c:1841:71: error: macro "zend_hash_get_current_key" requires 4 arguments, but only 3 given
         type = zend_hash_get_current_key(keytable, &key_zstr, &idx);
                                                                   ^
/home/justdial/Downloads/phpredis-php7/redis.c:1841:20: error: 'zend_hash_get_current_key' undeclared (first use in this function)
         type = zend_hash_get_current_key(keytable, &key_zstr, &idx);
                ^
/home/justdial/Downloads/phpredis-php7/redis.c:1842:64: error: macro "zend_hash_get_current_data" requires 2 arguments, but only 1 given
         if((z_value_p = zend_hash_get_current_data(keytable)) == NULL)
                                                            ^
/home/justdial/Downloads/phpredis-php7/redis.c:1842:29: error: 'zend_hash_get_current_data' undeclared (first use in this function)
         if((z_value_p = zend_hash_get_current_data(keytable)) == NULL)
                         ^
/home/justdial/Downloads/phpredis-php7/redis.c:1856:35: error: request for member 'len' in something not a structure or union
             key_len = key_zstr->len;
                               ^
/home/justdial/Downloads/phpredis-php7/redis.c:1857:31: error: request for member 'val' in something not a structure or union
             key = key_zstr->val;
                           ^
/home/justdial/Downloads/phpredis-php7/redis.c:1873:17: warning: format '%d' expects argument of type 'int', but argument 3 has type 'size_t' [-Wformat=]
             p += sprintf(p, "$%d" _NL, key_len);    /* key len */
             ^
/home/justdial/Downloads/phpredis-php7/redis.c:1877:17: warning: format '%d' expects argument of type 'int', but argument 3 has type 'size_t' [-Wformat=]
             p += sprintf(p, "$%d" _NL, val_len);    /* val len */
             ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zim_Redis_multi':
/home/justdial/Downloads/phpredis-php7/redis.c:2196:5: error: unknown type name 'zend_long'
     zend_long multi_value = MULTI;
     ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'generic_unsubscribe_cmd':
/home/justdial/Downloads/phpredis-php7/redis.c:2567:13: error: too few arguments to function 'zend_hash_index_find'
         if ((z_channel = zend_hash_index_find(Z_ARRVAL(z_tab), 1)) == NULL)
         ^
In file included from /usr/include/php5/Zend/zend.h:286:0,
             from /usr/include/php5/main/php.h:35,
             from /home/justdial/Downloads/phpredis-php7/common.h:1,
             from /home/justdial/Downloads/phpredis-php7/redis.c:27:
/usr/include/php5/Zend/zend_hash.h:166:14: note: declared here
 ZEND_API int zend_hash_index_find(const HashTable *ht, ulong h, void **pData);
          ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zim_Redis_slaveof':
/home/justdial/Downloads/phpredis-php7/redis.c:2610:5: error: unknown type name 'zend_long'
     zend_long port = 6379;
     ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zim_Redis_slowlog':
/home/justdial/Downloads/phpredis-php7/redis.c:2764:5: error: unknown type name 'zend_long'
     zend_long option;
     ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zim_Redis_wait':
/home/justdial/Downloads/phpredis-php7/redis.c:2818:5: error: unknown type name 'zend_long'
     zend_long num_slaves, timeout;
     ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'redis_build_pubsub_cmd':
/home/justdial/Downloads/phpredis-php7/redis.c:2901:13: error: unknown type name 'zend_string'
         zend_string *key_zstr;
         ^
/home/justdial/Downloads/phpredis-php7/redis.c:2902:22: warning: assignment makes pointer from integer without a cast [enabled by default]
         key_zstr = zval_get_string(z_ele);
                  ^
/home/justdial/Downloads/phpredis-php7/redis.c:2903:17: warning: assignment makes pointer from integer without a cast [enabled by default]
         key = ZSTR_VAL(key_zstr);
             ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'redis_build_eval_cmd':
/home/justdial/Downloads/phpredis-php7/redis.c:3041:17: error: unknown type name 'zend_string'
             zend_string *key_zstr;
             ^
/home/justdial/Downloads/phpredis-php7/redis.c:3042:26: warning: assignment makes pointer from integer without a cast [enabled by default]
             key_zstr = zval_get_string(elem);
                      ^
/home/justdial/Downloads/phpredis-php7/redis.c:3043:21: warning: assignment makes pointer from integer without a cast [enabled by default]
             key = ZSTR_VAL(key_zstr);
                 ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zim_Redis_evalsha':
/home/justdial/Downloads/phpredis-php7/redis.c:3086:5: error: unknown type name 'zend_long'
     zend_long keys_count = 0;
     ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zim_Redis_eval':
/home/justdial/Downloads/phpredis-php7/redis.c:3124:5: error: unknown type name 'zend_long'
     zend_long keys_count = 0;
     ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'redis_build_script_exists_cmd':
/home/justdial/Downloads/phpredis-php7/redis.c:3167:9: error: unknown type name 'zend_string'
     zend_string *arg_zstr = zval_get_string(&argv[i]);
     ^
/home/justdial/Downloads/phpredis-php7/redis.c:3167:33: warning: initialization makes pointer from integer without a cast [enabled by default]
     zend_string *arg_zstr = zval_get_string(&argv[i]);
                             ^
/home/justdial/Downloads/phpredis-php7/redis.c:3171:13: warning: passing argument 3 of 'redis_cmd_append_str' makes pointer from integer without a cast [enabled by default]
         ZSTR_LEN(arg_zstr));
         ^
In file included from /home/justdial/Downloads/phpredis-php7/redis_commands.h:17:0,
             from /home/justdial/Downloads/phpredis-php7/redis.c:31:
/home/justdial/Downloads/phpredis-php7/library.h:15:5: note: expected 'char *' but argument is of type 'int'
 int redis_cmd_append_str(char **cmd, int cmd_len, char *append, int append_len);
     ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zim_Redis_script':
/home/justdial/Downloads/phpredis-php7/redis.c:3203:5: warning: passing argument 3 of '_zend_get_parameters_array' from incompatible pointer type [enabled by default]
     if(zend_get_parameters_array(ht, argc, z_args) == FAILURE ||
     ^
In file included from /usr/include/php5/main/php.h:39:0,
             from /home/justdial/Downloads/phpredis-php7/common.h:1,
             from /home/justdial/Downloads/phpredis-php7/redis.c:27:
/usr/include/php5/Zend/zend_API.h:237:14: note: expected 'struct zval **' but argument is of type 'struct zval *'
 ZEND_API int _zend_get_parameters_array(int ht, int param_count, zval **argument_array TSRMLS_DC);
          ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zim_Redis_migrate':
/home/justdial/Downloads/phpredis-php7/redis.c:3285:5: error: unknown type name 'zend_long'
     zend_long port, dest_db, timeout;
     ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zim_Redis_getLastError':
/home/justdial/Downloads/phpredis-php7/redis.c:3394:60: error: macro "RETURN_STRINGL" requires 3 arguments, but only 2 given
     RETURN_STRINGL(redis_sock->err, redis_sock->err_len);
                                                        ^
/home/justdial/Downloads/phpredis-php7/redis.c:3394:9: error: 'RETURN_STRINGL' undeclared (first use in this function)
     RETURN_STRINGL(redis_sock->err, redis_sock->err_len);
     ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zim_Redis_getHost':
/home/justdial/Downloads/phpredis-php7/redis.c:3475:39: error: macro "RETURN_STRING" requires 2 arguments, but only 1 given
     RETURN_STRING(redis_sock->host);
                                   ^
/home/justdial/Downloads/phpredis-php7/redis.c:3475:9: error: 'RETURN_STRING' undeclared (first use in this function)
     RETURN_STRING(redis_sock->host);
     ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zim_Redis_getPersistentID':
/home/justdial/Downloads/phpredis-php7/redis.c:3533:52: error: macro "RETURN_STRING" requires 2 arguments, but only 1 given
         RETURN_STRING(redis_sock->persistent_id);
                                                ^
/home/justdial/Downloads/phpredis-php7/redis.c:3533:13: error: 'RETURN_STRING' undeclared (first use in this function)
         RETURN_STRING(redis_sock->persistent_id);
         ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zim_Redis_getAuth':
/home/justdial/Downloads/phpredis-php7/redis.c:3548:43: error: macro "RETURN_STRING" requires 2 arguments, but only 1 given
         RETURN_STRING(redis_sock->auth);
                                       ^
/home/justdial/Downloads/phpredis-php7/redis.c:3548:13: error: 'RETURN_STRING' undeclared (first use in this function)
         RETURN_STRING(redis_sock->auth);
         ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'zim_Redis_rawcommand':
/home/justdial/Downloads/phpredis-php7/redis.c:3625:5: warning: passing argument 3 of '_zend_get_parameters_array' from incompatible pointer type [enabled by default]
     if (zend_get_parameters_array(ht, argc, z_args) == FAILURE) {
     ^
In file included from /usr/include/php5/main/php.h:39:0,
             from /home/justdial/Downloads/phpredis-php7/common.h:1,
             from /home/justdial/Downloads/phpredis-php7/redis.c:27:
/usr/include/php5/Zend/zend_API.h:237:14: note: expected 'struct zval **' but argument is of type 'struct zval *'
 ZEND_API int _zend_get_parameters_array(int ht, int param_count, zval **argument_array TSRMLS_DC);
          ^
/home/justdial/Downloads/phpredis-php7/redis.c: In function 'generic_scan_cmd':
/home/justdial/Downloads/phpredis-php7/redis.c:3725:5: error: unknown type name 'zend_long'
     zend_long count=0;
     ^
make: *** [redis.lo] Error 1

我还在PHPREDIS github存储库(https://github.com/phpredis/phpredis/issues/958)中创建了一个关于此的问题。

不知道这里出了什么问题。

2 个答案:

答案 0 :(得分:1)

请尝试这种方式。

1. 删除现有的PHP-Redis扩展程序并清除

2. 安装必需的软件包(如果已经安装了php7,请跳过)

apt-get install php7.0-dev

3. 下载PhpRedis

cd /tmp
wget https://github.com/phpredis/phpredis/archive/php7.zip -O phpredis.zip

4. 解压缩,编译和安装PhpRedis

unzip -o /tmp/phpredis.zip && mv /tmp/phpredis-* /tmp/phpredis && cd /tmp/phpredis && phpize && ./configure && make && sudo make install

现在有必要将已编译的扩展名添加到PHP配置

5. 将PhpRedis扩展添加到PHP 7

sudo touch /etc/php/mods-available/redis.ini && echo extension=redis.so > /etc/php/mods-available/redis.ini
sudo ln -s /etc/php/mods-available/redis.ini /etc/php/7.0/apache2/conf.d/redis.ini
sudo ln -s /etc/php/mods-available/redis.ini /etc/php/7.0/fpm/conf.d/redis.ini
sudo ln -s /etc/php/mods-available/redis.ini /etc/php/7.0/cli/conf.d/redis.ini

6. 重启PHP-FPM

sudo service php7.0-fpm restart

7. 重启Apache

sudo service apache2 restart

注意:如果您使用的是Nginx,则无需重新启动它,因为在大多数情况下它适用于PHP-FPM。 您可以使用以下命令检查已成功安装的PhpRedis

php -r "if (new Redis() == true){ echo \"OK \r\n\"; }"

答案 1 :(得分:0)

嗯......最后,我已经解决了这个问题。我想,我在php7.0-dev配置中遇到了一些问题。因此,使用apt-get install php7.0-dev重新安装它。之后使用以下命令 -

sudo make
sudo make install

然后在php.ini文件中添加了redis.so扩展程序链接的路径。前 -

extension=/usr/lib/php/20151012/redis.so (path is system dependent)

那就是它。它解决了问题。

@Renjith VR:谢谢你的回复。这真的帮助我解决了这个问题。