Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jarod022/7081206 to your computer and use it in GitHub Desktop.
Save jarod022/7081206 to your computer and use it in GitHub Desktop.
#Installation RVM + Ruby 2.0.0-p247 + Rails + nginx + Passenger sur CentOS
(avec sudo)
# Dépendance à installer :
sudo yum install git git-core curl curl-devel
# Création du groupe rvm (Il suffira d'ajouter les utilisateurs pouvants utiliser rvm à ce groupe)
sudo groupadd rvm
# On y ajoute le compte root (requis pour installer rvm)
sudo usermod -a -G rvm root
# Installation RVM (system wide)
curl -L https://get.rvm.io | sudo bash -s stable
# Suivre les instructions de rvm post installation
# Vérifier dans le .bash_profile la présence de
echo '[[ -s "/usr/local/lib/rvm" ]] && . "/usr/local/lib/rvm" # This loads RVM into a shell session.' >> ~/.bash_profile
# reload bash ou Logout si pb
source ~/.bash_profile
#tester rvm
rvm | head -1 # should print 'rvm is a function'
# Installation des dépendances pour ruby
rvm requirements
# Install Ruby 2.0.0-p247
sudo rvm install 2.0.0
# Utilisation de ruby 2.0.0 par defaut
rvm --default use 2.0.0
# Installation de Passenger
gem install passenger
# Installation nginx avec Passenger. Option 1 nginx compiled
passenger-install-nginx-module
# Installation nginx init script -- : https://gist.github.com/jarod022/7084623#file-nginx
# NGINX_CONF_FILE sur /opt/nginx (à adapter)
cd /etc/init.d
sudo wget -O nginx https://gist.github.com/jarod022/7084623/raw/5ff622dd2f659622af736d6aa7d0c3577f9c38cf/nginx
sudo chmod +x nginx
# démarrage auto de nginx
sudo /sbin/chkconfig nginx on
# Installation de mysql
sudo yum install mysql-devel
# Installation REDIS
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
yum install redis -y
(ne pas oublier de l'ajouter pour un restart auto)
sudo /sbin/chkconfig redis on
# Installation Image Magick
yum install ImageMagick
-------- Ajout d'un projet -------
# Prérequis :
mkdir -p /var/www
# Ajout groupe ssh_users et permitRootLogin No
groupadd -r ssh_users
vi /etc/ssh/sshd_config
AllowGroups ssh_users
# Ajout projet
groupadd name_project
useradd -b /var/www -g name_project -s /bin/bash name_project
usermod -a -G ssh_users name_project
mkdir -p /var/www/name_project/prod
mkdir -p /var/www/name_project/tmp
mkdir -p /var/www/name_project/log
chown -R name_project:name_project /var/www/name_project
# Création BDD & user mysql name_project
# add user to rvm group
usermod -a -G rvm name_project
# Ajout dans le bashrc_profile de name_project
[[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm"
# Création GEMSET: (ruby 2.0.0 par defaut)
Login to name_project
rvm gemset create name_project
# Ajout SSH key dans authorizez_keys pour l'accès de Capistrano.
# Tweak : à ajouter dans /etc/gemrc
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri
----- Exemple VHOST NGINX ----
server {
listen 80;
server_name www.name_project.fr;
error_page 405 =200 $uri;
access_log /var/www/name_project/log/name_project.access_log;
error_log /var/www/name_project/log/name_project.error_log;
root /var/www/name_project/prod/current/public;
passenger_enabled on;
}
server {
listen 80;
server_name .name_project.fr;
rewrite ^ http://www.name_project.fr$request_uri? permanent;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment