Ubuntu 10.04 LTS + NginX + Django 1.3 (FastCGI) + Python 2.7.2

이번에는 Ubuntu 10.04 (LTS) 에서 NginX + Django 1.3 (FastCGI) + Python 2.7.2 를 구성해보았다. Python 을 설치하기 전에 zlibc 를 먼저 설치해주어야 distribute 가 제대로 설치되는 삽질이 있었긴 했지만, CentOS에서 설치했던 것처럼 대체적으로 무난하게 설정이 되었다.


  1. Install Python
    # aptitude install zlibc zlib1g-dev
    # echo 'export PYTHONBREW_ROOT=/opt/pythonbrew' >> /etc/profile; source /etc/profile
    # curl -kLO http://xrl.us/pythonbrewinstall; chmod +x pythonbrewinstall; ./pythonbrewinstall
    # echo 'source /opt/pythonbrew/etc/bashrc' >> /etc/profile; source /etc/profile
    # pythonbrew install --force --no-test 2.7.2
    # pythonbrew switch 2.7.2
  2. Install Django
    # pip install django flup
  3. Create Project
    # mkdir -p /opt/project
    # cd /opt/project
    # django-admin.py startproject sample_project
    # cd sample_project
    # mkdir media
  4. Run Project
    # cd /opt/project/sample_project
    # python manage.py runfcgi method=threaded pidfile=/tmp/django_sample.pid host=127.0.0.1 port=8000
  5. Install NginX
    # aptitude install nginx
  6. Configure NginX
    # cd /etc/nginx/sites-available
    # vi django 
    server {
        listen 80;
        server_name 도메인주소;
        location /site_media  {
            root /opt/project/sample_project/media/;
        }
        location / {
            # host and port to fastcgi server
            fastcgi_pass 127.0.0.1:8000;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            fastcgi_param REQUEST_METHOD $request_method;
            fastcgi_param QUERY_STRING $query_string;
            fastcgi_param CONTENT_TYPE $content_type;
            fastcgi_param CONTENT_LENGTH $content_length;
            fastcgi_pass_header Authorization;
            fastcgi_intercept_errors off;
        }
    }
    # cd /etc/nginx/sites-enabled
    # ln -s /etc/nginx/sites-available/django django
  7. Run NginX
    # /etc/init.d/nginx restart


댓글

이 블로그의 인기 게시물

야마하 디지털 피아노 YDP-140

테이블위로 마우스 커서 이동시 색깔 변경하기

피아노 연습