gpt4 book ai didi

无法存储 key : SYSTEM ERROR when running c program under cgi-bin

转载 作者:行者123 更新时间:2023-11-30 17:52:47 24 4
gpt4 key购买 nike

当我在 CentOS 6.4 上从命令行运行以下程序时,我得到了预期的结果,但是当我作为 Apache cgi 运行它时,出现错误 无法存储 key :系统错误 错误。我通过同一用户运行 Memcached、Apache 和程序。

我可能做错了什么?

    #include<stdio.h>
#include<string.h>
#include <libmemcached/memcached.h>

int main(int argc, char **argv) {
memcached_server_st *servers = NULL;
memcached_st *memc;
memcached_return rc;
char *key= "keystring";
char *value= "keyvalue";
char *key1= "keystring1";
char *value1= "keyvalue1 ";

memc= memcached_create(NULL);
servers= memcached_server_list_append(servers, "localhost", 11211, &rc);
rc= memcached_server_push(memc, servers);

printf("Content-Type: text/plain;charset=us-ascii\n\n");

if (rc == MEMCACHED_SUCCESS)
printf("Added server successfully\n");
else
printf("Couldn't add server: %s\n",memcached_strerror(memc, rc));

rc= memcached_set(memc, key, strlen(key), value, strlen(value), (time_t)0, (uint32_t)0);

if (rc == MEMCACHED_SUCCESS)
printf("Key stored successfully\n");
else
printf("Couldn't store key: %s\n",memcached_strerror(memc, rc));

char *keys[]= {"keystring", "keystring1"};
size_t key_length[]= {9, 10};
unsigned int x;
uint32_t flags;

char return_key[MEMCACHED_MAX_KEY];
size_t return_key_length;
char *return_value;
size_t return_value_length;

rc= memcached_mget(memc, keys, key_length, 2);

x= 0;

if (rc == MEMCACHED_SUCCESS)
{
while ((return_value= memcached_fetch(memc, return_key, &return_key_length,
&return_value_length, &flags, &rc)))
{
if (rc == MEMCACHED_SUCCESS)
{
printf("Key %s returned %s\n",return_key, return_value);
}
}
}

return 0;
}

最佳答案

最终通过禁用 SELINUX 解决了该错误。

关于无法存储 key : SYSTEM ERROR when running c program under cgi-bin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15966333/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com