Hot answers tagged

13

Well, how much traffic do the actual Superuser and Serverfault sites have? Hypotheticals aren't much use if they don't have enough info to make the answer easier... Your worst-case process count should be the peak number of requests per second you want the site to be able to handle, divided by the number of requests per second that one process can handle ...


12

No it isn't possible. The mod_wsgi binary has to be compiled against one Python version only and only one instance of a compiled mod_wsgi module can be loaded into Apache at a time. What you would need to do is setup Apache to proxy to a separate WSGI server listening on its own ports. To use Apache/mod_wsgi as that backend server as well, you would want ...


8

yum install mod_wsgi confirmed on CentOS 5.7


8

The line: LoadModule mod_wsgi modules/mod_wsgi.so is wrong. It should have been: LoadModule wsgi_module modules/mod_wsgi.so Upgrading itself should not have made any difference.


7

The important bit is to rebuild Python with --enable-shared. The symlink comments are not relevant if you haven't done that and should't even apply with recent Python/mod_WSGI versions.


6

Read the documentation for mod_wsgi and it tells you what to do. See: http://code.google.com/p/modwsgi/wiki/InstallationIssues#Multiple_Python_Versions Specifically, use the WSGIPythonHome directive to tell mod_wsgi that your Python is actually in a different location. If this doesn't work, then make sure you are no longer loading mod_python into same ...


6

Use WSGIRestrictStdout option: WSGIRestrictStdout Off or replace sys.stdout with sys.stderr in Django WSGI star script: import sys sys.stdout = sys.stderr Writing To Standard Output No WSGI application component which claims to be portable should write to standard output. That is, an application should not use the Python print statement without ...


6

