First time here? Check out the FAQ!
1

Apache 2.4 config for askbot 0.11.x

Hi, I try to set up an askbot 0.11.x (more precise 0.11.8). I have askbot 0.11.8 and apache 2.4 installed in a docker container.

After running

askbot-setup -r /opt/b2-askbot --proj-name b2-askbot --admin-name "Matthias Schnepf" --admin-email "matthias.schnepf@kit.edu" --db-engine=sqlite  --db-name askbot-db --force  --noinput
python manage.py migrate
python manage.py collectstatic
python manage.py makemigrations
python manage.py migrate

I can run the website with python manage.py runserverhostname -i:8000

However, when I use my apache config, based on the example, I get first a Forbidden in my browser. That can be fixed by adding

 <Location />
   require all granted
 </Location>

in the Apache config and downloading the django.wsgi from the askbot GitHub.

However, now the website does not load, and in the Apache log I just see:

[Fri Jun 07 14:10:34.598309 2024] [wsgi:debug] [pid 463:tid 139732459718208] src/server/mod_wsgi.c(9142): mod_wsgi (pid=463): Started thread 0 in daemon process 'askbot2'.
[Fri Jun 07 14:10:34.598328 2024] [wsgi:debug] [pid 463:tid 139732449232448] src/server/mod_wsgi.c(9142): mod_wsgi (pid=463): Started thread 1 in daemon process 'askbot2'.
[Fri Jun 07 14:10:34.598362 2024] [wsgi:debug] [pid 463:tid 139732438746688] src/server/mod_wsgi.c(9142): mod_wsgi (pid=463): Started thread 2 in daemon process 'askbot2'.
[Fri Jun 07 14:10:34.598417 2024] [wsgi:debug] [pid 463:tid 139732428260928] src/server/mod_wsgi.c(9142): mod_wsgi (pid=463): Started thread 3 in daemon process 'askbot2'.
[Fri Jun 07 14:10:34.598454 2024] [wsgi:debug] [pid 463:tid 139732417775168] src/server/mod_wsgi.c(9142): mod_wsgi (pid=463): Started thread 4 in daemon process 'askbot2'.
[Fri Jun 07 14:10:34.598500 2024] [wsgi:debug] [pid 463:tid 139732407289408] src/server/mod_wsgi.c(9142): mod_wsgi (pid=463): Started thread 5 in daemon process 'askbot2'.
[Fri Jun 07 14:10:34.598526 2024] [wsgi:debug] [pid 463:tid 139732396803648] src/server/mod_wsgi.c(9142): mod_wsgi (pid=463): Started thread 6 in daemon process 'askbot2'.
[Fri Jun 07 14:10:34.598591 2024] [wsgi:debug] [pid 463:tid 139732386317888] src/server/mod_wsgi.c(9142): mod_wsgi (pid=463): Started thread 7 in daemon process 'askbot2'.
[Fri Jun 07 14:10:34.598611 2024] [wsgi:debug] [pid 463:tid 139732375832128] src/server/mod_wsgi.c(9142): mod_wsgi (pid=463): Started thread 8 in daemon process 'askbot2'.
[Fri Jun 07 14:10:34.598648 2024] [wsgi:debug] [pid 463:tid 139732365346368] src/server/mod_wsgi.c(9142): mod_wsgi (pid=463): Started thread 9 in daemon process 'askbot2'.
[Fri Jun 07 14:10:34.598696 2024] [wsgi:debug] [pid 463:tid 139732354860608] src/server/mod_wsgi.c(9142): mod_wsgi (pid=463): Started thread 10 in daemon process 'askbot2'.
[Fri Jun 07 14:10:34.598756 2024] [wsgi:debug] [pid 463:tid 139732344374848] src/server/mod_wsgi.c(9142): mod_wsgi (pid=463): Started thread 11 in daemon process 'askbot2'.
[Fri Jun 07 14:10:34.598784 2024] [wsgi:debug] [pid 463:tid 139732333889088] src/server/mod_wsgi.c(9142): mod_wsgi (pid=463): Started thread 12 in daemon process 'askbot2'.
[Fri Jun 07 14:10:34.598819 2024] [wsgi:debug] [pid 463:tid 139732323403328] src/server/mod_wsgi.c(9142): mod_wsgi (pid=463): Started thread 13 in daemon process 'askbot2'.
[Fri Jun 07 14:10:34.598862 2024] [wsgi:debug] [pid 463:tid 139732312917568] src/server/mod_wsgi.c(9142): mod_wsgi (pid=463): Started thread 14 in daemon process 'askbot2'.
[Fri Jun 07 14:10:45.308887 2024] [authz_core:debug] [pid 464:tid 139732396803648] mod_authz_core.c(815): [client 10.0.0.1:56110] AH01626: authorization result of Require all granted: granted
[Fri Jun 07 14:10:45.308916 2024] [authz_core:debug] [pid 464:tid 139732396803648] mod_authz_core.c(815): [client 10.0.0.1:56110] AH01626: authorization result of <RequireAny>: granted
[Fri Jun 07 14:10:45.308982 2024] [authz_core:debug] [pid 464:tid 139732396803648] mod_authz_core.c(815): [client 10.0.0.1:56110] AH01626: authorization result of Require all granted: granted
[Fri Jun 07 14:10:45.308988 2024] [authz_core:debug] [pid 464:tid 139732396803648] mod_authz_core.c(815): [client 10.0.0.1:56110] AH01626: authorization result of <RequireAny>: granted
[Fri Jun 07 14:10:45.316106 2024] [wsgi:info] [pid 463:tid 139732459718208] mod_wsgi (pid=463): Create interpreter 'askbot.belle2.org|'.
[Fri Jun ...
(more)
mschnepf's avatar
21
mschnepf
asked 2024-06-07 09:35:48 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

1

With nginx it works fine now. Here my config:

# the upstream component nginx needs to connect to
upstream django {
    server unix:///opt/test-askbot/askbot.sock; # for a file socket
    #server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}

# configuration of the server
server {
    # the port your site will be served on
    listen      80;
    # the domain name it will serve for
    server_name test-askbot; # substitute your machine's IP address or FQDN
    charset     utf-8;

    # max upload size
    client_max_body_size 75M;   # adjust to taste

    location /m {
        alias /opt/test-askbot/static;
    }
    location /static {
        alias /opt/test-askbot/static; # your Django project's static files - amend as required
    }
    location /upfiles {
        alias /opt/test-askbot/upfiles;
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
    uwsgi_param  QUERY_STRING       $query_string;
    uwsgi_param  REQUEST_METHOD     $request_method;
    uwsgi_param  CONTENT_TYPE       $content_type;
    uwsgi_param  CONTENT_LENGTH     $content_length;

    uwsgi_param  REQUEST_URI        $request_uri;
    uwsgi_param  PATH_INFO          $document_uri;
    uwsgi_param  DOCUMENT_ROOT      $document_root;
    uwsgi_param  SERVER_PROTOCOL    $server_protocol;
    uwsgi_param  REQUEST_SCHEME     $scheme;
    uwsgi_param  HTTPS              $https if_not_empty;

    uwsgi_param  REMOTE_ADDR        $remote_addr;
    uwsgi_param  REMOTE_PORT        $remote_port;
    uwsgi_param  SERVER_PORT        $server_port;
    uwsgi_param  SERVER_NAME        $server_name;
    }
}

It additionally needs a running uwsgi --socket askbot.sock --wsgi-file django.wsgi --module test-askbot --chmod-socket=666 But that is fine.

mschnepf's avatar
21
mschnepf
answered 2024-06-13 09:56:04 -0500, updated 2024-06-13 09:56:52 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

Hi Matthias,

mod_wsgi (pid=463): Daemon process deadlock timer expired, stopping process 'askbot2'`.

The above suggests that perhaps the first hit to the application takes too long for the default apache settings to execute.

When you visit the site the very first time after starting the app, it compiles the python to bytecode, initializes the django app, and that takes additional time.

So you might want to try to adjusting the timeout settings, some of these (the numbers below are arbitrary, try finding the values that work for you):

Timeout 600
WSGIDaemonProcess askbot2 deadlock-timeout=300 startup-timeout=300

Probably the deadlock-timeout is the most relevant setting.

I would also recommend to reduce the number of processes and threads to 1, that would help avoid running out of memory/cpu. Once the app is working, increase as is appropriate for your system.

EDIT: it is possible that there are permission issues for the Apache to access the log files and maybe a unix socket used by the python app.

Finally - unless you must use Apache, I'd suggest switching NGINX, that would improve the performance.

Evgeny's avatar
13.2k
Evgeny
answered 2024-06-07 12:25:37 -0500, updated 2024-06-10 09:26:22 -0500
edit flag offensive 0 remove flag delete link

Comments

Hi Evgeny, Thanks for the answer. I tested it with and without a single-threaded Apache2 config, but nothing changed. It does not seem like a performance problem since the CPU is not really utilized; Apache2 processes at about 5% max. I try to use nginx instead of apache2.

mschnepf's avatar mschnepf (2024-06-10 08:06:48 -0500) edit

Sure, I'll be able to assist better with NGINX. I do not use Apache day to day.

Evgeny's avatar Evgeny (2024-06-10 09:26:48 -0500) edit
add a comment see more comments