adduser deploy
ssh-copy-id -i ~/.ssh/deploy.pub deploy@example.com
aptitude install git
git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
vim /etc/profile.d/rbenv.sh
# rbenv setup
export RBENV_ROOT=/usr/local/rbenv
export PATH="$RBENV_ROOT/bin:$PATH"
eval "$(rbenv init -)"
chmod +x /etc/profile.d/rbenv.sh
Exit and login again
mkdir /usr/local/rbenv/plugins
git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build
https://github.com/fesplugas/rbenv-bootstrap/blob/master/bin/rbenv-bootstrap-ubuntu-12-04
apt-get update
apt-get -y install build-essential tklib zlib1g-dev libssl-dev libreadline-gplv2-dev libxml2 libxml2-dev libxslt1-dev
apt-get -y install libcurl4-openssl-dev libpcre3-dev
rbenv install 2.1.0
rbenv global 2.1.0
rbenv rehash
ruby -v
gem install bundler
gem install passenger
cd /tmp && wget http://nginx.org/download/nginx-1.4.4.tar.gz
tar zxvf nginx-1.4.4.tar.gz && cd nginx-1.4.4
./configure \
--sbin-path=/usr/local/sbin \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/lib/nginx/body \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
--user=deploy --group=deploy \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_dav_module \
--with-http_flv_module \
--with-sha1=/usr/lib \
--add-module=`passenger-config --root`/ext/nginx
mkdir /var/lib/nginx
make && make install
http {
passenger_root /usr/local/rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/passenger-4.0.33;
passenger_ruby /usr/local/rbenv/shims/ruby;
passenger_pool_idle_time 0;
client_max_body_size 25m;
server_tokens off;
sendfile on;
keepalive_timeout 70;
gzip on;
gzip_http_version 1.1;
gzip_disable "msie6";
gzip_vary on;
gzip_min_length 1100;
gzip_buffers 64 8k;
gzip_comp_level 3;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml;
}
aptitude install mysql-server mysql-client libmysqlclient-dev
vim /etc/mysql/my.cnf
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
service mysql restart
mysql -uroot -p
GRANT ALL PRIVILEGES ON `%\_staging` . * TO 'staging'@'localhost' IDENTIFIED BY '***';
GRANT ALL PRIVILEGES ON `%\_production` . * TO 'production'@'localhost' IDENTIFIED BY '***';
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com/public;
passenger_enabled on;
index index.html;
charset utf-8;
access_log /dev/null;
error_log /dev/null;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
}