1

I am running the script with my own user:

# from /etc/lighttpd/lighttpd.conf

server.document-root        = "/opt/app/current/bin/"
server.username             = "klenwell"

fastcgi.server  = (
    ".py" => (
        "localhost" => (
            "socket" => "/tmp/klenwell-fastcgi.socket",
            "bin-path" => "/opt/app/current/bin/app.py",
            "max-procs" => 5
        )
    )
)

In my python script, I have the shebang set like so:

#!/usr/bin/env python

But when I run the script, I get an error stating it can't load a module I installed with pip. This indicates that it is using system python rather than the pyenv version.

/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf start
(traceback omitted)
ImportError: No module named requests

If I change the shebang to use the pyenv python install explicitly, like so:

#!/home/klenwell/.pyenv/versions/2.7.8/bin/python

I am able start lighttpd successfully.

Currently, the same basic configuration is successfully running the web application using pythonbrew rather than pyenv. But since pythonbrew has been deprecated, I am trying to migrate to pyenv. Any ideas on how to configure lighttpd so that it successfully loads pyenv for my user?

1 Answer 1

1

A colleague figured this out. It required adding the pyenv paths to the PATH variable under bin-environment. For example:

fastcgi.server  = (
    ".py" => (
        "localhost" => (
            "socket" => "/tmp/klenwell-fastcgi.socket",
            "bin-path" => "/opt/app/current/bin/app.py",
            "bin-copy-environment" => (""),
            "bin-environment" => (
              "PATH" => "/home/klenwell/.pyenv/shims:/home/klenwell/.pyenv/bin:/bin:/sbin:/usr/bin:/usr/local/bin"
            ),
            "max-procs" => 5
        )
    )
)
Sign up to request clarification or add additional context in comments.

2 Comments

how did you do that?
how can i contact you ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.