mercredi 14 décembre 2016

A script to install everything from scracth

#!/bin/sh

## update & upgrade
sudo apt-get update
sudo apt-get upgrade

## install rvm with ruby & rails
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable
\curl -sSL https://get.rvm.io | bash -s stable --ruby
rvm --default use ruby-2.3.1
gem update --system
source ~/.rvm/scripts/rvm

## rvm lib requirements
rvm requirements
rvmsudo /usr/bin/apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion -y
rvm install ruby-2.3.1

## install passenger
gem install passenger

## install nginx with passenger and recompile it - default
 echo | rvmsudo passenger-install-nginx-module -y

## install curl ssl for passenger
sudo apt-get install libcurl4-openssl-dev -y

## define where to find nginx
wget -O init-deb.sh http://ift.tt/PfsLUk
sudo mv init-deb.sh /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
sudo /usr/sbin/update-rc.d -f nginx defaults

## after that you can control nginx with
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx start

## create directory for application
mkdir www
mkdir www/rails

## create new app
cd www/rails
rvm use ruby-2.3.1@myApp --ruby-version --create
gem install rails
rails new .


### ADD MANDATORY GEMS ###
## install postgreSQL with right packages
sudo apt-get install libpq-dev -y

rails g react:install

My goal is to make a script which will install :

- rvm to manage ruby & rails versions
- nginx and passenger ( not with apt-get i nginx )
- add postgresql
- create directory & app in /home/ubuntu/www/rails/myApp
- install react and assets
- modify if possible nginx conf to work with passenger ( no location {} and need passenger_enabled on )
- build connection if possible between the app and postgreSQL DB of RDS AWS
- start the server and is accessible

If someone got any suggestions for how to improve this script is welcomed :)

for now since last ruby version 2.3.1, it s seems that RVM stable is still 2.3.0 and when i force install 2.3.1 it remove rails unless i redo "gem install rails"

thanks for your help !

Aucun commentaire:

Enregistrer un commentaire