mod-wsgi

Serving static files with mod_wsgi and Django

ぐ巨炮叔叔 提交于 2019-12-03 02:52:09
问题 I have a django application using mod_python, fairly typical configuration except that media files are being served by a (I know, not recommended) 'media' directory in the document root. I would like to test and maybe deploy with mod_wsgi but I cannot figure out how to create something simple to serve static files. mod_python allows the use of Apache directives like: <Location '/'> SetHandler MyApplication.xyz..... </Location> <Location '/media'> SetHandler None </Location> The django docs

Where should WSGIPythonPath point in my virtualenv?

守給你的承諾、 提交于 2019-12-03 02:49:51
I have a folder called python2.7 inside of lib in the virtual environment. After reading half a dozen tutorials, I can't figure out exactly what I'm suppose to point the WSGIPythonPath to. I've seen some pointing to site-packages but some have been a colon : separated list. Syntax error on line 1019 of /etc/httpd/conf/httpd.conf: WSGIPythonPath cannot occur within <VirtualHost> section Where should WSGIPythonPath point in my virtualenv? You are getting the error because WSGIPythonPath Directive cannot be used inside the VirtualHost context. You have to declare it inside your main Apache

mod_wsgi, mod_python, or just cgi?

时光毁灭记忆、已成空白 提交于 2019-12-03 02:36:31
问题 I've been playing around with my own webserver (Apache+Ubuntu) and python. From what I've seen there are 3(?) main ways of doing this: Apache configured to handle .py as cgi Apache configured to use mod_python that is now outdated(?) Apache configured to use mod_wsgi I recall reading that Django prefers mod_wsgi, and I'm kinda interested in learning Django (I've heard their official tutorial is rather excellent). What is the 'recommended' setup? I presume there's really no reason to use mod

How do I use Flask routes with Apache and mod_wsgi?

﹥>﹥吖頭↗ 提交于 2019-12-02 20:43:42
I've got my Apache server setup and it is handling Flask responses via mod_wsgi. I've registered the WSGI script via the alias: [httpd.conf] WSGIScriptAlias /service "/mnt/www/wsgi-scripts/service.wsgi" I've added the corresponding WSGI file at the above path: [/mnt/www/wsgi-scripts/service.wsgi] import sys sys.path.insert(0, "/mnt/www/wsgi-scripts") from service import application And I have a simple test Flask Python script that provides the service module: [/mnt/www/wsgi-scripts/service.py] from flask import Flask app = Flask(__name__) @app.route('/') def application(environ, start_response

SyntaxError with VirtualEnv + mod-wsgi in Django

岁酱吖の 提交于 2019-12-02 19:32:51
问题 I am having trouble using VirtualEnv on my production Ubuntu 13.04 server with mod-wsgi . Would someone be able to point out what the issue may be? Here is the traceback that I am getting the below syntax error: [Mon Jul 14 14:37:09 2014] [error] [client 70.180.246.22] mod_wsgi (pid=14292): Target WSGI script '/home/aaron/public_html/flapsta.com/flapsta/flapsta/flapsta.wsgi' cannot be loaded as Python module. [Mon Jul 14 14:37:09 2014] [error] [client 70.180.246.22] mod_wsgi (pid=14292):

How to set mod_wsgi for apache and django?

╄→尐↘猪︶ㄣ 提交于 2019-12-02 18:39:09
I know that there are already a lot of information on this topic, but they are quite clumsy, not so simple and expressive. Could anyone explain me how to use django and with mod_wsgi and apache ? mod_wsgi isn't particularly the best fit for running Python WSGI applications, or, if you'd rather, there are more pythonic ways you can run your Django instance. First off, I'd reason that it takes a lot of effort to understand Apache's request processing model and to configure it correctly, especially with respect to mod_wsgi. If your not exactly set or locked into using Apache, I would recommend

Why is mod_wsgi not able to write data? IOError: failed to write data

北城以北 提交于 2019-12-02 17:53:53
What could be causing this error: $ sudo tail -n 100 /var/log/apache2/error.log' [Wed Dec 29 15:20:03 2010] [error] [client 220.181.108.181] mod_wsgi (pid=20343): Exception occurred processing WSGI script '/home/username/public_html/idm.wsgi'. [Wed Dec 29 15:20:03 2010] [error] [client 220.181.108.181] IOError: failed to write data Here is the WSGI script: $ cat public_html/idm.wsgi import os import sys sys.path.append('/home/username/public_html/IDM_app/') os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()

Speeding Up the First Page Load in django

Deadly 提交于 2019-12-02 16:47:47
When I update the code on my website I (naturally) restart my apache instance so that the changes will take effect. Unfortunately the first page served by each apache instance is quite slow while it loads everything into RAM for the first time (5-7 sec for this particular site). Subsequent requests only take 0.5 - 1.5 seconds so I would like to eliminate this effect for my users. Is there a better way to get everything loaded into RAM than to do a wget x times (where x is the number of apache instances defined by ServerLimit in my http.conf) Writing a restart script that restarts apache and

WSGI ( is caching mysql result until script code is modified ) code included. ( want to stop this caching )

孤街醉人 提交于 2019-12-02 16:44:46
问题 This is the basic wsgi code. import MySQLdb conn = MySQLdb.connect (host = "localhost", user = "root", passwd = "", db = "a") cursor = conn.cursor () cursor.execute ("select * from `01` where id in (1,2) limit 2") rows = cursor.fetchall() cursor.close () conn.close () test = rows[0][1] test2 = rows[1][1] def application(environ, start_response): start_response('200 OK', [('content-type', 'text/html')]) yield test the problem here is the mysql result is being cached.. it is not mysql caching

Python, WSGI, multiprocessing and shared data

我们两清 提交于 2019-12-02 16:44:24
I am a bit confused about multiproessing feature of mod_wsgi and about a general design of WSGI applications that would be executed on WSGI servers with multiprocessing ability. Consider the following directive: WSGIDaemonProcess example processes=5 threads=1 If I understand correctly, mod_wsgi will spawn 5 Python (e.g. CPython) processes and any of these processes can receive a request from a user. The documentation says that: Where shared data needs to be visible to all application instances, regardless of which child process they execute in, and changes made to the data by one application