1

I am trying to install a server for inginious (a program for automatic grading). One step in the installation is configuring Apache2 to use mod_wsgi. Here is the configuration file inginious.conf:

<VirtualHost *:8081>
       LoadModule wsgi_module /usr/local/lib/python3.6/dist-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-l$
       WSGIScriptAlias / "/usr/local/bin/inginious-webapp"
       WSGIScriptReloading On

       Alias /static /usr/local/lib/python3.6/dist-packages/inginious/frontend/static

        <Directory "/usr/local/bin">
            <Files "inginious-webapp">
                Require all granted
            </Files>
        </Directory>

        <DirectoryMatch "/usr/local/lib/python3.6/dist-packages/inginious/frontend/static">
            Require all granted
        </DirectoryMatch>

       ServerAdmin erelsgl@gmail.com
       DocumentRoot /var/www/inginious
</VirtualHost>

<VirtualHost *:8082>
        LoadModule wsgi_module /usr/local/lib/python3.6/dist-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-$
        WSGIScriptAlias / "/usr/local/bin/inginious-webdav"
        WSGIScriptReloading On

        <Directory "/usr/local/bin">
            <Files "inginious-webdav">
                Require all granted
            </Files>
        </Directory>
</VirtualHost>

I enabled it using a2ensite inginious and then systemctl reload apache2. There are no errors in /var/log/apache2/error.log. But netstat -tupln |grep 80 returns

tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      1500/python3
tcp6       0      0 :::80                   :::*                    LISTEN      852/apache2

which shows that no one is listening at ports 8081 and 8082. On the other hand, apache2 -M shows, among others,

wsgi_module (shared)

and apache2 -S shows, among others,

*:8081                 104.248.40.179 (/etc/apache2/sites-enabled/inginious.conf:1)
*:8082                 104.248.40.179 (/etc/apache2/sites-enabled/inginious.conf:22)

which shows that Apache2 does read the wsgi configuration.

Here is the error.log file just after reloading Apache2:

[Thu Feb 18 18:57:46.994117 2021] [socache_shmcb:info] [pid 12632] AH00830: Shared memory socache initialised
[Thu Feb 18 18:57:46.994139 2021] [ssl:info] [pid 12632] AH01887: Init: Initializing (virtual) servers for SSL
[Thu Feb 18 18:57:46.994146 2021] [ssl:info] [pid 12632] AH01876: mod_ssl/2.4.29 compiled against Server: Apache/2.4.29, Library: OpenSSL/1.1.1
[Thu Feb 18 18:57:46.994214 2021] [mpm_prefork:notice] [pid 12632] AH00163: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Thu Feb 18 18:57:46.994219 2021] [mpm_prefork:info] [pid 12632] AH00164: Server built: 2020-08-12T21:33:25
[Thu Feb 18 18:57:46.994222 2021] [core:notice] [pid 12632] AH00094: Command line: '/usr/sbin/apache2'
[Thu Feb 18 18:57:47.997715 2021] [wsgi:info] [pid 16827] mod_wsgi (pid=16827): Initializing Python.
[Thu Feb 18 18:57:48.000974 2021] [wsgi:info] [pid 16831] mod_wsgi (pid=16831): Initializing Python.
[Thu Feb 18 18:57:48.004725 2021] [wsgi:info] [pid 16830] mod_wsgi (pid=16830): Initializing Python.
[Thu Feb 18 18:57:48.006544 2021] [wsgi:info] [pid 16829] mod_wsgi (pid=16829): Initializing Python.
[Thu Feb 18 18:57:48.011627 2021] [wsgi:info] [pid 16828] mod_wsgi (pid=16828): Initializing Python.
[Thu Feb 18 18:57:48.063143 2021] [wsgi:info] [pid 16831] mod_wsgi (pid=16831): Attach interpreter ''.
[Thu Feb 18 18:57:48.067184 2021] [wsgi:info] [pid 16830] mod_wsgi (pid=16830): Attach interpreter ''.
[Thu Feb 18 18:57:48.072145 2021] [wsgi:info] [pid 16831] mod_wsgi (pid=16831): Imported 'mod_wsgi'.
[Thu Feb 18 18:57:48.072434 2021] [wsgi:info] [pid 16827] mod_wsgi (pid=16827): Attach interpreter ''.
[Thu Feb 18 18:57:48.073417 2021] [wsgi:info] [pid 16830] mod_wsgi (pid=16830): Imported 'mod_wsgi'.
[Thu Feb 18 18:57:48.080393 2021] [wsgi:info] [pid 16829] mod_wsgi (pid=16829): Attach interpreter ''.
[Thu Feb 18 18:57:48.083918 2021] [wsgi:info] [pid 16829] mod_wsgi (pid=16829): Imported 'mod_wsgi'.
[Thu Feb 18 18:57:48.084460 2021] [wsgi:info] [pid 16827] mod_wsgi (pid=16827): Imported 'mod_wsgi'.
[Thu Feb 18 18:57:48.088675 2021] [wsgi:info] [pid 16828] mod_wsgi (pid=16828): Attach interpreter ''.
[Thu Feb 18 18:57:48.091951 2021] [wsgi:info] [pid 16828] mod_wsgi (pid=16828): Imported 'mod_wsgi'.

What is wrong with my configuration?

  • Are you sure the error message has something to do with WSGI? To me, it looks more like `server-ip-address:8079` is not reachable. Try the usual: `ping server-ip-address`, `nc server-ip-address 8079`. Use `curl` instead of a browser. Check firewall on the server. Use `tcpdump` to see traffic. Try to access the server locally e.g. `curl localhost:8079`. Etc. – berndbausch Feb 18 '21 at 11:24
  • @berndbausch The firewall is disabled. I checked using netstat (see edit) and it seems no process is listening in port 8079. I see that python3 is listening in port 8080 - does it indicate that wsgi works? – Erel Segal-Halevi Feb 18 '21 at 12:06
  • If nothing listens at port 8079, the above configuration is not in effect. Did you reload or restart Apache? – berndbausch Feb 18 '21 at 14:12
  • Apache should also listen on 8080, then pass requests to the WSGI python process through a UNIX socket (or perhaps I misunderstand mod_wsgi) . Check what process 1500 is; I guess it's not related. – berndbausch Feb 18 '21 at 14:18
  • See also [mod_wsgi troubleshooting suggestions](https://modwsgi.readthedocs.io/en/master/troubleshooting.html). – berndbausch Feb 18 '21 at 14:19
  • @berndbausch you were right, it was something else. To avoid clash, I changed the port numbers to 8081 and 8082 and restarted Apache. Now none of them is listened to. – Erel Segal-Halevi Feb 18 '21 at 14:39
  • You mean Apache doesn't listen on ports 8081 and 8082? Anything in the Apache logs? – berndbausch Feb 18 '21 at 15:03
  • @berndbausch it contains only info files, see my edit – Erel Segal-Halevi Feb 18 '21 at 18:59
  • I am sorry, all I can do is point out that the web server should be listening on the configured ports. I can't explain why it doesn't, and I can also not tell you if anything is wrong with your configuration. To investigate this further, use the documentation I referred to. – berndbausch Feb 19 '21 at 00:20

0 Answers0