Deploy Rails project on AWS - ruby-on-rails

How can I deploy my Ruby on Rails project to EC2? I have a postgres database and currently use Heroku but I now need to shift to AWS.
Any help is much appreciated.

Googling it may help ;o)
https://www.google.fr/search?q=deploy+rails+on+EC2
Then you have a very nice railscast that details the steps to do so with the rubber gem.
http://railscasts.com/episodes/347-rubber-and-amazon-ec2/

My preference is the default AWS linux then jump start it with some basic libraries:
sudo yum update
sudo yum groupinstall -y "Development Tools"
sudo yum groupinstall -y "Development Libraries"
sudo yum install -y httpd httpd-devel apr-devel libcurl-devel libxslt-devel libcurl-devel openssl-devel mysql mysql-devel ImageMagick ImageMagick-devel sqlite-devel
\curl -L https://get.rvm.io | bash -s stable --rails
git clone your rails app to your directory
bundle install --without test
Then don't forget to increase your limits (if you do any significant file io)
Add this to the /etc/security/limits.conf
root soft nofile 65535
root hard nofile 65535
* soft nofile 65535
* hard nofile 65535
Then install passenger or something like this and have it use rvm 1.9.3.

Related

How to install rails in Ubuntu 16 OS X?

I am beginner of learning rails. I want to install rails5 in my Linux operating system.
How can I install rails in Ubuntu 16.04 LTS system ?
The first step is to install some dependencies for Ruby.
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 libffi-dev nodejs
Install rbenv and ruby:
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 2.4.0
rbenv global 2.4.0
ruby -v
The last step is to install Bundler
gem install bundler
Install nodejs:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
Install rails now:
gem install rails -v 5.0.1
you'll need to run the following command to make the rails executable available:
rbenv rehash
Now that you've installed Rails, you can run the rails -v command to make sure you have everything installed correctly:
rails -v
# Rails 5.0.1
You should use RVM to install Rails. It's a virtualization system that will allow you to install multiple versions of Ruby, and maintain different sets of libraries (including Rails) for each project you work on. By default, it installs Rails and its libraries (gems) in your user directory. This is both safer (more secure) than system-wide installation, and much more flexible.
You could install Rails via Ubuntu's package manager (sudo apt-get install rails), and install its libraries via the system-wide RubyGems installer (gem), but that's not a best-practice. While Ruby and Rails don't change as often as they did a few years ago, the dev ecosystem still evolves faster than Linux distributions like Ubuntu can keep up with.
These days, everyone developing Rails apps uses either RVM or rbenv to manage user-space installations. There's no compelling reason to prefer RVM or rbenv as you start out, but RVM is more popular.

Rails Passenger and Nginx + GeoIP module

I install as always passanger gem and then:
rvmsudo passenger-install-nginx-module
and I chose auto configuration and
/opt/nginx
folder for nginx.
Now when I wrote
nginx -V
I only see
nginx:command not found
usr/local/bin is empty.
Of course app works but I try to install GeoIP and just can't check what modules nginx have installed.
ANSWER:
Standard auto installation of rvmsudo passenger-nginx-module doesn't load aditional modules.
Looks like something went wrong with the installation process. According to the passenger official docs, to install passenger do this (considering your are using Ubuntu 14.04):
# Install our PGP key and add HTTPS support for APT
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates
# Add our APT repository
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update
# Install Passenger + Nginx
sudo apt-get install -y nginx-extras passenger
If you already have nginx on the system this command will just upgrade Nginx to Phusion's version (with Passenger compiled in).
start it:
sudo service nginx restart
check if its working by running
sudo passenger-config validate-install

Error running 'requirements_debian_update_system ruby-1.9.3-p551',

Problem facing when installing rvm install 1.9.3
in ubuntu 12.04
Please help me
The problem here is that you didn't reboot (or log out) as per the ubuntu RVM instructions so your user is not (yet) part of the rvm group, and thus has no write permissions on the logs directory.
You can fix this by logging out, rebooting or opening a new shell using
sudo su - $USER
That will create a new shell with your user with the correct rights.
You can run following command from terminal and i think it will solve your problem.
N.B: If you don't need rails simply skip command after ruby installation
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
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm install 2.1.3
rvm use 2.1.3 --default
ruby -v
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
gem install rails
rails -v
For those who may have issues after running the commands shared on every thread out there, try opening ubuntu or the Linux environment you are working with as an administrator.
search for your app (in my case Ubuntu) using the search bar on the bottom-left of your computer's screen.
if you don't see the option "open as administrator" on the right side, then right-click over the app's icon and you should see it then.
Allow the app to make changes on your computer when prompted and then try the installation commands again.
If that didn't work then try the commands shared in this or other posts, but always as administrator.

Can ejabberd be installed on Google Compute Engine?

Can ejabberd be installed on Google Compute Engine? Will there be any issues with using ejabberd on Compute Engine? I have looked but cannot find any references to anyone trying this before. Grateful for any help.
Yes. Compute Engine gives you VMs. You can put whatever you want on them, such as Erlang and ejabberd.
Yes you can.
You can use the Vm with Debian Image and follow this intructions.
http://www.howtoforge.com/virtual-mail-jabber-server-xmpp-with-iredmail-and-ejabberd-on-ubuntu-9.10
dont forget open the ports in the firewall.
Sorry I didn't have much time to put together a cleaner "how to". I just copied and pasted from my personal archive.
Here's what you'd have to do to compile the source code on a Compute Engine. Please let me know if you have any questions.
Image: debian-7-wheezy-v20140408
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install libncurses5-dev
sudo apt-get install openssl libssl-dev
sudo apt-get install libexpat1-dev
sudo apt-get install unixodbc-dev
wget http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz
tar tar -xvzf yaml-0.1.5.tar.gz
cd yaml-0.1.5
./configure
sudo make
sudo make install
sudo apt-get install xsltproc
sudo apt-get install fop
cd ..
wget http://www.erlang.org/download/otp_src_R16B03-1.tar.gz
gunzip -c otp_src_R16B03-1.tar.gz | tar -xf -
cd o....
./configure --with-odbc=/usr/lib/odbc
sudo make
sudo make install
[.. Install git and clone repo here.. ]
git clone git#github.com:processone/ejabberd.git
cd ejabberd
./configure --enable-odbc --enable-mysql
sudo make
sudo make install

How to configure yaws webserver in the linux terminal?

can someone help me on to write my yaws webserver configuration file in the Linux terminal. when i follow the yaws tutorials i get errors. thanks a lot.
This is how I installed Yaws 1.89 on Ubuntu Server 10.10.
1. Update your Ubuntu system
sudo apt-get update
sudo apt-get upgrade
2. Install the tools you need to compile
sudo apt-get install gcc
sudo apt-get install libpam0g-dev
3. Download, compile and install Yaws 1.89
wget http://yaws.hyber.org/download/yaws-1.89.tar.gz
tar xfz yaws-1.89.tar.gz
cd yaws
./configure && make
sudo make install

Resources