Skip to content

Instantly share code, notes, and snippets.

@genomics-geek
Forked from ravidsrk/Install.md
Created January 16, 2017 22:46
Show Gist options
  • Save genomics-geek/c7c0c877fe57c1507fff27738e2c6475 to your computer and use it in GitHub Desktop.
Save genomics-geek/c7c0c877fe57c1507fff27738e2c6475 to your computer and use it in GitHub Desktop.

Revisions

  1. @ravidsrk ravidsrk revised this gist Jan 15, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Install.md
    Original file line number Diff line number Diff line change
    @@ -65,6 +65,7 @@ DATABASES = {
    cd /opt/myenv/myproject
    pip install -r requirements.txt
    python manage.py syncdb
    python manage.py collectstatic
    ```

    ### Step Nine: Configure Gunicorn
    @@ -80,7 +81,7 @@ sudo nano gunicorn_config.py
    command = '/opt/myenv/bin/gunicorn'
    pythonpath = '/opt/myenv/myproject'
    bind = '127.0.0.1:8001'
    user = nobody
    user = 'nobody'
    ```

    ```bash
  2. @ravidsrk ravidsrk revised this gist Jan 15, 2014. 1 changed file with 27 additions and 27 deletions.
    54 changes: 27 additions & 27 deletions Install.md
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,24 @@
    ### Step One: Update Packages
    ```bash
    $ sudo apt-get update
    $ sudo apt-get upgrade
    sudo apt-get update
    sudo apt-get upgrade
    ```

    ### Step Two: Install and Create Virtualenv
    ```bash
    $ sudo apt-get install python-virtualenv
    $ sudo virtualenv /opt/myenv
    sudo apt-get install python-virtualenv
    sudo virtualenv /opt/myenv
    ```

    ### Step Three: Install Django
    ```bash
    $ pip install django
    pip install django
    ```

    ### Step Four: Install MySQL
    ```bash
    $ deactivate
    $ sudo apt-get install build-essential git mysql-server mysql-client libmysqlclient-dev python-dev
    deactivate
    sudo apt-get install build-essential git mysql-server mysql-client libmysqlclient-dev python-dev
    ```

    ### Step Five: Install NGINX
    @@ -28,24 +28,24 @@ sudo apt-get install nginx

    ### Step Six: Install Gunicorn
    ```bash
    $ source /opt/myenv/bin/activate
    $ pip install gunicorn
    source /opt/myenv/bin/activate
    pip install gunicorn
    ```

    ### Step Seven: Configure MySQL


    ### Step Eight: Clone the Django Project
    ```bash
    $ cd /opt/myenv
    $ source /opt/myenv/bin/activate
    $ git clone git-url myproject
    $ cd /opt/myenv/myproject/myproject
    cd /opt/myenv
    source /opt/myenv/bin/activate
    git clone git-url myproject
    cd /opt/myenv/myproject/myproject
    ```

    ##### Edit the settings.py file with your editor of choice:
    ```bash
    $ vim settings.py
    vim settings.py
    ```

    ```python
    @@ -62,17 +62,17 @@ DATABASES = {
    ```

    ```bash
    $ cd /opt/myenv/myproject
    $ pip install -r requirements.txt
    $ python manage.py syncdb
    cd /opt/myenv/myproject
    pip install -r requirements.txt
    python manage.py syncdb
    ```

    ### Step Nine: Configure Gunicorn

    ```bash
    $ gunicorn_django --bind 162.243.36.4:8001
    $ cd /opt/myenv
    $ sudo nano gunicorn_config.py
    gunicorn_django --bind 162.243.36.4:8001
    cd /opt/myenv
    sudo nano gunicorn_config.py
    ```

    ##### Add the following contents to the file:
    @@ -84,13 +84,13 @@ user = nobody
    ```

    ```bash
    $ /opt/myenv/bin/gunicorn -c /opt/myenv/gunicorn_config.py myproject.wsgi
    /opt/myenv/bin/gunicorn -c /opt/myenv/gunicorn_config.py myproject.wsgi
    ```

    ### Step Ten: Configure NGINX
    ```bash
    $ sudo service nginx start
    $ sudo nano /etc/nginx/sites-available/myproject
    sudo service nginx start
    sudo nano /etc/nginx/sites-available/myproject
    ```

    ##### Add following lines in nginx Configure
    @@ -115,8 +115,8 @@ server {

    ##### nginx restart
    ```bash
    $ cd /etc/nginx/sites-enabled
    $ sudo ln -s ../sites-available/myproject
    $ sudo rm default
    $ sudo service nginx restart
    cd /etc/nginx/sites-enabled
    sudo ln -s ../sites-available/myproject
    sudo rm default
    sudo service nginx restart
    ```
  3. @ravidsrk ravidsrk revised this gist Jan 15, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Install.md
    Original file line number Diff line number Diff line change
    @@ -43,7 +43,7 @@ $ git clone git-url myproject
    $ cd /opt/myenv/myproject/myproject
    ```

    # Edit the settings.py file with your editor of choice:
    ##### Edit the settings.py file with your editor of choice:
    ```bash
    $ vim settings.py
    ```
  4. @ravidsrk ravidsrk revised this gist Jan 15, 2014. 1 changed file with 48 additions and 15 deletions.
    63 changes: 48 additions & 15 deletions Install.md
    Original file line number Diff line number Diff line change
    @@ -1,38 +1,54 @@
    `` bash
    # Step One: Update Packages
    ### Step One: Update Packages
    ```bash
    $ sudo apt-get update
    $ sudo apt-get upgrade
    ```

    # Step Two: Install and Create Virtualenv
    ### Step Two: Install and Create Virtualenv
    ```bash
    $ sudo apt-get install python-virtualenv
    $ sudo virtualenv /opt/myenv
    ```

    # Step Three: Install Django
    ### Step Three: Install Django
    ```bash
    $ pip install django
    ```

    # Step Four: Install MySQL
    ### Step Four: Install MySQL
    ```bash
    $ deactivate
    $ sudo apt-get install build-essential git mysql-server mysql-client libmysqlclient-dev python-dev
    ```

    # Step Five: Install NGINX
    ### Step Five: Install NGINX
    ```bash
    sudo apt-get install nginx
    ```

    # Step Six: Install Gunicorn
    ### Step Six: Install Gunicorn
    ```bash
    $ source /opt/myenv/bin/activate
    $ pip install gunicorn
    ```

    # Step Seven: Configure MySQL
    ### Step Seven: Configure MySQL


    # Step Eight: Clone the Django Project
    ### Step Eight: Clone the Django Project
    ```bash
    $ cd /opt/myenv
    $ source /opt/myenv/bin/activate
    $ git clone git-url myproject
    $ cd /opt/myenv/myproject/myproject
    ```

    # Edit the settings.py file with your editor of choice:
    ```bash
    $ vim settings.py
    ```

    ```python
    DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.mysql',
    @@ -43,28 +59,42 @@ DATABASES = {
    'PORT': '',
    }
    }
    ```

    ```bash
    $ cd /opt/myenv/myproject
    $ pip install -r requirements.txt
    $ python manage.py syncdb
    ```

    ### Step Nine: Configure Gunicorn

    # Step Nine: Configure Gunicorn
    ```bash
    $ gunicorn_django --bind 162.243.36.4:8001
    $ cd /opt/myenv
    $ sudo nano gunicorn_config.py
    # Add the following contents to the file:
    ```

    ##### Add the following contents to the file:
    ```bash
    command = '/opt/myenv/bin/gunicorn'
    pythonpath = '/opt/myenv/myproject'
    bind = '127.0.0.1:8001'
    user = nobody
    ```

    ```bash
    $ /opt/myenv/bin/gunicorn -c /opt/myenv/gunicorn_config.py myproject.wsgi
    ```

    # Step Ten: Configure NGINX
    ### Step Ten: Configure NGINX
    ```bash
    $ sudo service nginx start

    $ sudo nano /etc/nginx/sites-available/myproject
    #Add following lines in nginx Configure
    ```

    ##### Add following lines in nginx Configure
    ```bash
    server {
    server_name yourdomainorip.com;

    @@ -81,9 +111,12 @@ server {
    add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
    }
    }
    ```

    ##### nginx restart
    ```bash
    $ cd /etc/nginx/sites-enabled
    $ sudo ln -s ../sites-available/myproject
    $ sudo rm default
    $ sudo service nginx restart
    ``
    ```
  5. @ravidsrk ravidsrk created this gist Jan 15, 2014.
    89 changes: 89 additions & 0 deletions Install.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,89 @@
    `` bash
    # Step One: Update Packages
    $ sudo apt-get update
    $ sudo apt-get upgrade

    # Step Two: Install and Create Virtualenv
    $ sudo apt-get install python-virtualenv
    $ sudo virtualenv /opt/myenv

    # Step Three: Install Django
    $ pip install django

    # Step Four: Install MySQL
    $ deactivate
    $ sudo apt-get install build-essential git mysql-server mysql-client libmysqlclient-dev python-dev

    # Step Five: Install NGINX
    sudo apt-get install nginx

    # Step Six: Install Gunicorn
    $ source /opt/myenv/bin/activate
    $ pip install gunicorn

    # Step Seven: Configure MySQL


    # Step Eight: Clone the Django Project
    $ cd /opt/myenv
    $ source /opt/myenv/bin/activate
    $ git clone git-url myproject
    $ cd /opt/myenv/myproject/myproject

    # Edit the settings.py file with your editor of choice:
    $ vim settings.py

    DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.mysql',
    'NAME': 'myproject',
    'USER': 'root',
    'PASSWORD': 'password',
    'HOST': '127.0.0.1',
    'PORT': '',
    }
    }
    $ cd /opt/myenv/myproject
    $ pip install -r requirements.txt
    $ python manage.py syncdb

    # Step Nine: Configure Gunicorn
    $ gunicorn_django --bind 162.243.36.4:8001
    $ cd /opt/myenv
    $ sudo nano gunicorn_config.py
    # Add the following contents to the file:
    command = '/opt/myenv/bin/gunicorn'
    pythonpath = '/opt/myenv/myproject'
    bind = '127.0.0.1:8001'
    user = nobody

    $ /opt/myenv/bin/gunicorn -c /opt/myenv/gunicorn_config.py myproject.wsgi

    # Step Ten: Configure NGINX
    $ sudo service nginx start

    $ sudo nano /etc/nginx/sites-available/myproject
    #Add following lines in nginx Configure

    server {
    server_name yourdomainorip.com;

    access_log off;

    location /static/ {
    alias /opt/myenv/static/;
    }

    location / {
    proxy_pass http://127.0.0.1:8001;
    proxy_set_header X-Forwarded-Host $server_name;
    proxy_set_header X-Real-IP $remote_addr;
    add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
    }
    }

    $ cd /etc/nginx/sites-enabled
    $ sudo ln -s ../sites-available/myproject
    $ sudo rm default
    $ sudo service nginx restart
    ``