如何使用 eclipse 发布(在服务器中)pydev 应用程序?

发布于 2024-10-17 15:58:08 字数 219 浏览 7 评论 0原文

我是 Eclipse 和 Web 应用程序领域的新手。我使用 eclipse 编写了一个 django 应用程序,该应用程序在 django 集成的开发服务器中运行良好。现在,我想使用 Eclipse 导出我的应用程序以使用 apache2 服务器。我已经安装了服务器并在 eclipse 中对其进行了配置(定义服务器运行时环境首选项并创建服务器)。
现在,我必须遵循哪些步骤才能导出并使我的应用程序在服务器中运行?

I'm new with Eclipse and in the field of web applications. I used eclipse to wrote a django application that works well inside the development server integrated in django. Now, using Eclipse, I want to export my app to work with an apache2 server. I've installed the server and configured it inside eclipse (Defining the server runtime environments preferences and creating the server).
Now, what are the steps I have to follow to export and make my app work in the server?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

残龙傲雪 2024-10-24 15:58:08

您可能正在将 django 开发服务器(manage.py runningrever)与 eclipse 一起使用。 Eclipse 或任何其他 ide 与 Web 应用程序的部署关系不大。

Django 文档解释了如何在 appache 和 wsgi 上部署应用程序 相当好。

基本上,您需要在 wsgi 脚本中重现 Eclipse 配置。 Wsgi脚本是由apache mod_wsgi模块运行的python脚本。以下是 wsgi 脚本的示例:

import os
PROJECT_DIR = os.path.dirname(__file__)

# You probably provided some python-paths (places to look for python modules) 
# in your eclipse configuration. You'll need to add those path's to the wsgi 
# script too.

os.path.append(PROJECT_DIR)
os.path.append(PROJECT_DIR + '/lib')
os.path.append(PROJECT_DIR + '/src')

# You probably have this set in eclipse too:
os.environ['DJANGO_SETTINGS_MODULE'] = 'production_setting'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

最好使 PYTHON_PATH 相对于 wsgi 脚本文件。那么你的应用程序将更加可移植。

您可能希望在部署中禁用调试模式。可以使用单独的 settings.py 文件。典型的生产设置可能如下所示:

from settings import *

DEBUG = False
TEMPLATE_DEBUG = False

maybe your database settings...
maybe some secret keys...
maybe some API keys to various services...

You are probably using django development server (the manage.py runsrever) with eclipse. Eclipse or any other ide has little to do with deployment of your web application.

Django documentation explains how to deploy you application on appache and wsgi quite well.

Basically you will need to reproduce your eclipse configuration in wsgi script. Wsgi script is python script runned by apache mod_wsgi module. Here is example of wsgi script:

import os
PROJECT_DIR = os.path.dirname(__file__)

# You probably provided some python-paths (places to look for python modules) 
# in your eclipse configuration. You'll need to add those path's to the wsgi 
# script too.

os.path.append(PROJECT_DIR)
os.path.append(PROJECT_DIR + '/lib')
os.path.append(PROJECT_DIR + '/src')

# You probably have this set in eclipse too:
os.environ['DJANGO_SETTINGS_MODULE'] = 'production_setting'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

It good idea to make the PYTHON_PATH relative to wsgi script file. Then your application will be more portable.

Probably you will want to disable DEBUG mode in your deployment. It is possible with separate settings.py file. Typical production settings might look like this:

from settings import *

DEBUG = False
TEMPLATE_DEBUG = False

maybe your database settings...
maybe some secret keys...
maybe some API keys to various services...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文