The default MPM is prefork, which creates (as you've seen) a pre-forked Apache process that is waiting for a connection to serve a request. It does not fire off different processes for different VirtualHost declarations, so any given process could serve any of your sites. As processes are restarted after a configurable number of requests have been served ...


6

A few comments about your configuration. MaxSpareThreads and MinSpareThreads should really be a multiple of ThreadsPerChild. If it isn't, with some combinations of values you can get Apache cycling between creating new processes because it thinks it needs them and then deciding the next moment to kill them again because it then changes its mind and sees ...


6

Some third party packages for Python which use C extension modules, and this includes scipy and numpy, will only work in the Python main interpreter and cannot be used in sub interpreters as mod_wsgi by default uses. The result can be thread deadlock, incorrect behaviour or processes crashes. These is detailed in: ...


5

See if the module is actually loaded properly with: apache2ctl -t -D DUMP_MODULES


5

I have found that this is a known bug with mod_wsgi apt-get package that is over a year old! Details at http://www.mail-archive.com/ubuntu-bugs@lists.ubuntu.com/msg1147225.html. The apt-get package did not have the wsgi.load file so that needed to be created by doing the steps in the link above. Thanks to everyone that helped!


5

Updates, updates, updates. Are you running Debian stable or testing? Sometimes keeping testing up to date is a bit more complicated than stable. Are you running everything as Debian packages? Make sure you are not running extraneous services. Run netstat -nap and check all processes that are listening on ports, make sure there's nothing there which is ...


5

Run: sudo apachectl -t and you will clearly see that you made an error in your configuration. Use: LoadModule wsgi_module /usr/local/Cellar/mod_wsgi/3.2/libexec/mod_wsgi.so as instructions should tell you. Ie., use 'wsgi_module' and not 'mod_wsgi_module'. See: http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide#Loading_Module_Into_Apache If ...


5

Your mod_wsgi was compiled for Python 2.7. You cannot then try and point it at a Python 2.5 virtual environment. Also, the setting: WSGIPythonHome /home/rory/tix/virtualenv2.5/lib/python2.5/ is pointing at the wrong thing even if it was a Python 2.7 virtual environment. The settings: UnSetEnv PYTHONSTARTUP SetEnv PYTHONPATH ...


5

The error your saw can also occur as a transient issue if you have done an Apache graceful restart and an Apache worker process had socket connections still alive that hadn't yet called through to mod_wsgi daemon process for initial request or subsequent request due to keep alive on socket. This will occur because on graceful restart the mod_wsgi daemon ...


5

A given Apache worker isn't associated with any particular virtual host. If you want more detailed information on what Apache is doing (including resource usage), you should turn on Apache's status pages and look at the extended status information: http://articles.slicehost.com/2010/3/26/enabling-and-using-apache-s-mod_status-on-ubuntu For example, this ...


5

You should definitely go with virtualenv. This is how you can check if you already have virtualenv installed: $ virtualenv --version If you don't have virtualenv installed, you can install it like this: $ pip install virtualenv If that gives you an error, you probably don't have pip yet. You can install it using: $ easy_install pip Once virtualenv ...


5

Take a look in /proc/<PID>/fd which should list all of the open files that PID has open. On my CentOS system fd 7 is lrwx------. 1 root root 64 Aug 28 22:01 7 -> socket:[1872522] I can then use netstat -ane | grep 1872522 to get tcp 0 0 :::443 :::* LISTEN 0 1872522 You can use lsof | grep ...


4

As far as I can see, you haven't loaded the mod_wsgi module into your httpd.conf. I'd first try adding the wsgi files to the mods-enabled directory of Apache. sudo ln -s /etc/apache2/mods-available/wsgi.load /etc/apache2/mods-enabled sudo ln -s /etc/apache2/mods-available/wsgi.conf /etc/apache2/mods-enabled Then restart Apache and it should work.


4

The mod_status module in Apache will show you which virtualhost / request a particular process is handling, but this will only be useful to you if the requests are long-lived. Adding execution time (%D) to your Apache LogFormat is also useful. More important is tracking down the bottleneck. For this you need to investigate iostat and vmstat (usually ...


4

If this is a uni project, I would really consult with them, not just to determine what you can run, but also what they will accept as a project deliverable. Otherwise you could waste a lot of time working on a project that nobody is prepared to mark.


4

The #! line is not used and would not normally be placed into a WSGI script file as used by mod_wsgi. To determine which version/installation of Python is used, there are two parts to it. The first as pointed out by someone else is to work out which Python library mod_wsgi.so is linked to. On most UNIX systems this is done using the 'ldd' command. ldd ...


4

Look for /usr/lib/apache2/modules/mod_wsgi.so*, at least on ubuntu I have: /usr/lib/apache2/modules/mod_wsgi.so -> mod_wsgi.so-2.6 /usr/lib/apache2/modules/mod_wsgi.so-2.5 /usr/lib/apache2/modules/mod_wsgi.so-2.6 If you change the symlink, you change the default mod_wsgi. An alternative is to look in /etc/apache2/mods-enabled/wsgi.load, for me ...


4

Add: ProxyPass /trac ! before ProxyPass for '/'. See: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass You are also missing a WSGIProcessGroup directive. That Trac instance isn't going to run in the daemon mode process you created. See: http://code.google.com/p/modwsgi/wiki/IntegrationWithTrac


4

This is how I did it on my django site, where the path is set in the apache file (as MY_PATH). Notice that I copy it into the os.environ variable. import os, sys, django.core.handlers.wsgi _application = django.core.handlers.wsgi.WSGIHandler() def application(environ, start_response): path = environ['MY_PATH'] if path not in sys.path: ...


4

Quoting the documentation at: http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess behaviour is: If the WSGIDaemonProcess directive is specified outside of all virtual host containers, any WSGI application can be delegated to be run within that daemon process group. If the WSGIDaemonProcess directive is specified within ...


4

You can comment out the line: WSGIDaemonProcess django processes=5 \ python-path=/home/pllee/webapps/django:/home/pllee/webapps/django/lib/python2.7 \ threads=1 for a start. This line is doing absolutely nothing except for causing five processes to be started which then sit there idle and do nothing. This is the mistake WebFaction has had for a ...


4

As pointed out in comment to question, most likely filesystem permissions with Apache user unable to read from where WSGI script file is or read the WSGI script file itself. This specific error is described in the presentation: http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations


4

Curious... as a quick test, try running chmod o+rx /var/run/postgresql -- if that fixes the problem (as I suspect it will) then you'll need to diagnose why the permissions are screwed up on the directory. On my system (Debian Squeeze) the perms are 2775 postgres:postgres; while it isn't necessary to have that particular mode, you'll want (at least) o+x to ...



Only top voted, non community-wiki answers of a minimum length are eligible