Я создал свой собственный модуль apache в C API с Python.
#include "httpd.h"
#include "http_config.h"
#include "http_protocol.h"
#include "ap_config.h"
#include "python2.7/Python.h"
static char* a(){
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
"print 'Today is',ctime(time())\n");
Py_Finalize();
return "aba\t";
}
/* The sample content handler */
static int mor_handler(request_rec *r)
{
if (strcmp(r->handler, "mor")) {
return DECLINED;
}
r->content_type = "text/html";
if (!r->header_only)
{ char *d;
d= a();
ap_rputs(d, r);
ap_rputs("The sample page from mod_mor.c\n", r);}
return OK;
}
static void mor_register_hooks(apr_pool_t *p)
{
ap_hook_handler(mor_handler, NULL, NULL, APR_HOOK_MIDDLE);
}
/* Dispatch list for API hooks */
module AP_MODULE_DECLARE_DATA mor_module = {
STANDARD20_MODULE_STUFF,
NULL, /* create per-dir config structures */
NULL, /* merge per-dir config structures */
NULL, /* create per-server config structures */
NULL, /* merge per-server config structures */
NULL, /* table of config file commands */
mor_register_hooks /* register hooks */
};
Но произошла следующая ошибка. Я не понимаю этого.
/etc/init.d/apache2 restart
apache2: Syntax error on line 203 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/mor.load: Cannot load /usr/lib/apache2/modules/mod_mor.so into server: /usr/lib/apache2/modules/mod_mor.so: `undefined symbol: Py_Initialize`
`Action 'configtest' failed`.
The Apache error log may have more information.
...fail!