Go to file
2024-01-15 00:10:37 +01:00
README.install-with-rbenv Complete file 'README.install-with-rbenv'. 2024-01-15 00:10:37 +01:00

# --------------------
# Installing Ruby using 'ruby version manager'
# --------------------

# see:   https://gorails.com/deploy/ubuntu/24.04

# ---
# 0. Install pre-requisites
# ---

#apt-get install -y apt-transport-https ca-certificates curl gnupg

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 \
   software-properties-common \
   libffi-dev \
   dirmngr \
   gnupg apt-transport-https ca-certificates \
   redis-server redis-tools 

# ---
# 1 Install node.js
# ---

# seei also : https://git.oopen.de/install/node.js.git

NODE_VERSION="20.x"

# Download and import the Nodesource GPG key
#
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION nodistro main"  | tee /etc/apt/sources.list.d/nodesource.list > /dev/null

# N|solid Config
echo "Package: nsolid" | tee /etc/apt/preferences.d/nsolid > /dev/null
echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nsolid > /dev/null
echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nsolid > /dev/null

# Nodejs Config
echo "Package: nodejs" | tee /etc/apt/preferences.d/nodejs > /dev/null
echo "Pin: origin deb.nodesource.com" | tee -a /etc/apt/preferences.d/nodejs > /dev/null
echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/nodejs > /dev/null

apt install nodejs

# ---
# 2. Install yarn

# Download and import Yarn  GPG key 
#
curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor -o /usr/share/keyrings/yarn.gpg

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list  > /dev/null

# Nodejs Yarn
echo "Package: yarn" | tee /etc/apt/preferences.d/yarn > /dev/null
echo "Pin: origin dl.yarnpkg.com" | tee -a /etc/apt/preferences.d/yarn > /dev/null
echo "Pin-Priority: 600" | tee -a /etc/apt/preferences.d/yarn > /dev/null

apt install yarn


# ---
# 3. Install ruby using rbenv (Ruby version mmanager)
# ---

USER=webadmin

su - ${USER}

RUBY_VERSION=3.2.2
SHELL="/bin/bash"

# Next we're going to install Ruby using a Ruby version mmanager called rbenv. 
# It is the easiest and simplest option, plus it comes with some handy plugins 
# to let us easily manage environment variables in production.
#
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc

echo 'eval "$(rbenv init -)"' >> ~/.bashrc

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc

git clone https://github.com/rbenv/rbenv-vars.git ~/.rbenv/plugins/rbenv-vars

exec $SHELL

rbenv install ${RUBY_VERSION}

# Activate this Ruby version as the new default:
#
rbenv global ${RUBY_VERSION}

# Test ruby version
#
ruby -v


# ---
# 4. Install Bundler
# ---

# This installs the latest Bundler, currently 2.x.
#
# Note:
#
#     For older apps that require Bundler 1.x, you can install it as well:
#
#        gem install bundler -v 1.17.3
#
# but we install latest Bundler
#
gem install bundler


?? bundler install ??


# Test version of bundler
#
bundle -v

# exit user $USER
#
exit


# ---
# 5. Install NGINX
# ---

# Note!
#    use install script 
#
#        /usr/local/src/nginx/install_nginx.sh
#
#     from nginx git repository at https://git.oopen.de
#
cd /usr/local/src/
if [[ ! -d "/usr/local/src/nginx" ]] ; then
   git clone https://git.oopen.de/install/nginx
fi

# Install nginx
#
/usr/local/src/nginx/install_nginx.sh

# Install dehydrated (Let's encrypt certification tool)
#
cd /usr/local/src/
if [[ ! -d "/usr/local/src/dehydrated-cron" ]] ; then
   git clone https://git.oopen.de/certificates/dehydrated-cron
fi

# Install dehydrated..
#
/usr/local/src/dehydrated-cron/install_dehydrated.sh



# ---
# 6. Install Passenger packages
# ---

# see also: 
#     https://www.phusionpassenger.com/docs/advanced_guides/install_and_upgrade/nginx/install/oss/bookworm.html
#     https://www.phusionpassenger.com/docs/advanced_guides/install_and_upgrade/nginx/install/#select_os

# install pre-requisites
#
apt-get install -y dirmngr gnupg \
   apt-transport-https \
   ca-certificates curl


# Install PGP key for phusionpassenger.com's repository 
# and add HTTPS support for APT
#
curl https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt \
   | gpg --dearmor \
   | sudo tee /etc/apt/trusted.gpg.d/phusion.gpg >/dev/null

echo "deb https://oss-binaries.phusionpassenger.com/apt/passenger bookworm main" > /etc/apt/sources.list.d/passenger.list
apt update


# Install Passenger + Nginx module
#
apt-get install -y libnginx-mod-http-passenger

# Load passenger module
#
if [ ! -f /etc/nginx/modules-enabled/50-mod-http-passenger.conf ]; then 
   ln -s /usr/share/nginx/modules-available/mod-http-passenger.load /etc/nginx/modules-enabled/50-mod-http-passenger.conf
fi

# Adjust passenger configuration
#
# Change the passenger_ruby line to match the following:
#
#     passenger_ruby /var/www/.rbenv/shims/ruby;
#
perl -i -n -p -e "s/^((\s*passenger_ruby\s+).*)/#\1\n\2/var/www/.rbenv/shims/ruby;/" \
   /etc/nginx/conf.d/mod-http-passenger.conf
vim /etc/nginx/conf.d/mod-http-passenger.conf


# Restart NGINX webservice
#
systemctl restart nginx