开发者

How to publish (in a server) a pydev app using eclipse?

开发者 https://www.devze.com 2023-02-11 12:19 出处:网络
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

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?


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...
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号