# 首先设置语言 ```shell cd /usr/share/locales sudo ./install-language-pack zh_CN ``` # 安装RUBY必要的环境依赖 ```shell sudo apt-get update sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libpq-dev imagemagick libmagickwand-dev ``` # 安装必要的服务 ```shell sudo apt-get memcached redis-server # https://www.linode.com/docs/databases/redis/redis-on-ubuntu-12-04-precise-pangolin ``` # 将bashrc生效 ```shell cp ~/.profile ~/.bash_profile ``` add following code to ~/.bash_profile ```shell # ~/.profile: executed by Bourne-compatible login shells. if [ "$BASH" ]; then if [ -f ~/.bashrc ]; then . ~/.bashrc fi fi mesg n ``` # 使用RBENV安装RUBY ```shell cd ~ git clone git://github.com/sstephenson/rbenv.git .rbenv echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc exec $SHELL git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc exec $SHELL rbenv install 2.1.3 rbenv global 2.1.3 ruby -v ``` # 安装 Phusion Passenger ```shell sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7 sudo apt-get install apt-transport-https ca-certificates sudo vim /etc/apt/sources.list.d/passenger.list ``` insert one of the following lines, depending on your distribution. ```shell deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main ``` ```shell sudo chown root: /etc/apt/sources.list.d/passenger.list sudo chmod 600 /etc/apt/sources.list.d/passenger.list sudo apt-get update sudo apt-get install nginx-extras passenger ``` Edit /etc/nginx/nginx.conf and uncomment and change to this ```shell passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini; passenger_ruby /home/ubuntu/.rbenv/shims/ruby; # passenger_friendly_error_pages on; for show error ``` # 配置虚拟主机 ```shell cd /etc/nginx/sites-available sudo vim virtual-host-name ``` ```shell server { server_name virtual-host; listen 80; root /home/ubuntu/www/virtual_host_path/current/public; passenger_enabled on; rails_env staging; # ruby env underscores_in_headers on; # fuck nginx http://stackoverflow.com/questions/22856136/why-underscores-are-forbidden-in-http-header-names gzip on; gzip_http_version 1.1; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_types text/plain text/css text/xml application/xml application/xml+rss; location ~* \.(ico|css|gif|jp?g|png)(\?[0-9]+)?$ { expires max; } } ``` # www.pathsource.com 字幕配置 ```shell sudo vim /etc/ngnix/ngnix.conf ... http { ... resolver 8.8.8.8; //dns server ... } sudo vim /etc/nginx/sites-available/www.pathsource.com server { ... location ~ /subtitles/(?.*).vtt { proxy_pass http://hls.pathsource.com/$videoid/subtitles/$videoid.vtt; proxy_set_header Host hls.pathsource.com; } ... } ... ``` ``` sudo ln -nfs /etc/nginx/sites-available/virtual-host-name /etc/nginx/sites-enabled/virtual-host-name ``` ``` # Bundler ```shell gem install bundler ``` # 服务器安装定时任务管理器 ```shell gem install whenever ``` # 使用mina架设服务器和配置数据库 ```shell sudo vim /etc/environment 添加 RAILS_ENV=production ``` # 本地部署命令 ```shell mina deploy # 部署 staging 环境 mina deploy on=live # 部署 production 环境 ```