Configure apache module on ubuntu 16.04
I created a hello world module on ubuntu 16.04
#include <httpd.h>
#include <http_protocol.h>
#include <http_config.h>
static int helloworld_handler(request_rec* r)
{
if (!r->handler || strcmp(r->handler, "helloworld"))
return DECLINED;
if (r->method_number != M_GET)
return HTTP_METHOD_NOT_ALLOWED;
ap_set_content_type(r, "text/html");
ap_rprintf(r, "Hello, world!");
return OK;
}
static void register_hooks(apr_pool_t* pool)
{
ap_hook_handler(helloworld_handler, NULL, NULL, APR_HOOK_MIDDLE);
}
module AP_MODULE_DECLARE_DATA helloworld_module = {
STANDARD20_MODULE_STUFF,
NULL,
NULL,
NULL,
NULL,
NULL,
register_hooks
};
compile it with this command:
apxs -iac mod_helloworld.c
I see a module running it
apache2ctl -M
and
a2enmod
if i run
sudo a2enmod helloworld
I see that this module is already enabled
I also added this helloworld.conf to the available mods folder
<Location /helloworld>
SetHandler helloworld_handler
</Location>
and the helloworld.load file contains
LoadModule helloworld_module /usr/lib/apache2/modules/mod_helloworld.so
How do I configure it to view the output in a browser like
http: // localhost / helloworld
mod_helloworld.so is located under / usr / lib / apache2 / modules
if I root@ubuntu:/var/log/apache2# tail -f access.log
I get this
127.0.0.1 - - [03/Aug/2017:03:18:14 -0700] "GET /helloworld HTTP/1.1" 404 500 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0"
How to solve it?
+3
source to share