This document has now been incorporated into the uWSGI documentation:
http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html
Steps with explanations to set up a server using:
| // | |
| // Regular Expression for URL validation | |
| // | |
| // Author: Diego Perini | |
| // Created: 2010/12/05 | |
| // Updated: 2018/09/12 | |
| // License: MIT | |
| // | |
| // Copyright (c) 2010-2018 Diego Perini (http://www.iport.it) | |
| // |
| namespace :db do desc "Backup project database. Options: DIR=backups RAILS_ENV=production MAX=7" | |
| task :backup => [:environment] do | |
| datestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S") | |
| base_path = Rails.root | |
| base_path = File.join(base_path, ENV["DIR"] || "backups") | |
| backup_base = File.join(base_path, 'db_backups') | |
| backup_folder = File.join(backup_base, datestamp) | |
| backup_file = File.join(backup_folder, "#{RAILS_ENV}_dump.sql") | |
| FileUtils.mkdir_p(backup_folder) | |
| db_config = ActiveRecord::Base.configurations[RAILS_ENV] |
| #!/bin/bash | |
| echo "Generating an SSL private key to sign your certificate..." | |
| openssl genrsa -des3 -out myssl.key 1024 | |
| echo "Generating a Certificate Signing Request..." | |
| openssl req -new -key myssl.key -out myssl.csr | |
| echo "Removing passphrase from key (for nginx)..." | |
| cp myssl.key myssl.key.org | |
| openssl rsa -in myssl.key.org -out myssl.key |
| # Capistrano configuration | |
| # | |
| # require 'new_relic/recipes' - Newrelic notification about deployment | |
| # require 'capistrano/ext/multistage' - We use 2 deployment environment: staging and production. | |
| # set :deploy_via, :remote_cache - fetch only latest changes during deployment | |
| # set :normalize_asset_timestamps - no need to touch (date modification) every assets | |
| # "deploy:web:disable" - traditional maintenance page (during DB migrations deployment) | |
| # task :restart - Unicorn with preload_app should be reloaded by USR2+QUIT signals, not HUP |
| ''' | |
| Add CORS headers for tastypie APIs | |
| Usage: | |
| class MyModelResource(CORSModelResource): | |
| ... | |
| class MyResource(CORSResource): | |
| ... | |
| # to generate your dhparam.pem file, run in the terminal | |
| openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.
Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.
The simplest way to add an alias for a specific git command is to use a standard bash alias.
# .bashrcdbfpy: http://sourceforge.net/projects/dbfpy/files/latest/download?source=filessudo python setup.py installTo convert DBF file to CSV:
./dbf2csv database.dbf