第ä¸é¨åï¼å®è£
å¿
è¦å·¥å
·ã
1.å 为è¿æ¯é¨ç½²Pythonå¼åç¯å¢ï¼æ以å®è£
pipå¯ä»¥ç®åä¸äºè½¯ä»¶çå®è£
è¿ç¨ãï¼PIP对åºLuaçluarocksï¼
sudo apt-get install python-pip
å®è£
ä¸ä¸ªPythonæ¡æ¶
sudo pip install flask
sudo pip install django==1.5.1
sudo pip install tornado==3.1.1
2.å®è£
Gunicornï¼è¿æ¯è¿è¡PythonçWSGI HTTPæå¡ã
sudo pip install gunicorn
3.Virtualenv, å®è£
è¿ä¸ªæ¯å 为ï¼å¨é¨ç½²Djangoçæ¶åï¼ä½¿ç¨äºä¸åççæ¬ã
sudo pip install virtualenv
第äºé¨åï¼å建é¨ç½²åºç¨ã
1.å建ä¸ä¸ªWSGIç±»åçTornadoåºç¨ã
import tornado.web
import tornado.wsgi
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("My source code in the MoPaas server by python Tornado!")
settings = {
"debug" : True,
"static_path": "static",
}
#####
urls = [
(r"/", MainHandler),
]
app = tornado.wsgi.WSGIApplication(urls, **settings)
å¯å¨è¿ä¸ªæå¡ï¼
gunicorn -w 4 torapp:app -b 0.0.0.0:8888
2.å建ä¸ä¸ªFlaskåºç¨ã
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "My source code in the MoPaas server by python Tornado!"
if __name__ == "__main__":
app.run()
å¯å¨è¿ä¸ªæå¡ï¼
gunicorn -w 4 server:app -b 0.0.0.0:8888
3.å建Djangoåºç¨ã
Djangoæ¯ä¸ä¸ªæ¯è¾å¤§çWEBåºç¨ï¼å建åé¨ç½²çè¿ç¨ï¼ç¨å¾®å¤æä¸äºã
å建工ç¨
django-admin.py startproject hotdoc
å建åºç¨
python manage.py startapp verp
å建æ°æ®åºè¡¨
python manage.py syncdb
å¯å¨å·¥ç¨
gunicorn hotdoc.wsgi:application -b 0.0.0.0:8888
éè¦å¨ä¿®æ¹å·¥ç¨ç®å½ä¸çsettings.py
å¨INSTALLED_APPSä¸å å
¥ï¼ verupågunicornï¼
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'verup',
'gunicorn'
)
以ä¸ï¼æ¬å°å¼åç¯å¢æ¯æ²¡é®é¢çã
è¿äºæ¥éª¤ä¹å¯ä»¥ç¨virtualenvæ°å建ä¸ä¸ªèæç¯å¢å®æï¼æ¬å°å建virtualenvå¯ä»¥
ç®åå¨WEB IDEä¸æ²¡ææµè¯éè¿ï¼ç论ä¸è¯´ï¼å¦æcodingçWEB IDEæ¯åºäºDocker
çï¼virtualevnä¹åºè¯¥å¥½ç¨ã
mkdir ~/environments/
virtualenv ~/environments/tutorial/
cd ~/environments/tutorial/bin
source bin/activate
ç®åçPaaså¹³å°ä¸çPythonæå¡å°±æ¯WSGIå½¢å¼çåºç¨ï¼æ¯å¦SAEåMopaasï¼
ä¸åçæ¯ï¼å¨SAEä¸æäºç°æçä¾åãMopaaséè¦èªå·±ä»å¤´åï¼è¿ä¸ä¸ªä¾å
å¨Mopaasç产ç¯å¢ä¸é½è¿è¡æµè¯éè¿ãå¨coding.netçWEB IDEä¹å¯æåè¿
è¡ã
温馨提示:答案为网友推荐,仅供参考