Deploy Django nginx flup diatas ubuntu server

Pada awalnya sayah ingin memakai nginx sebagai webserver untuk aplikasi sosial direktori sayah .. berikut ini sedikit Dokumentasi Deploy Django nginx flup diatas ubuntu server

Install paket paket berikut

sudo apt-get update
sudo apt-get install nginx
sudo apt-get install mysql-server mysql-client
sudo apt-get install python-mysqldb
sudo easy_install flup

siapkan direktori untuk installasi django
$ mkdir public_html
$ mkdir brungut.com
$ mkdir ~/public_html/brungut.com/logs
$ cd public_html
wget -c http://media.djangoproject.com/releases/1.1/Django-1.1.tar.gz

ekstrak berkas tarbal tersebut

$ cd Django-1.1
$ sudo python setup.py install

atur python path (optional)

$ cd
$ nano .bash_profile

export PATH=$PATH:$HOME/public_html/Django-1.1/django/bin
export PYTHONPATH=$PYTHONPATH:$HOME/ public_html/Django-1.1:$HOME/brungut.com

database

$ mysql -u root -p
$ mysql> create database benderahitam;

(buat user baru dan beri hak ke database tersebut )

buat django apps

$ cd brungut.com
$ django-admin.py startproject myproject
$ cd myproject
$ nano settings.py

sesuaikan dengan kofigurasi database

DATABASE_ENGINE = ‘mysql’ #
DATABASE_NAME = ‘benderahitam’ #
DATABASE_USER = ‘user’ #
DATABASE_PASSWORD = ‘mypasswd’ #
DATABASE_HOST = ” #
DATABASE_PORT = ”

Konvigurasi nginx

$ sudo nano /etc/nginx/sites-available/brungut.com

server
{
listen 80;

server_name http://www.brungut.com;
access_log /home/dodolboks/public_html/brungut.com/log/access.log;
error_log /home/dodolboks/public_html/brungut.com/log/error.log;
root /home/dodolboks/public_html/brungut.com/myproject/;

location /site_media
{
root /home/dodolboks/public_html/brungut.com/myproject/media;
}

location /
{
# host and port to fastcgi server
fastcgi_pass 127.0.0.1:8081;
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;
}
}

$ sudo ln -s /usr/lib/python2.5/site-packages/django/contrib/admin/media /home/dodolboks/public_html/brungut.com/myproject/media/admin
$ sudo usermod -a -G www-data dodolboks
$ sudo chgrp -R www-data /home/dodolboks/public_html
$ sudo chmod -R 2750 /home/dodolboks/public_html
$ sudo ln -s /etc/nginx/sites-available/brungut.com /etc/nginx/sites-enabled/brungut.com
$ sudo /etc/init.d/nginx restart

$ cd /home/dodolboks/public_html/brungut.com/myproject/
$ python manage.py runfcgi host=127.0.0.1 port=8081 –settings=settings

viola … simpel kan… ? demonya bisa dilihat disini

Iklan

One response to “Deploy Django nginx flup diatas ubuntu server

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s