$ adduser deploy
$ usermod -s /bin/bash deploy
$ mkdir /home/deploy
$ mkdir /var/local/apps
$ chown deploy /var/local/apps
$ apt-get update
$ apt-get install build-essential libssl-dev zlib1g-dev libreadline5-dev git-core libxml2-dev libxslt-dev libcurl4-openssl-dev -y
$ apt-get install htop zip curl duplicity imagemagick ufw -y
$ ssh-keygen
Editar o arquivo /etc/ssh/sshd_config, mudar o "Port", "PermitRootLogin" e "Banner". Restart SSH
$ /etc/init.d/ssh restart
ufw default deny
ufw allow 80
ufw allow 443
ufw allow 5022
ufw logging on
ufw enable
$ cd /tmp && wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
$ tar xzvf yaml-0.1.4.tar.gz
$ cd yaml-0.1.4
$ ./configure --prefix=/usr/local
$ make && make install
$ cd /tmp && wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
$ tar -xvzf ruby-1.9.3-p194.tar.gz
$ cd ruby-1.9.3-p194/
$ ./configure --prefix=/usr/local
$ make && make install
Atualiza rubygems e instala o bundler
$ gem update --system
$ gem install bundler --no-ri --no-rdoc
$ cd /tmp && wget http://nginx.org/download/nginx-1.2.2.tar.gz
$ tar xvzf nginx-1.2.2.tar.gz
$ cd nginx-1.2.2
$ apt-get install libpcre3-dev
$ ./configure --prefix='/opt/nginx' --with-http_ssl_module --with-cc-opt='-Wno-error' --with-http_stub_status_module
$ make && make install
Copiar o nginx.conf para a pasta /opt/nginx/conf/ e alterar o domain para o nome do app.
Adicionar no /etc/apt/sources.list
# redis https://launchpad.net/~rwky/+archive/redis
deb http://ppa.launchpad.net/rwky/redis/ubuntu lucid main
deb-src http://ppa.launchpad.net/rwky/redis/ubuntu lucid main
$ apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5862E31D
$ apt-get update
$ apt-get install redis-server
$ apt-get install mysql-server libmysqlclient16 libmysqlclient16-dev
Cria o usuário do projeto.
$ mysql -uroot -p
mysql> CREATE USER 'rails'@'localhost' IDENTIFIED BY 'senha';
mysql> GRANT ALTER,DELETE,INSERT,SELECT,UPDATE,DROP,INDEX,CREATE ON xxx_production.* TO 'rails'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> exit
$ cat /dev/null > ~/.mysql_history
$ chmod 600 ~/.mysql_history
Subir a chave cat ~/.ssh/id_rsa.pub
para o account do BitBuckut.
Entrar em /var/local/apps
e executar o git clone.
No projeto executar:
$ bundle install --deployment --without development test
Configurar o config/database.yml
Criar o arquivo myapp dentro do diretório "/etc/logrotate.d/". Exemplo do arquivo myapp:
# Rotate Rails application logs weekly
/var/local/apps/myapp/log/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
copytruncate
}