ãåå.com ã® VPS ã® CentOS5.3 ã«ãPython 2.6.4 㨠Django 1.1.1 ã¨ãmod_wsgi ãè¨å®ããè¦ãæ¸ã
æè¬
ãåå.com 㧠yum ã使ããããã«ãªãã¾ã§ã¯ お名前.comのVPSサーバを使うまで - UNIX的なアレ ãåèã«ãã¨ã¦ãç´ æ´ãããã¨ã³ããªã§ããããã¨ãupdatedb 㨠locate ã使ãç§ã¯ yum install mlocate ããã¾ããããããããCentOS 5.3にPHP5.2.9とMySQL5.1.33をインストール: サーバー初心者による自宅サーバー構築備忘録 ãã¡ãã®yum ã®ã¬ãã¸ããªè¨å®ã使ã㨠yum çµç±ã§ MySQL 㨠php ãæ°ãããã¼ã¸ã§ã³ã«ãåºæ¥ã¾ãã
次ã«ãPython 2.6 ã Django ã®ã¤ã³ã¹ãã¼ã«ã§ããCentOS5.3にPython2.6でDjango1.1の開発環境を作成する - やさしいデスマーチ ãã¡ããä¸çªåèã«ããã¦é ãã¾ãããæå¹ã®æ¹ã§ããããã§ããè£å®çã«æµ·å¤ã®ãã¡ãã®æ¹ http://villaroad.com/2009/08/rolling-python-2-6-2-on-centos-5-3/ ã®PATHè¨å®ãè¦ããããã¨ã¯ãMySQLdb ã mod_wsgi ã®è¨å®ä¾ã¯ã¡ãã£ã¨å¤ãããã±ã¼ã¸ã®æ
å ±ã§ãããåºæ¬åããªã®ã§ http://blog.perplexedlabs.com/2008/11/10/setup-python-25-mod_wsgi-and-django-10-on-centos-5-cpanel/ ããã¨ã Django ç¨ã® mod_wsgi ã®è¨å®ã¯ Google Code Archive - Long-term storage for Google Code Project Hosting. ã«ã¦ããã¾ããã
ç§ã¯ /opt ã使ãæ¹ã§ããã¾ããããPython2.6 ã³ãã³ããç©æ¥µçã«ä½¿ãæ¹å¼ããä¸è¨ã¨ã¯éãã¤ã³ã¹ãã¼ã«ã§ã¯ CentOS5.2にPython2.6+Django1.1+mod_wsgi3.1をインストール - orangain flavor ãåèã«ãªãã¾ãã
ç§ã¯ã/opt é ä¸ãåæ§ã«ã¤ãã£ã¦ 2.6 ãèªåã§ã¯ä½¿ããããã«ããªãããã·ã¹ãã å´ã¡ã¤ã³ã§ã¯2.4 ã使ãå½¢ã«ãã¦ãã¾ãã
ä¸è¨ã«å¾ãã° Django ã® ã¤ã³ã¹ãã¼ã«ã¨ãã³ãã³ããåãã¨ããã¾ã§ã¯è¡ãã¾ãããã ãvps ã® ãã¼ãã£ã«ãã¹ãããã¡ã¤ã¤ã¼ã¦ã©ã¼ã«ã®ãããã§ãrunserver ãã¦ã è¦ãããªããã§ããããããããã¨ããããwsgi ã使ãè¨å®ããã¾ãã
wsgi_handler.wsgi ãé ç½®
ä»ã¯ä¾ãã° django ã® project ã schedule ã¨ããªååã§ä½ã£ãã¨ãã¾ãããããã㨠schedule ãã£ã¬ã¯ããªã«ã§ãããapache 㨠Django ã®æ©æ¸¡ãããã wsgi ãæ¸ãã¦ãããå¿ è¦ãããã¾ãã
import sys, os os.environ['DJANGO_SETTINGS_MODULE'] = 'schedule.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
å¿ è¦ã«å¿ãã¦ãsys.path.append('/var/www/vhosts/virtualhostã®domain/httpdocs')ãªã©ã追è¨ããå¿ è¦ãããã¨æãã¾ãããã®ãã¨ã§ãhttpd.conf è¨å®ããã¾ãã
ã¤ã㧠httpd.conf ã®åè¨å®ãªã©ãªã©ã
ä¸è¨ã®æ¹ã ã®ã¨ã³ããªãåç §ããã¨ãDjango ã®ã¤ã³ã¹ãã¼ã«ã¾ã§ã¯ãã¾ãè¡ãã¾ãããã ããååã® VPS ã®å ´åã¯è±ªå¿«ã« vhost ã«ãªã£ã¦ããã®ã§ãããããè¨å®ããªãã¨åãã¨ãããè¦ããã¾ãããçµæ§ã²ã£ãããã¨ãããå¤ãã¦ãerror_log ãã¿ãªãã追ã£ããã¦ä¿®æ£ããã¾ããããªããªã大å¤ã§ãã...orz
1. /etc/httpd/conf/httpd.conf 㫠追è¨
LoadModule wsgi_module modules/mod_wsgi.so AddHandler wsgi-script .wsgi
ã¢ã¸ã¥ã¼ã«å¼ã³åºãã«ã¤ãã¦ã®è¿½è¨ã§ããã
*** 2. ãã¼ãã£ã«ãã¹ãã® httpd_vh_base.conf ã«è¿½è¨
WSGISocketPrefix /var/run/wsgi WSGIPythonHome /opt/python2.6 WSGIScriptAlias /schedule /var/www/vhosts/virtualhostã®domain/httpdocs/schedule/wsgi_han dler.wsgi
ä¸åº¦ .wsgi 㨠.py ãééããã®ã¯å ç·ã ...!! ãã¨ãWSGISocketPrefix ããªãã¨åããªãã£ããã.python-eggs ã® permission ãå¤ã ãã¨ãè¨ããããããã®ã§ããã®ããã㯠ç¹ã« http://d.hatena.ne.jp/perezvon/20081103 ãã¡ããåèã«ãã¦ãè¨å®ãå¤ãã¾ããã.python-eggs ã®æ¨©éãå¤ãããããã°ããããã§ããã
以ä¸ããã好ã¿ã§è¨å®ã
WSGIDaemonProcess schedule user=apache group=apache processes=1 threads=10 WSGIProcessGroup schedule
ãããããDjango ã® admin ã使ãå ´åãããã®ã§ãåæã§ããåãæ¥ã以ä¸ãæ¸ããããã¦CSSãè¦ããããã«ããããã¾ãããä¾ã«ããããã«static ãªãã¡ã¤ã«ã®ç½®ãå ´æããã¡ãã¨ä½ã£ãæ¹ãã¨ã¬ã¬ã³ãã§ãã=> Google Code Archive - Long-term storage for Google Code Project Hosting.
Alias /media/ /opt/python2.6/lib/python2.6/site-packages/Django-1.1.1-py2.6.eg g/django/contrib/admin/media/
ããã¯åãæ¥ãã®åä½ç¢ºèªã§ãã£ã¦ã¿ãã®ã§ãããã¾ãçä¼¼ããªãã§ãã
ããã§ãsocket ã¤ãªããã¼ãã¨ããwsgi ãããããã¨ãã¯åé¿ã§ãã¾ããããadmin ãæ£ãã表示ããã¾ãããã¨ããããå®å¿ã
ã¾ã¨ãã
Django ã¯ãPython ãªãã¨ãããã³ã¼ãããã£ãããã¦ã¦è¦ãããããå
¬å¼ã® Tutroial ãå
å®ãã¦ãã®ã§ãå¦ç¿ããããã§ãããããã©ããããã«ã¯å®ã¯ Python ããã¡ããã¨ãã¦ã人ã«ã¯ Perl ãåãã¦ãã¨ããããã¾ããã
ãã¨ãDjango ã§ãã è¨å®ã§ãããã¨ããããããããã©ããããã§ããã° MVC ãªã Webãã¬ã¼ã ã¯ã¼ã¯ã§ã±ãã±ãæ¸ããã¨æãã¾ããPython ã® å
¬å¼ã¬ã¤ãããã¥ã¼ããªã¢ã«ããããã¾ãä¿ã«ãã Pythonistique ã§ããã§ããã
ã²ããã¶ãã«ãããããã½ã¼ã¹ããã¤ã³ã¹ãã¼ã«ããããCentOS ã ãã®ã§ãrpm 系㧠yum ãªã©ä½¿ãã¾ãããã deb系㧠apt ãªæ¹ã楽ã§å¥½ãã ... ã¯ã¯ã¯ã
é ¼ã¾ãç©ã®ã¡ãã£ã¨ãããã®ã Django ã§ä½ããããªã¡ãããã£ã¦ããªãåã°ããã§ããä¸è¨ãåã¨ã³ããªãè¨è¼ãã¦ãã ãã£ãçæ§ã¨éçºè ã®çæ§ã«æè¬ã