sudo aptitude install vim-nox
sudo vim /etc/ssh/sshd_config
Port 2222 PermitRootLogin no PasswordAuthentication no
に変更する
sudo /etc/init.d/ssh restart
sudo aptitude install locale sudo aptitude install language-pack-ja-base
sudo aptitude install python-software-properties pkg-config sudo add-apt-repository "deb http://ppa.launchpad.net/nginx/stable/ubuntu lucid main" sudo aptitude update sudo aptitude install nginx sudo cp /etc/nginx/nginx.conf . sudo mkdir /tmp/nginx sudo chown www-data /tmp/nginx
sudo aptitude install mysql-server-5.1 libmysqld-dev sudo vim /etc/mysql/my.cnf
[client] default-character-set = utf8 [mysqld] skip-name-resolve default-character-set = utf8 log-bin=/var/log/mysql/mysql-slow.log log-bin-index=bin.index log_slow_queries = /var/log/mysql/mysql-slow.log long-query-time=1 log-queries-not-using-indexes log-slow-admin-statements [mysqldump] default-character-set = utf8 [mysql] default-character-set = utf8
サービス動かしたいユーザーでやると良いです。www-dataとか?
sudo aptitude install build-essential bison openssl\
libreadline6 libreadline6-dev curl git-core zlib1g\
zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 \
libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev
sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
echo 'source /usr/local/lib/rvm' >> ~/.zshrc # if you use bash, write into ".bashrc". rvmsudo rvm install ruby-1.8.7-head rvm use ruby-1.8.7-head --default rvm gemset create your_service rvm gemset list_all rvm use 1.8.7-head@your_service rvm current # 確認
sudo vim /etc/rvmrc
export rvm_trust_rvmrcs_flag=1
を追加
さきほど作ったrvm gemsetをuseした状態でbundlerは最低限入れておく。
gem install bundler —no-ri —no-rdoc
unicornは後述のようにcapistranoで起動させます。
nginxで、動かすサービスのforward proxyの設定をします。
以下は一例。
upstream your-service-backend {
server localhost:3000;
}server {
location ~ ^/(_|assets|javascripts|images|stylesheets|uploads)/(.*)$ { root /path/to/your/service/current/public; gzip_static on; # to serve pre-gzipped version; expires max; add_header Cache-Control public; access_log off; } proxy_buffer_size 64k; proxy_buffers 16 64k; location / { proxy_pass http://your-service-backend; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
listen 80;
server_name yourservice.example.com;}
capistranoの設定は以下が参考になります。