BKJIA Translation: Nginx has become the third largest Web server in the world. Among the top 10 Web servers used by domestic websites, Nginx is also among the top. Ruby on Rails is a new generation of Web development languages that have become popular in recent years. Its easy-to-use and agile features have attracted the attention of many Web developers.
This article will guide you to install and configure the Ruby on Rails environment step by step on Ubuntu/Debian, and achieve excellent performance with the Nginx runtime environment.
Install Ruby
- export PATH="${PATH}:/var/lib/gems/1.8/bin/"
- echo 'export PATH="${PATH}:/var/lib/gems/1.8/bin/"' >> /etc/bash.bashrc
- aptitude install ruby rubygems vim-ruby rub y-dev libzlib-ruby
- libyaml-ruby libreadline-ruby libncurses-ruby rdoc ri libcurses-ruby
- libruby libruby-extras libfcgi-ruby build-essential libopenssl-ruby
- libdbm-ruby libdbi-ruby libxml-ruby libxml2-dev
Install Rails
- gem install -v=2.3.5 rails
Gem install rails should also work, but 2.3.6-2.3.8 is currently being written) there is a problem. If you want to try the latest version, you can use:
- gem install rails –pre
Or use RVM. RVM is a command line tool that allows us to install, manage, and use multiple Ruby environments more easily.
Applications
My new application is called myapp.example.com.
- cd /var/www
- rails new myapp.example.com
- cd myapp.example.com
Thin Server
Thin will become a Ruby Server:
- gem install thin
- thin install
- /usr/sbin/update-rc.d -f thin defaults
- thin config -C /etc/thin/myapp.example.com -c
- /var/www/myapp.example.com --servers 3 -e development # or: -e production for caching, etc
If you do not like Thin, and Mongrels:
- aptitude install mongrel mongrel-cluster
- mongrel_rails cluster::configure -e development -p 3000 -N 3 -c /var/www/myapp.example.com
- -a 127.0.0.1 # or: -e production for caching, etc
- mkdir /etc/mongrel_cluster
- sudo ln -nfs /var/www/myapp.example.com/config/mongrel_cluster.yml /etc/mongrel_cluster/myapp.example.com.yml
- #sudo ln -nfs /var/www/myapp.example.com/config/mongrel_cluster.yml
- /etc/mongrel-cluster/sites-enabled/myapp.example.com.yml
Install Nginx
Nginx will act as a Web server, and the Ruby request sent by the proxy to Thin runs on port-. Run the following command to install Nginx:
- aptitude install nginx