Rails Passenger and Nginx + GeoIP module - ruby-on-rails

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

Related

Gems are not found inside Docker container After sourcing RVM path

scenario1
So the problem I am facing like after building the docker images. If I am going inside the docker container and doing GEM_PATH=$GEM_HOME gem list it is not showing all the gems installed at the time of building the image. it is showing only a few gems.
scenario2
If I am not sourcing the RVM path inside the Dockerfile. Then If I am going inside the docker container and doing GEM_PATH=$GEM_HOME gem list then it is showing all the gems.
Can anyone please explain to me why this is happening and how I should install and source RVM? So I can see all the gems inside the container. Basically, I want the scenario1 should work. Thanks
Below is my Dockerfile
FROM ruby:2.6.5
RUN apt-get update -qq && apt-get install -y sudo && apt-get install -y build-essential && apt-get install -y apt-utils && apt-get install -y git
RUN gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB && \curl -sSL https://get.rvm.io | sudo bash -s stable --ruby && echo 'source /usr/local/rvm/scripts/rvm' >> /etc/bash.bashrc
RUN /bin/bash -l -c 'gem install bundler -v 1.17.3'
RUN /bin/bash -l -c 'gem install rails --version=5.2.4.1'
WORKDIR /app
RUN bundle config build.nokogiri --use-system-libraries
RUN bundle config set path 'vendor/bundle'
COPY Gemfile Gemfile.lock ./
ARG SSH_KEY
# Make ssh dir
RUN mkdir /root/.ssh/
# Copy ssh
RUN echo "$SSH_KEY" > /root/.ssh/id_rsa && \
chmod 0600 /root/.ssh/id_rsa
RUN touch /root/.ssh/known_hosts
# Add bitbuckets key
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts
RUN bundle install
COPY . ./
EXPOSE 80:80
CMD rails s -p 80 -b '0.0.0.0' -e qa
TL;DR: don't use rvm\rbenv within a container
the whole thing when using containers, is to bundle\package all the dependencies inside a container. for instance, if you need ruby 2.9 then use a docker image which has ruby 2.9 installed rather than using rvm[rbenv](https://github.com/rbenv/rbenv).
since you are using bundler, i will advise you to add rails gem to it, and let bundler manage the dependencies.
i assume that you care about the directory where rubygems are being installed for caching propose, and i see that you instruct bundler exactly what is the rubygem home directory
RUN bundle config set path 'vendor/bundle'

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.

How to check ruby version inside docker container

I have build the docker container by creating below docker file
# Select ubuntu as the base image
FROM ubuntu
# Install nginx, nodejs and curl
RUN apt-get update -q
RUN apt-get install -qy nginx
RUN apt-get install -qy curl
RUN apt-get install -qy nodejs
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
# Install rvm, ruby, bundler
RUN curl -sSL https://get.rvm.io | bash -s stable
RUN /bin/bash -l -c "rvm requirements"
RUN /bin/bash -l -c "rvm install 2.1.0"
RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc"
# Add configuration files in repository to filesystem
ADD config/container/nginx-sites.conf /etc/nginx/sites-enabled/default
ADD config/container/start-server.sh /usr/bin/start-server
RUN chmod +x /usr/bin/start-server
# Add rails project to project directory
ADD ./ /rails
# set WORKDIR
WORKDIR /rails
# bundle install
RUN /bin/bash -l -c "bundle install"
# Publish port 80
EXPOSE 80
# Startup commands
ENTRYPOINT /usr/bin/start-server
When i go inside the container and give the command ruby -v it throws bash: ruby: command not found
Could any one help me in doing this
I've spent a bit of time messing with RVM, Ruby and Docker recently. This answer might not be what you're looking for, but it needs to be said anyway: if you don't absolutely need RVM, then don't use it in your docker file. You've already noticed one downside: having to pre-empt your commands with /bin/bash -lc. You'll run into another downside if you ever want to have a non-root user run a ruby program in your Docker container. Also, your problem is most likely related to Docker not loading .bashrc or .bash_profile (I forgot which one RVM modifies) when you run a bash shell.
Instead use this to compile Ruby from source:
RUN apt-get update
RUN apt-get install -yq build-essential openssl libreadline6 libreadline6-dev curl git-core \
zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev \
autoconf libc6-dev ncurses-dev automake libtool bison subversion libmysqlclient-dev
ADD http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz /tmp/
RUN cd /tmp && tar -xzf /tmp/ruby-2.1.2.tar.gz
RUN cd /tmp/ruby-2.1.2/ && ./configure --disable-install-doc && make && make install
RUN rm -rf /tmp/*
ADD http://production.cf.rubygems.org/rubygems/rubygems-2.4.1.tgz /tmp/
RUN cd /tmp && tar -xzf /tmp/rubygems-2.4.1.tgz
RUN cd /tmp/rubygems-2.4.1 && ruby setup.rb
RUN rm -rf /tmp/*
RUN echo "gem: --no-ri --no-rdoc" > ~/.gemrc
RUN gem install bundler --no-rdoc --no-ri
You are not setting the default ruby after installing RVM. Trying setting the default ruby after installing it.
RUN /bin/bash -l -c "rvm install 2.1.0"
RUN /bin/bash -l -c "rvm use 2.1.0 --default"

passenger-install-apache2-module fails on ubuntu 12.04

I've installed gem install passenger for my rails app. Now I try passenger-install-apache2-module.
I get errors screen:
Installation instructions for required software
To install Apache 2 development headers:
Please run apt-get install apache2-prefork-dev as root.
To install Apache Portable Runtime (APR) development headers:
Please run apt-get install libapr1-dev as root.
To install Apache Portable Runtime Utility (APU) development headers:
Please run apt-get install libaprutil1-dev as root.
When I run sudo apt-get install apache2-prefork-dev, I get
The following packages have unmet dependencies: apache2-prefork-dev :
Depends: apache2.2-common (= 2.2.22-1ubuntu1) but 2.2.22-1ubuntu1.1 is
to be installed.
E: Unable to correct problems, you have held broken
packages.
When I run sudo apt-get update, it doesn't solve anything. The error still exists.
Try this:
sudo apt-get install apache2-dev
I did that and passenger-install-apache2-module was able to pass the mentioned errors.
For me, the fix was to re-enable the precise-updates repository - I had disabled it in the Update Manager - and updating the system after that.
(I would have liked to only install important security updates, that's why I had disabled it in the first place.)
Try
sudo apt-get -f install
sudo apt-get clean all
sudo apt-get autoremove
sudo apt-get update
sudo apt-get upgrade
Then retry installing apache, plus all the dev packages. You may have to uninstall apache first.
There is also a pre-made package for passenger in the Precise repo:
apt-get install libapache2-mod-passenger

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