问题描述
如何将一个没有使用自制的或不同的风味蟒一个比随OS X 10.8.1部署OS X服务器2.0 Django应用程序?我使用可可绑定在一个Django应用程序,并有麻烦它与我的自制软件的台式机上运行(运行OS X 10.8.1);因此,要求对部署的Python安装系统版本的应用程序。
How would one deploy a Django application on OS X Server 2.0 without using homebrew or a different flavor of python than the one shipped with OS X 10.8.1? I'm using the cocoa bindings in a Django application and had trouble getting it to work with homebrew on my desktop machine (running OS X 10.8.1); hence the request to deploy the application on the system installed version of Python.
我有以下的OS X Server环境中,具有以下已安装:
I have the following OS X Server environment, with the following already installed:
- OS X 10.8.1
- OS X Server 2.0的
- 的Python 2.7.2
- 的Apache 2.2.22
1.4.1的Django使用以下命令安装:
Django 1.4.1 was installed using the following command:
sudo easy_install django
我的第一次尝试是部署一个空的网站,一旦成功,部署生产中使用实际的应用程序。该项目于创建/库/服务器/网络/数据/ webapps /下的mysite /
使用下面的命令
django-admin.py startproject mysite
我使用下面的命令运行应用程序。它只是证实了该应用程序启动和运行。这是标准的成功了!页当你第一次创建一个项目。
I ran the application using the following command. It simply confirmed that the application was up and running. It is the standard "It worked!" page when you first created a project.
python manage.py runserver 8080
然后我创建了一个文件 /Library/Server/Web/Config/apache2/httpd_mysite.conf
包含以下内容:
WSGIScriptAlias /mysite /Library/Server/Web/Data/WebApps/mysite/mysite/wsgi.py
我还创建了一个文件 /Library/Server/Web/Config/apache2/webapps/com.example.mysite.wsgi.plist
包含以下内容:
<?xml version="1.0" encoding="UTF-7"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>com.example.mysite.wsgi</string>
<key>displayName</key>
<string>Python "My Site" app</string>
<key>launchKeys</key>
<array/>
<key>proxies</key>
<dict/>
<key>installationIndicatorFilePath</key>
<string>/Library/Server/Web/Data/WebApps/mysite/mysite/wsgi.py</string>
<key>includeFiles</key>
<array>
<string>/Library/Server/Web/Config/apache2/httpd_mysite.conf</string>
</array>
<key>requiredModuleNames</key>
<array>
<string>wsgi_module</string>
</array>
</dict>
</plist>
文件 com.example.mysite.wsgi.plist
从 com.apple.webapp.wsgi.plist $ C $调整C>和
httpd_mysite.conf
改编自 httpd_wsgi.conf
。这两个文件被用来成功运行独立Python应用程序通过服务器管理器配置为当。
The file com.example.mysite.wsgi.plist
was adapted from com.apple.webapp.wsgi.plist
and httpd_mysite.conf
adapted from httpd_wsgi.conf
. Both these files are used to run the "standalone" python application successfully when configured through the server manager.
然后我创建了服务器管理网站,证实了我的应用程序是在Web应用程序列表。然而,当我访问我得到一个500错误。日志具有以下条目(IP地址改为1.2.3.4对于隐私的原因):
I then created a site with the server manager, confirmed my application was in the list of web applications. However, when I visit http://example.com/mysite I get a 500 error. The logs has the following entries (IP addresses changed to 1.2.3.4 for privacy reasons):
[Sat Sep 01 21:49:17 2012] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Sat Sep 01 21:49:17 2012] [notice] Apache/2.2.22 (Unix) PHP/5.3.13 with Suhosin-Patch mod_wsgi/3.3 Python/2.7.2 mod_fastcgi/2.4.6 mod_ssl/2.2.22 OpenSSL/0.9.8r DAV/2 configured -- resuming normal operations
[Sat Sep 01 21:50:13 2012] [error] [client 1.2.3.4] (8)Exec format error: exec of '/Library/Server/Web/Data/WebApps/mysite/mysite/wsgi.py' failed
[Sat Sep 01 21:50:13 2012] [error] [client 1.2.3.4] Premature end of script headers: wsgi.py
这似乎并不认为WSGI模块处理请求,而是,请求可以使用FCGI进行处理。然而,该日志表明的mod_wsgi / 3.3
加载。
当我创建了一个标准的Python应用程序,如下所示:
When I created a standard Python application that looks as follows:
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
和更新文件,以指向 /Library/Server/Web/Data/WebApps/helloworld.wsgi
,而不是 /库/服务器/网络/数据/ webapps /下的mysite / mysite的/ wsgi.py
然后Hello World的显示。因此,我认为WSGI正确配置,并能够执行应用程序和其他东西是错的我的设置。
And update the files to point to /Library/Server/Web/Data/WebApps/helloworld.wsgi
rather than /Library/Server/Web/Data/WebApps/mysite/mysite/wsgi.py
then "Hello World" is displayed. I therefore assume that wsgi is correctly configured and able to execute applications and that something else is wrong with my setup.
推荐答案
有些Apache的配置与发行版地图的.py要么CGI或FASTCGI,这将与mod_wsgi的冲突。这就是为什么mod_wsgi的建议使用.wsgi扩展。所以,重命名wsgi.py'到'site.wsgi',然后在WSGIScriptAlias使用'site.wsgi'
Some Apache configurations with distros map .py to either CGI or FASTCGI and this will conflict with mod_wsgi. This is why mod_wsgi recommends using a .wsgi extension. So, rename 'wsgi.py' to 'site.wsgi' and then use 'site.wsgi' in the WSGIScriptAlias.
顺便说一句,你可以确认有一个precompiled mod_wsgi.so随山狮服务器。
BTW, can you confirm that there is a precompiled mod_wsgi.so shipped with Mountain Lion server.
这篇关于一个人如何部署OS X Server上的Django应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!