# Issue with Netcgi-apache

**URL:** <https://discuss.ocaml.org/t/issue-with-netcgi-apache/14106>\
**Category:** Ecosystem\
**Tags:** ocamlnet\
**Created:** [February 17, 2024, 8:52pm UTC](https://discuss.ocaml.org/t/issue-with-netcgi-apache/14106 "2024-02-17T20:52:11Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frederic\_Loyer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/frederic_loyer/32/3472_2.png) [@Frederic\_Loyer](https://discuss.ocaml.org/u/Frederic_Loyer)\
**Post date:** [February 17, 2024, 8:52pm UTC](https://discuss.ocaml.org/t/issue-with-netcgi-apache/14106/1 "2024-02-17T20:52:11Z")

</div>

I have installed on a Debian system the package `libocamlnet-ocaml-dev`.

I brings `/usr/lib/ocaml/netcgi2-apache/netcgi2-apache.cma` and several other caml archives. However, the name in the META file is `netcgi_apache`. Then when I set the Ocaml/Apache module to load `netcgi2-apache` there is an error because `netcgi_apache.cma` is not found. I have managed to fix this issue with a symlink and make the library available with the two names.

Now, I am trying to use the `Netcgi_apache` module.

I have:

```shell
loyer@ks3001154:~/public_html/ocaml$ ocamlc /usr/lib/ocaml/netcgi2-apache/netcgi_apache.cma essai.ml
File "essai.ml", line 1, characters 19-36:
1 | let process (cgi : Netcgi_apache.cgi) =
                       ^^^^^^^^^^^^^^^^^
Error: Unbound module Netcgi_apache
loyer@ks3001154:~/public_html/ocaml$ ocamlc /usr/lib/ocaml/netcgi2-apache/netcgi2-apache.cma essai.ml
File "essai.ml", line 1, characters 19-36:
1 | let process (cgi : Netcgi_apache.cgi) =
                       ^^^^^^^^^^^^^^^^^
Error: Unbound module Netcgi_apache

```

Shouldn’t the `netcgi2-apache.cma` bring the require module ?

I note that I have ` /usr/lib/ocaml/netcgi2-apache/netcgi_apache_mod.mli` and its `.cmi`, but not its implementation (`.cma`)

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [February 17, 2024, 9:06pm UTC](https://discuss.ocaml.org/t/issue-with-netcgi-apache/14106/2 "2024-02-17T21:06:08Z")

</div>

The compiler needs to see the `.cmi` file of the module `Netcgi_apache`. Something like:

```auto
ocamlc -I /usr/lib/ocaml/netcgi2-apache/ /usr/lib/ocaml/netcgi2-apache/netcgi_apache.cma essai.ml

```

should work.

---

<div class="post-metadata">

**Author:** ![UnixJunkie](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/unixjunkie/32/638_2.png) [@UnixJunkie](https://discuss.ocaml.org/u/UnixJunkie)\
**Post date:** [February 20, 2024, 12:20am UTC](https://discuss.ocaml.org/t/issue-with-netcgi-apache/14106/3 "2024-02-20T00:20:44Z")

</div>

You don’t use dune to compile your project?

---

<div class="post-metadata">

**Author:** ![Frederic\_Loyer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/frederic_loyer/32/3472_2.png) [@Frederic\_Loyer](https://discuss.ocaml.org/u/Frederic_Loyer)\
**Post date:** [February 20, 2024, 12:33am UTC](https://discuss.ocaml.org/t/issue-with-netcgi-apache/14106/4 "2024-02-20T00:33:05Z")

</div>

I have tried manually because dune seems to use the opam directory path… and hasn’t worked either.

Note, the proposed -I /path\_to\_netcgi2-apache doesn’t work.

I guess, I will try to recompile the module in the Debian way and see how it has been done.

---

<div class="post-metadata">

**Author:** ![UnixJunkie](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/unixjunkie/32/638_2.png) [@UnixJunkie](https://discuss.ocaml.org/u/UnixJunkie)\
**Post date:** [February 20, 2024, 2:49am UTC](https://discuss.ocaml.org/t/issue-with-netcgi-apache/14106/5 "2024-02-20T02:49:57Z")

</div>

Maybe, ask Gerd Stolpman (the maintainer of ocamlnet) or in the ocamlnet-devel mailaing list or  
open an issue in there:

> **[Issues · Gerd Stolpmann / lib-ocamlnet3 · GitLab](https://gitlab.com/gerdstolpmann/lib-ocamlnet3/-/issues)**
>
> This is the new home of Ocamlnet, replacing the svn repo

[https://sourceforge.net/p/ocamlnet/mailman/ocamlnet-devel/](https://sourceforge.net/p/ocamlnet/mailman/ocamlnet-devel/)

---

<div class="post-metadata">

**Author:** ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)\
**Post date:** [February 20, 2024, 3:59am UTC](https://discuss.ocaml.org/t/issue-with-netcgi-apache/14106/6 "2024-02-20T03:59:21Z")

</div>

If you are not strongly tied to Netcgi-apache, I would actually strongly recommend the Dream web framework: [Dream — Tidy, feature-complete web framework](https://aantron.github.io/dream/)

It’s very easy to get started:

```auto
let () =
  Dream.run
  @@ Dream.logger
  @@ Dream.router [
    Dream.get "/" (fun _ ->
      Dream.html "hello world");
  ]

```

And of course, you get a standalone executable which is a nice bonus.

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [February 20, 2024, 7:36am UTC](https://discuss.ocaml.org/t/issue-with-netcgi-apache/14106/7 "2024-02-20T07:36:17Z")

</div>

> [@Frederic\_Loyer](#):
>
> Note, the proposed -I /path\_to\_netcgi2-apache doesn’t work.

What is the error you get ? The same error ? According to what I see [there](https://packages.debian.org/en/bookworm/amd64/libocamlnet-ocaml-dev/filelist) the `.cmi` should be there.

Oherwise something like `ocamlfind ocamlc -linkpkg -package netcgi2_apache test.ml` will likely be easier.

---

<div class="post-metadata">

**Author:** ![Frederic\_Loyer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/frederic_loyer/32/3472_2.png) [@Frederic\_Loyer](https://discuss.ocaml.org/u/Frederic_Loyer)\
**Post date:** [February 20, 2024, 9:48am UTC](https://discuss.ocaml.org/t/issue-with-netcgi-apache/14106/8 "2024-02-20T09:48:02Z")

</div>

```auto
$ ocamlfind ocamlc -linkpkg -package netcgi2_apache main.ml
ocamlfind: Package `netcgi2_apache' not found
$ $ ocamlc -I /usr/lib/ocaml/netcgi2-apache netcgi2_apache.cma main.ml
File "main.ml", line 1, characters 18-28:
1 | let process (cgi: Netcgi.cgi) =
                      ^^^^^^^^^^
Error: Unbound module Netcgi

```

I have though about the dream server, but can’t start it:

```t
$ cat /etc/systemd/system/dream.service
[Unit]
Description=Dream server
After=network.target

[Service]
Type=simple
Restart=on-failure
User=loyer # ensure minimal access to system
Group=nobody
ExecStart=/home/loyer/dream_server/_build/default/bin/server.exe
StandardOutput=file:/var/log/dream.log
StandardError=file:/var/log/dream.log
PrivateTmp=yes # hide contents of /tmp from other processes on system

[Install]
WantedBy=multi-user.target
$ sudo systemctl start dream
$ sudo systemctl status dream
● dream.service - Dream server
     Loaded: loaded (/etc/systemd/system/dream.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-02-20 10:46:23 CET; 15s ago
    Process: 1810506 ExecStart=/home/loyer/dream_server/_build/default/bin/server.exe (code=exited, status=217/USER)
   Main PID: 1810506 (code=exited, status=217/USER)
        CPU: 13ms

févr. 20 10:46:23 my_host.com systemd[1]: dream.service: Scheduled restart job, restart counter is at 5.
févr. 20 10:46:23 my_host.com systemd[1]: Stopped Dream server.
févr. 20 10:46:23 my_host.com systemd[1]: dream.service: Start request repeated too quickly.
févr. 20 10:46:23 my_host.com systemd[1]: dream.service: Failed with result 'exit-code'.
févr. 20 10:46:23 my_host.com systemd[1]: Failed to start Dream server.

```

(and there are no `/var/log/dream.log` file. I have tried to change le log file (where the user has write rights… but it doesn’t change anything)

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [February 20, 2024, 10:08am UTC](https://discuss.ocaml.org/t/issue-with-netcgi-apache/14106/9 "2024-02-20T10:08:21Z")

</div>

> [@Frederic\_Loyer](#):
>
> ```auto
> $ ocamlfind ocamlc -linkpkg -package netcgi2_apache main.ml
> ocamlfind: Package `netcgi2_apache' not found
> 
> ```

Maybe it’s called differently try `ocamlfind list` to see the list of packages, also maybe that’s looking up in your opam, `ocamlfind printconf` / `command -v ocamlfind` will tell you that. You may want to try with `/usr/bin/ocamlfind`.

> [@Frederic\_Loyer](#):
>
> ```auto
> $ $ ocamlc -I /usr/lib/ocaml/netcgi2-apache netcgi2_apache.cma main.ml
> File "main.ml", line 1, characters 18-28:
> 1 | let process (cgi: Netcgi.cgi) =
> ^^^^^^^^^^
> Error: Unbound module Netcgi
> 
> ```

I guess by now you should see the pattern here. You need to [locate](https://packages.debian.org/en/bookworm/amd64/libocamlnet-ocaml-dev/filelist) the `netcgi.cmi` file and add its directory to the includes, you will likely also need to add the cma that holds this module on the cli.

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [February 20, 2024, 10:17am UTC](https://discuss.ocaml.org/t/issue-with-netcgi-apache/14106/10 "2024-02-20T10:17:45Z")

</div>

> [@Frederic\_Loyer](#):
>
> ```auto
> User=loyer # ensure minimal access to system
> Group=nobody
> 
> ```

Didn’t look far but this 217/user error seems to be about inexistent user. I suspect it’s because `loyer` doesn’t belong to the `nobody` group.

---

<div class="post-metadata">

**Author:** ![Frederic\_Loyer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/frederic_loyer/32/3472_2.png) [@Frederic\_Loyer](https://discuss.ocaml.org/u/Frederic_Loyer)\
**Post date:** [February 20, 2024, 11:10am UTC](https://discuss.ocaml.org/t/issue-with-netcgi-apache/14106/11 "2024-02-20T11:10:25Z")

</div>

> [@dbuenzli](#):
>
> Didn’t look far but this 217/user error seems to be about inexistent user. I suspect it’s because `loyer` doesn’t belong to the `nobody` group.

I have get it work.

Simply,

```auto
User=loyer # ensure minimal access to system

```

Try to find a `loyer # ensure minimal access to system` user which doesn’t exist. I had just to suppress the comment.
