4

After restarting a lighttpd server recently I haven't been able to get it up and running again. I am running a python built API service on it, and am relying on the web.py module to run the application.

I am having difficulty getting the MySQLdb Python module to import. That specific import causes everything to error out and produce a 500 error when I try and hit the API.

Initially, I thought that it was just a matter of permissions since I was able to import the module when running python from the command line. When I saw that running MySQLdb from the command line worked, I went on and changed the permissions of the Python code and the Python egg for the module to 755. This hasn't fixed the problem, however. I am not exactly certain what will be most helpful to post here, so I will include some configuration settings and other general facts about the server.

To clarify, I am able to get a Hello, World! message to print with my lighttpd setup, and have also confirmed that the lighttpd server is using the correct Python version (i.e 1.7.3).

Location of MySQLDb Python Module code:

/home/pythoninstall/MySQL-python-1.2.3c1

Location of Python 3rd Party Modules/eggs:

/opt/python2.7/lib/python2.7/site-packages

Lighttpd FastCGI Setup for Python:

server.modules = ("mod_fastcgi","mod_accesslog","mod_rewrite", "mod_access",       "mod_redirect", "mod_proxy")
server.document-root = "/home/OverLord/"
fastcgi.server = ( "/code.py" =>
    ((      "bin-environment" => (
                    "REAL_SCRIPT_NAME" => ""
            ),
            "socket" => "/tmp/fastcgi.socket",
            "bin-path" => "/opt/python2.7/bin/python /home/OverLord/code.py",
            "check-local" => "disable",
            "max-procs" => 1
    ))
)

Any ideas would be great. I have spent too much time losing my mind over this. Thanks!

breezy
  • 41
  • 2
  • Are you getting an entry in the error log to go with your HTTP 500? The fact that it works for you from the command line and not for your server user suggests a path/library issue. My guess: `ImportError: No module named MySQLdb` – khoxsey Aug 16 '12 at 22:13
  • All that I could really dig up in the lighttpd error log was this. Would you mind explaining 'path issue' a little more? Thanks for the help! `2012-08-16 18:18:19: (mod_fastcgi.c.2568) unexpected end-of-file (perhaps the fastcgi process died): pid: 25980 socket: unix:/tmp/fastcgi.socket-0 2012-08-16 18:18:19: (mod_fastcgi.c.3356) response not received, request sent: 1154 on socket: unix:/tmp/fastcgi.socket-0 for /code.py?, closing connection` –  Aug 16 '12 at 22:19

1 Answers1

0

FCGI is changing the name of your socket, somehow. You declare it as:

"socket" => "/tmp/fastcgi.socket"

But it is erroring on:

request sent: 1154 on socket: unix:/tmp/fastcgi.socket-0

Bashing google a bit suggests the php people have a lot of trouble with this. If FCGI keeps appending a -0 to your socket name and then barfing, it might be time to dig in to wsgi.

EDIT: adding a config from somebody who seems to have solved the issue. Use this for your socket definition:

"socket" => "/tmp/php.socket" + var.PID,
khoxsey
  • 715
  • 3
  • 8
  • Would this prevent modules from being imported? The lighttpd server was able to do a hello world page with the same socket. –  Aug 17 '12 at 06:16
  • Prevent loading? Unlikely, but I don't know. Confuse modules so they access the wrong socket? Possible. [One other link to consider](http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModFastCGI) discussed troubleshooting and suggests the **FCGI_WEB_SERVER_ADDRS** might be involved. – khoxsey Aug 17 '12 at 16:54